-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Replace outdated Prettier settings with recommended ones #43756
Conversation
duplicate of #41877? |
@yungsters has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@@ -19,7 +19,7 @@ module.exports = { | |||
}, | |||
}, | |||
|
|||
extends: ['plugin:prettier/recommended'], | |||
extends: ['prettier'], |
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.
Note that this config only turns rules off, so it only makes sense using it together with some other config.
extends: ['prettier'], |
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.
I suspect that people probably rely on it being turned off. So without this, the upgrade path might be too annoying / non-obvious. I think we can remove it separately later.
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.
It feels like I’m missing something. In what situation does it help to have extends: ['prettier']
here? Remember that rules
win over extends
.
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.
The assumption is that developers are using this along with recommended configs (e.g. the ones included with ESLint), so this would disable those rules.
If someone has a project in which they explicitly enable rules that are disabled by eslint-config-prettier
, then yes… this would not overrule that.
@yungsters merged this pull request in 727f30b. |
This pull request was successfully merged by @gaearon in 727f30b. When will my fix make it into a release? | How to file a pick request? |
react native config no long runs prettier as part of eslint facebook/react-native#43756 We now run prettier on its own
* build: add prettier as a separate command react native config no long runs prettier as part of eslint facebook/react-native#43756 We now run prettier on its own * style: format code
Summary:
The React Native ESLint preset currently endorses the Prettier integration that is explicitly recommended against by Pretier itself. Notice the difference between these two packages:
eslint-config-prettier
is the config that turns off all formatting rules. It's recommended by Prettier to be used together with Prettier. You'd still use Prettier itself to actually do the formatting.eslint-plugin-prettier
is a legacy plugin developed a long time ago and that predates most modern Prettier integrations. It runs Prettier as if it were an ESLint rule, applies formatting on--fix
, and is not recommended.Unfortunately, RN uses the latter one (and always has).
This PR removes
eslint-plugin-prettier
and instead enableseslint-config-prettier
, as recommended by Prettier.As a consequence, you'll no longer see squiggly lines in your editor for stuff that isn't actually errors:
As another consequence, you'll have to set up your own Prettier step in your pipeline.
For example, if your precommit hook only contained
eslint --fix
, you'll now also need to runprettier --write
there as well. Similarly, if you want Prettier to fail CI, you'd need to find where you calleslint
and also doprettier --check
there.Here's an example for how to do it: bluesky-social/social-app#3373
Changelog:
[GENERAL] [BREAKING] - RN ESLint config no longer runs Prettier during ESLint
Test Plan:
Tested locally, verified formatting changes no longer get flagged as violations by the RN config.