Skip to content

Conversation

@luas10c
Copy link

@luas10c luas10c commented Sep 1, 2025

Adds simplicity when importing eslint configurations into new eslint configuration.

  • add flat/recommended config

Important

Adds flat/recommended ESLint configuration to eslint-plugin-prettier.js with prettier plugin and specific rules.

  • Configuration:
    • Adds flat/recommended config to eslint-plugin-prettier.js.
    • Includes prettier plugin and rules: 'prettier/prettier': 'error', 'arrow-body-style': 'off', 'prefer-arrow-callback': 'off'.

This description was created by Ellipsis for 9b7b811. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • New Features
    • Added a flat/recommended ESLint configuration to support ESLint’s flat config format.
    • Exposes an equivalent, dedicated config named "prettier/recommended" for easy adoption.
    • Retains existing rule behavior: enforces Prettier and keeps arrow-body-style and prefer-arrow-callback disabled.

@changeset-bot
Copy link

changeset-bot bot commented Sep 1, 2025

⚠️ No Changeset found

Latest commit: cff10b0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Sep 1, 2025

Walkthrough

Adds a new flat/recommended ESLint config to eslint-plugin-prettier.js that exposes the plugin via a lazy getter named prettier and defines the same rule set as the existing recommended config (prettier/prettier: error, arrow-body-style: off, prefer-arrow-callback: off). No rule logic changed.

Changes

Cohort / File(s) Summary
ESLint plugin config
eslint-plugin-prettier.js
Adds configs['flat/recommended'] with name: 'prettier/recommended', plugins using a lazy getter (get prettier() { return eslintPluginPrettier }), and rules: 'prettier/prettier': 'error', 'arrow-body-style': 'off', 'prefer-arrow-callback': 'off'. No other logic modified.

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)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • JounQin

Poem

I twitch my nose at config's seam,
A flat new rule to join the team.
Lazy getter calls my name,
Same tidy rules, unchanged game.
Hop, stamp — the code is neat and prim. 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@ellipsis-dev ellipsis-dev bot left a 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 23 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 draft 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% <= threshold 50% 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% <= threshold 50% 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% <= threshold 50% None

Workflow ID: wflow_lEHJde3kTzfSvKqI

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Copy link

@coderabbitai coderabbitai bot left a 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.

📥 Commits

Reviewing files that changed from the base of the PR and between befda88 and 9b7b811.

📒 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)

Comment on lines 143 to 154
'flat/recommended': {
plugins: {
get prettier() {
return eslintPluginPrettier
}
},
rules: {
'prettier/prettier': 'error',
'arrow-body-style': 'off',
'prefer-arrow-callback': 'off',
},
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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.

Suggested change
'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.

Copy link

@coderabbitai coderabbitai bot left a 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 recommended extends prettier (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/recommended for 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 9b7b811 and cff10b0.

📒 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.

@BPScott
Copy link
Member

BPScott commented Sep 1, 2025

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.
We might change our approach in the future, but considering this package has basically zero maintenance burden that feels like busywork and making breaking changes just for the sake of it.

@BPScott BPScott closed this Sep 1, 2025
@luas10c
Copy link
Author

luas10c commented Sep 7, 2025

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. We might change our approach in the future, but considering this package has basically zero maintenance burden that feels like busywork and making breaking changes just for the sake of it.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants