-
-
Notifications
You must be signed in to change notification settings - Fork 206
(PR): add config flat #759
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
Conversation
|
WalkthroughAdds a new Changes
Sequence Diagram(s)sequenceDiagram
participant ESLint as ESLint host
participant PluginFile as eslint-plugin-prettier.js
participant Plugin as eslintPluginPrettier
Note over PluginFile: config registration (flat/recommended)
ESLint->>PluginFile: request configs['flat/recommended']
PluginFile-->>ESLint: returns config object with rules and plugins (lazy getter)
ESLint->>PluginFile: access plugins.prettier
PluginFile->>Plugin: get prettier() { return eslintPluginPrettier }
Plugin-->>ESLint: plugin instance (rules available)
ESLint->>ESLint: apply rules ('prettier/prettier': error, others off)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests
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:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type 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.
Important
Looks good to me! 👍
Reviewed everything up to 9b7b811 in 36 seconds. Click for details.
- Reviewed
23lines of code in1files - Skipped
0files when reviewing. - Skipped posting
3draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. eslint-plugin-prettier.js:144
- Draft comment:
Document the lazy getter for the prettier plugin. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
2. eslint-plugin-prettier.js:143
- Draft comment:
Explain omission of an 'extends' field in the flat config. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
3. eslint-plugin-prettier.js:150
- Draft comment:
Consider extracting common rules to reduce duplication. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
Workflow ID: wflow_lEHJde3kTzfSvKqI
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
eslint-plugin-prettier.js(1 hunks)
🧰 Additional context used
🪛 ESLint
eslint-plugin-prettier.js
[error] 146-146: Insert ;
(prettier/prettier)
[error] 147-147: Insert ,
(prettier/prettier)
[error] 154-154: Insert ,
(prettier/prettier)
| 'flat/recommended': { | ||
| plugins: { | ||
| get prettier() { | ||
| return eslintPluginPrettier | ||
| } | ||
| }, | ||
| rules: { | ||
| 'prettier/prettier': 'error', | ||
| 'arrow-body-style': 'off', | ||
| 'prefer-arrow-callback': 'off', | ||
| }, | ||
| } |
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.
Fix Prettier violations: add missing semicolon and trailing commas in flat config.
These style errors will fail linting. Add the semicolon after the return and commas where indicated.
'flat/recommended': {
plugins: {
get prettier() {
- return eslintPluginPrettier
- }
+ return eslintPluginPrettier;
+ },
},
rules: {
'prettier/prettier': 'error',
'arrow-body-style': 'off',
'prefer-arrow-callback': 'off',
},
- }
+ },📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| 'flat/recommended': { | |
| plugins: { | |
| get prettier() { | |
| return eslintPluginPrettier | |
| } | |
| }, | |
| rules: { | |
| 'prettier/prettier': 'error', | |
| 'arrow-body-style': 'off', | |
| 'prefer-arrow-callback': 'off', | |
| }, | |
| } | |
| 'flat/recommended': { | |
| plugins: { | |
| get prettier() { | |
| return eslintPluginPrettier; | |
| }, | |
| }, | |
| rules: { | |
| 'prettier/prettier': 'error', | |
| 'arrow-body-style': 'off', | |
| 'prefer-arrow-callback': 'off', | |
| }, | |
| }, |
🧰 Tools
🪛 ESLint
[error] 146-146: Insert ;
(prettier/prettier)
[error] 147-147: Insert ,
(prettier/prettier)
[error] 154-154: Insert ,
(prettier/prettier)
🤖 Prompt for AI Agents
In eslint-plugin-prettier.js around lines 143 to 154, the flat/recommended
config is missing a semicolon after the getter's return and missing trailing
commas in the object literals; fix by adding a semicolon after "return
eslintPluginPrettier;" inside the getter, and add the necessary trailing commas
after the plugins getter block, after the rules object entries (and after the
flat/recommended object entry) so the file conforms to Prettier rules.
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
♻️ Duplicate comments (1)
eslint-plugin-prettier.js (1)
147-148: Fix Prettier violations (semicolon + trailing commas).These style errors will fail CI. Add the missing semicolon and commas.
plugins: { get prettier() { - return eslintPluginPrettier - } + return eslintPluginPrettier; + }, }, rules: { 'prettier/prettier': 'error', 'arrow-body-style': 'off', 'prefer-arrow-callback': 'off', }, - } + },Also applies to: 155-155
🧹 Nitpick comments (2)
eslint-plugin-prettier.js (2)
150-154: Confirm parity with classic “recommended” (extends 'prettier').The non-flat
recommendedextendsprettier(eslint-config-prettier), but the flat variant doesn’t import/merge those disables. If divergence is intentional, fine—just make sure it’s documented; if not, consider bundling equivalent disables or advising users to include the flat config from eslint-config-prettier alongside this.
144-144: Nit: clarify the displayed config name.Consider renaming to
prettier/flat/recommendedfor clearer debugging output in Flat Config stacks.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
eslint-plugin-prettier.js(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: JounQin
PR: prettier/eslint-plugin-prettier#743
File: test/prettier.mjs:28-35
Timestamp: 2025-06-17T07:50:43.759Z
Learning: In the eslint-plugin-prettier test file, the pattern `const ESLint = eslintUnsupportedApi.FlatESLint ?? eslint.ESLint;` works correctly even though `eslint` is declared later with `var eslint;` because the hoisted declaration makes `eslint` available throughout the file, and `eslintUnsupportedApi.FlatESLint` is always truthy when this code executes, so the `eslint.ESLint` fallback is never evaluated.
🧬 Code graph analysis (1)
eslint-plugin-prettier.js (1)
test/prettier.mjs (2)
config(547-550)runFixture(498-582)
🪛 ESLint
eslint-plugin-prettier.js
[error] 147-147: Insert ;
(prettier/prettier)
[error] 148-148: Insert ,
(prettier/prettier)
[error] 155-155: Insert ,
(prettier/prettier)
🔇 Additional comments (1)
eslint-plugin-prettier.js (1)
146-149: Getter pattern is correct for self-referencing the plugin.The lazy getter cleanly avoids TDZ/self-reference issues and keeps the flat config consumable without early binding. This matches our prior learning from PR #743 about deferring resolution safely.
|
Flat config is already supported per https://github.com/prettier/eslint-plugin-prettier?tab=readme-ov-file#configuration-new-eslintconfigjs I don't want to add two ways of doing the same thing. |
The form that was added does not follow the conventional pattern followed by the rest of the other libs. I think it would make a lot of sense to follow the same pattern. |
Adds simplicity when importing eslint configurations into new eslint configuration.
Important
Adds
flat/recommendedESLint configuration toeslint-plugin-prettier.jswithprettierplugin and specific rules.flat/recommendedconfig toeslint-plugin-prettier.js.prettierplugin and rules:'prettier/prettier': 'error','arrow-body-style': 'off','prefer-arrow-callback': 'off'.This description was created by
for 9b7b811. You can customize this summary. It will automatically update as commits are pushed.
Summary by CodeRabbit