-
-
Notifications
You must be signed in to change notification settings - Fork 8
feat: add insertFinalNewline to UserOptions #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request updates the manifest JSON writing logic in the codebase. The Changes
Sequence Diagram(s)sequenceDiagram
participant S as Setup
participant M as ManifestContext
participant F as FileWriter
S->>M: onUpdate(options)
Note right of M: options include { minify, insertFinalNewline }
M->>M: Process options in WriteManifestJSON
alt insertFinalNewline true
M->>F: Write JSON with final newline
else
M->>F: Write JSON without final newline
end
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/core/src/context.ts (1)
39-42
: Consider updating the CheckManifestJsonFile method to also pass options.The
CheckManifestJsonFile
method callsWriteManifestJSON
without any options, which means it won't respect user-configured options. Consider updating this method to accept and pass options.- static CheckManifestJsonFile() { - if (!existsSync(manifestJsonPath)) - ManifestContext.WriteManifestJSON() - } + static CheckManifestJsonFile(opts?: ResolvedOptions) { + if (!existsSync(manifestJsonPath)) + ManifestContext.WriteManifestJSON(undefined, opts) + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/core/src/context.ts
(1 hunks)packages/core/src/options.ts
(1 hunks)packages/core/src/types.ts
(1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
packages/core/src/context.ts (2)
packages/core/src/types.ts (1)
ResolvedOptions
(16-16)packages/core/src/constant.ts (1)
manifestJsonPath
(6-8)
🔇 Additional comments (6)
packages/core/src/types.ts (1)
7-11
: New option added correctly with proper documentation.The
insertFinalNewline
option is well-documented with a clear description and default value annotation, following the same pattern as the existingminify
property.packages/core/src/options.ts (1)
6-6
: Default value set correctly for the new option.The
insertFinalNewline
property has been added with a default value offalse
in theresolveOptions
function, which is consistent with the documentation in the types file.packages/core/src/context.ts (4)
24-24
: Good update to use the complete options object.The change correctly passes the entire
options
object toWriteManifestJSON
instead of just theminify
property, which is necessary to support the newinsertFinalNewline
option.
27-27
: Properly updated the initial manifest writing call.This line was also updated to pass the complete options object, maintaining consistency with the change on line 24.
32-32
: Method signature updated to accept the options object.The signature change from accepting a boolean parameter to an options object improves the API by making it more extensible for future options.
35-35
: Properly implemented the new option.The implementation correctly applies the
insertFinalNewline
option by conditionally appending a newline character to the JSON string. The optional chaining operator (?.
) is used appropriately.
Description 描述
增加
insertFinalNewline
参数支持editorconfig
的insert_final_newline
效果Linked Issues 关联的 Issues
Additional context 额外上下文
Summary by CodeRabbit