From d4220ccfb72da7ec25e393b40130223b06d92268 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Thu, 1 Dec 2022 09:28:16 -0800 Subject: [PATCH] Simplify Template ESLint Configuration (#35529) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/35529 ESLint configuration is derived from `react-native/eslint-config`, which has supported Flow, vanilla JS, and TypeScript. https://github.com/react-native-community/react-native-template-typescript/pull/238 and a related PR ended up adding new rules to the TypeScript config, to fix bugs with TS linting. It required a followup change, to specify the parser/plugin, and explicity reference them as devDependencies. https://github.com/react-native-community/react-native-template-typescript/pull/240 `react-native/eslint-config` already includes setting the plugin/parser. But overriding rules requires declaring that again, and directly referencing a plugin means a need for the app to declare dependencies, since ESLint resolves modules from the current config. The rules overridedn were later fixed in `react-native/eslint-config`, which is really the right place for the fix (e.g. https://github.com/facebook/react-native/pull/32644). I noticed this when deriving from the TS template in https://github.com/facebook/react-native/pull/32644 and removed the rule overrides, but didn't have the historical context to realize this means we can then: 1. Remove the explicit parser/plugins since `react-native/eslint-config` already sets them, and we are no longer overriding any rules. 2. Remove the devDependencies, to let the versions be managed entirely by `react-native/eslint-config`. Changelog: [General][Changed] - Simplify Template ESLint Configuration Reviewed By: cortinico Differential Revision: D41652699 fbshipit-source-id: 8e3313dbf27407c5866f3c2432cffc2ecec1b01d # Conflicts: # template/_eslintrc.js --- template/_eslintrc.js | 4 +--- template/package.json | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/template/_eslintrc.js b/template/_eslintrc.js index 189699723fd268..187894b6af25ee 100644 --- a/template/_eslintrc.js +++ b/template/_eslintrc.js @@ -1,6 +1,4 @@ module.exports = { root: true, - extends: '@react-native-community', - parser: '@typescript-eslint/parser', - plugins: ['@typescript-eslint'], + extends: '@react-native', }; diff --git a/template/package.json b/template/package.json index e9184784366179..b86fcc47bd480a 100644 --- a/template/package.json +++ b/template/package.json @@ -22,8 +22,6 @@ "@types/jest": "^29.2.1", "@types/react": "^18.0.24", "@types/react-test-renderer": "^18.0.0", - "@typescript-eslint/eslint-plugin": "^5.37.0", - "@typescript-eslint/parser": "^5.37.0", "babel-jest": "^29.2.1", "eslint": "^8.19.0", "jest": "^29.2.1",