Skip to content
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

Add flat recommended config #616

Merged
merged 2 commits into from Dec 19, 2023
Merged

Add flat recommended config #616

merged 2 commits into from Dec 19, 2023

Conversation

BPScott
Copy link
Member

@BPScott BPScott commented Dec 3, 2023

Fixes #591.
Fixes #592.
Original ideas extracted from #592.

Add flat recommended config file. Unlike the legacy recommended file this only enables the prettier rule and disables arrow-body-style and arrow-body-style. It does not enable anything from eslint-config-prettier.

It is now the responsibility of the consumer to enable both eslint-plugin-prettier and eslint-config-prettier. Configs extending other configs is complicated and not transparent. We should trust the user to configure their configs directly. In a future major change we should remove eslint-config-prettier from the legacy config too, as over lap between the responsibilities of eslint-plugin-prettier and eslint-config-prettier have always been a bit confusing and "a plugin goes and enables configs from other plugins" feels a bit odd. I think it is simpler if we push consumers towards "you configure both eslint-plugin-prettier and eslint-config-prettier in your repo's linting config.

Use it like this:

// eslint.config.js
const eslintPluginPrettierRecommended = require('eslint-plugin-prettier/recommended');
const eslintConfigPrettier = require('eslint-config-prettier');

return [
  eslintPluginPrettierRecommended,
  eslintConfigPrettier,
]

Copy link

changeset-bot bot commented Dec 3, 2023

🦋 Changeset detected

Latest commit: 3f05f8b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-prettier Minor

Not sure what this means? Click here to learn what changesets are.

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

@BPScott BPScott changed the title feat: add flat recommended config Add flat recommended config Dec 3, 2023
@BPScott BPScott marked this pull request as ready for review December 4, 2023 02:40
@BPScott BPScott requested a review from JounQin December 4, 2023 02:40
README.md Show resolved Hide resolved
recommended.js Show resolved Hide resolved
@BPScott
Copy link
Member Author

BPScott commented Dec 4, 2023

@JounQin, @filiptammergard I've extracted the ideas from what we discussed in #592, and have rewritten the README to talk about the legacy vs new flat config.

I've dropped talking about "how to configure the plugin without using a config as I feel that just confuses people - the other plugins I've looked at all talk about leveraging configs first and only.

recommended.js is a flat config version of the recommended config.

This diverges from the legacy config version of the recommended config
as it does not automatically configure eslint-config-prettier.

Configs extending other configs is complicated and not transparent. We
should trust the user to configure their configs directly. In a future
major change we should remove eslint-config-prettier from the legacy
config too.
@BPScott
Copy link
Member Author

BPScott commented Dec 19, 2023

@JounQin Thanks for the productive discussion. I've updated this PR so that the flat recommended config continues to extend from eslint-config-prettier. I've rerequested a review.

recommended.js Outdated Show resolved Hide resolved
recommended.js Outdated Show resolved Hide resolved
@JounQin
Copy link
Member

JounQin commented Dec 19, 2023

@BPScott Thanks for accepting my proposal, and your writing is always impressive, I'm learning how to write such clear document from you as always!

Copy link
Member

@JounQin JounQin left a comment

Choose a reason for hiding this comment

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

Thanks for addressing my nitpicking! Great work!

@BPScott BPScott merged commit 3856413 into master Dec 19, 2023
4 checks passed
@BPScott BPScott deleted the flat-config-2 branch December 19, 2023 20:00
@pplancq pplancq mentioned this pull request May 6, 2024
16 tasks
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.

Support ESLint flat config
2 participants