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

Simplify Template ESLint Configuration #35529

Closed
wants to merge 1 commit into from

Conversation

NickGerleman
Copy link
Contributor

Summary:
ESLint configuration is derived from react-native/eslint-config, which has supported Flow, vanilla JS, and TypeScript.

react-native-community/react-native-template-typescript#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. react-native-community/react-native-template-typescript#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. #32644). I noticed this when deriving from the TS template in #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

Differential Revision: D41652699

Summary:
ESLint configuration is derived from `react-native/eslint-config`, which has supported Flow, vanilla JS, and TypeScript.

react-native-community/react-native-template-typescript#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. react-native-community/react-native-template-typescript#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. facebook#32644). I noticed this when deriving from the TS template in facebook#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

Differential Revision: D41652699

fbshipit-source-id: 67620f12f8fa0ec94fc4db2cbbd2a60a62b70874
@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner fb-exported labels Dec 1, 2022
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D41652699

NickGerleman added a commit to facebook/react-native-website that referenced this pull request Dec 1, 2022
facebook/react-native#35529 simplifies the ESLint config of the template a bit more compared to the previous version, more directly derived from the community template. I expect it will be cherry-picked into 0.71, so this updates the corresponding TS documentation on adding TS to a non-TS project to remove the extra differences.
@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 7,098,138 +0
android hermes armeabi-v7a 6,467,177 +0
android hermes x86 7,516,238 +0
android hermes x86_64 7,374,451 +0
android jsc arm64-v8a 8,963,115 +0
android jsc armeabi-v7a 7,694,749 +0
android jsc x86 9,025,713 +0
android jsc x86_64 9,503,046 +0

Base commit: da4243b
Branch: main

@Pranav-yadav
Copy link
Contributor

Hi @NickGerleman
Since this PR is related to eslint, posting here. 👇
From here #35479 (comment) (Riccardo isn't available until next week)


yarn lint gives error on Win10 m/c -- me

How are you invoking it? -- Riccardo

From git-bash, yarn lint as well as tried eslint .
Also tried from cmd; gives same error 🤔

Click Me

image


Any guess ?

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 217696e
Branch: main

@pull-bot
Copy link

pull-bot commented Dec 1, 2022

PR build artifact for 571f106 is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

@pull-bot
Copy link

pull-bot commented Dec 1, 2022

PR build artifact for 571f106 is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

@github-actions
Copy link

github-actions bot commented Dec 1, 2022

This pull request was successfully merged by @NickGerleman in 68d6214.

When will my fix make it into a release? | Upcoming Releases

@github-actions github-actions bot added the Merged This PR has been merged. label Dec 1, 2022
kelset pushed a commit that referenced this pull request Dec 13, 2022
Summary:
Pull Request resolved: #35529

ESLint configuration is derived from `react-native/eslint-config`, which has supported Flow, vanilla JS, and TypeScript.

react-native-community/react-native-template-typescript#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. react-native-community/react-native-template-typescript#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. #32644). I noticed this when deriving from the TS template in #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
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
Summary:
Pull Request resolved: facebook#35529

ESLint configuration is derived from `react-native/eslint-config`, which has supported Flow, vanilla JS, and TypeScript.

react-native-community/react-native-template-typescript#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. react-native-community/react-native-template-typescript#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. facebook#32644). I noticed this when deriving from the TS template in facebook#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
@cipolleschi cipolleschi mentioned this pull request Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants