From 727f30bd0b27ff168e6a6556a9ffbc7e42dbb8f0 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 3 Apr 2024 23:38:12 -0700 Subject: [PATCH] Replace outdated Prettier settings with recommended ones (#43756) Summary: The React Native ESLint preset currently endorses the Prettier integration that is [explicitly recommended against by Pretier itself](https://prettier.io/docs/en/integrating-with-linters). 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 enables `eslint-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: Screenshot 2024-04-01 at 20 00 50 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 run `prettier --write` there as well. Similarly, if you want Prettier to fail CI, you'd need to find where you call `eslint` and also do `prettier --check` there. Here's an example for how to do it: https://github.com/bluesky-social/social-app/pull/3373 ## Changelog: [GENERAL] [BREAKING] - RN ESLint config no longer runs Prettier during ESLint Pull Request resolved: https://github.com/facebook/react-native/pull/43756 Test Plan: Tested locally, verified formatting changes no longer get flagged as violations by the RN config. Screenshot 2024-04-01 at 20 33 55 Reviewed By: motiz88 Differential Revision: D55643699 Pulled By: yungsters fbshipit-source-id: 97df774275922086f0356ac857d6425713184e39 --- packages/eslint-config-react-native/index.js | 2 +- packages/eslint-config-react-native/package.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-react-native/index.js b/packages/eslint-config-react-native/index.js index b1d0ee3cf36..7ab0ee00835 100644 --- a/packages/eslint-config-react-native/index.js +++ b/packages/eslint-config-react-native/index.js @@ -19,7 +19,7 @@ module.exports = { }, }, - extends: ['plugin:prettier/recommended'], + extends: ['prettier'], plugins: [ 'eslint-comments', diff --git a/packages/eslint-config-react-native/package.json b/packages/eslint-config-react-native/package.json index d2fd202cfb6..a46fc3126ef 100644 --- a/packages/eslint-config-react-native/package.json +++ b/packages/eslint-config-react-native/package.json @@ -29,7 +29,6 @@ "eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-ft-flow": "^2.0.1", "eslint-plugin-jest": "^27.9.0", - "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-react": "^7.30.1", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-native": "^4.0.0"