fix(linter): correct capitalized-comments rule config schema to tuple format#17208
fix(linter): correct capitalized-comments rule config schema to tuple format#17208
Conversation
CodSpeed Performance ReportMerging #17208 will not alter performanceComparing Summary
Footnotes
|
94a3aa3 to
7514288
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes the incorrect configuration documentation for the capitalized-comments linter rule to match ESLint's tuple array format.
Key changes:
- Created a dedicated
CapitalizedCommentsSchematuple struct to represent the configuration as[capitalize_option, options] - Added comprehensive documentation comments to all configuration fields
- Updated the rule declaration to use the new schema for proper documentation generation
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// - First element: `"always"` (default) or `"never"` - controls whether comments should be capitalized | ||
| /// - Second element: Optional object with additional configuration properties | ||
| #[derive(Debug, Clone, Deserialize, JsonSchema)] | ||
| #[serde(deny_unknown_fields)] |
There was a problem hiding this comment.
The deny_unknown_fields attribute is not semantically meaningful for tuple structs. Tuple structs are serialized as arrays with positional elements, not as objects with named fields. This attribute is typically used with named structs to reject JSON objects with unexpected properties. Since this struct is only used for schema generation and not runtime deserialization, consider removing this attribute as it may cause confusion or unexpected schema generation behavior.
| #[serde(deny_unknown_fields)] |
There was a problem hiding this comment.
I think this is probably true? But my suggestion being applied broke this suggestion so
b549884 to
c66acd9
Compare
- Changed config schema from OptionsJson to CapitalizedCommentsSchema - CapitalizedCommentsSchema properly represents tuple: [capitalize_option, options] - Added descriptions to all configuration fields for better documentation - First element: "always" | "never" (controls capitalization requirement) - Second element: optional object with ignorePattern, ignoreInlineComments, etc. - Documentation now matches ESLint format with proper tuple structure Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com>
Follow clippy recommendation to use #[expect(dead_code)] instead of #[allow(dead_code)] Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com>
Replace #[schemars(description)] attributes with /// doc comments as per review feedback. This aligns with the codebase convention and lets the doc generation system pick them up automatically. Co-authored-by: connorshea <2977353+connorshea@users.noreply.github.com>
Signed-off-by: Connor Shea <connor.james.shea@gmail.com>
Signed-off-by: Connor Shea <connor.james.shea@gmail.com>
Signed-off-by: Connor Shea <connor.james.shea@gmail.com>
Signed-off-by: Connor Shea <connor.james.shea@gmail.com>
Signed-off-by: Connor Shea <connor.james.shea@gmail.com>
408cac2 to
c159008
Compare
|
Closing in favor of #18748 |
) Fixes #17191. Previously, the docs were incorrect and a bit confusing for the user to understand. Now it's possible to actually configure the linter rule based on the docs. AI Disclosure: Change was made with help from Claude Code and also based on the changes originally made with #17208. Generated docs: ```md ## Configuration Configuration for the capitalized-comments rule. The first element specifies whether comments should `"always"` or `"never"` begin with a capital letter. The second element is an optional object containing additional options. ### The 1st option type: `"always" | "never"` ### The 2nd option This option is an object with the following properties: #### block type: `object` Configuration options specific to block comments. ##### block.ignoreConsecutiveComments type: `boolean` If true, consecutive comments will be ignored after the first comment. ##### block.ignoreInlineComments type: `boolean` If true, inline comments (comments in the middle of code) will be ignored. ##### block.ignorePattern type: `string` A regex pattern. Comments that match the pattern will not cause violations. #### ignoreConsecutiveComments type: `boolean` If true, consecutive comments will be ignored after the first comment. #### ignoreInlineComments type: `boolean` If true, inline comments (comments in the middle of code) will be ignored. #### ignorePattern type: `string` A regex pattern. Comments that match the pattern will not cause violations. #### line type: `object` Configuration options specific to line comments. ##### line.ignoreConsecutiveComments type: `boolean` If true, consecutive comments will be ignored after the first comment. ##### line.ignoreInlineComments type: `boolean` If true, inline comments (comments in the middle of code) will be ignored. ##### line.ignorePattern type: `string` A regex pattern. Comments that match the pattern will not cause violations. ```
Fix capitalized-comments rule configuration documentation
Resolves the issue where the capitalized-comments rule had incorrect configuration option docs that didn't match ESLint's format.
Changes Made
Created proper tuple schema (
CapitalizedCommentsSchema)[capitalize_option, options]"always"|"never"enumAdded comprehensive field descriptions for all configuration options using doc comments:
ignorePattern: Pattern for comments to ignoreignoreInlineComments: Whether to ignore inline commentsignoreConsecutiveComments: Whether to ignore consecutive commentsline: Configuration specific to line commentsblock: Configuration specific to block commentsUpdated schema generation
config = OptionsJsontoconfig = CapitalizedCommentsSchemaindeclare_oxc_lint!///doc comments instead of#[schemars(description)]attributes per codebase conventionVerification
Example Generated Documentation
Example Configuration
{ "rules": { "capitalized-comments": ["warn", "always", { "ignorePattern": "pragma|ignored", "ignoreInlineComments": true, "ignoreConsecutiveComments": true, "line": { "ignorePattern": "pragma|ignored" }, "block": { "ignorePattern": "ignored" } }] } }Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.