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

chore: migrate to @babel/eslint-parser #10761

Merged
merged 10 commits into from
Jul 14, 2021
4 changes: 2 additions & 2 deletions packages/eslint-config-react-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ The easiest way to use this configuration is with [Create React App](https://git

If you want to use this ESLint configuration in a project not built with Create React App, you can install it with the following steps.

First, install this package, ESLint and the necessary plugins.
First, install this package, ESLint and the necessary plugins. Note that when using npm 7 (or greater) this step is not required, as npm will automatically install peer dependencies.

```sh
npm install --save-dev eslint-config-react-app @typescript-eslint/eslint-plugin@^4.0.0 @typescript-eslint/parser@^4.0.0 babel-eslint@^10.0.0 eslint@^7.5.0 eslint-plugin-flowtype@^5.2.0 eslint-plugin-import@^2.22.0 eslint-plugin-jsx-a11y@^6.3.1 eslint-plugin-react@^7.20.3 eslint-plugin-react-hooks@^4.0.8
npm install --save-dev eslint-config-react-app @babel/eslint-parser@^7.13.0 @typescript-eslint/eslint-plugin@^4.0.0 @typescript-eslint/parser@^4.0.0 babel-preset-react-app@^10.0.0 eslint@^7.5.0 eslint-plugin-flowtype@^5.2.0 eslint-plugin-import@^2.22.0 eslint-plugin-jsx-a11y@^6.3.1 eslint-plugin-react@^7.20.3 eslint-plugin-react-hooks@^4.0.8
```

Then create a file named `.eslintrc.json` with following contents in the root folder of your project:
Expand Down
8 changes: 4 additions & 4 deletions packages/eslint-config-react-app/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
module.exports = {
root: true,

parser: 'babel-eslint',
parser: '@babel/eslint-parser',

plugins: ['react'],

Expand All @@ -27,10 +27,10 @@ module.exports = {
},

parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
requireConfigFile: false,
babelOptions: {
mrmckeb marked this conversation as resolved.
Show resolved Hide resolved
presets: ['babel-preset-react-app/prod'],
},
},

Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-config-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
"jest.js"
],
"peerDependencies": {
"@babel/eslint-parser": "^7.13.0",
JLHwung marked this conversation as resolved.
Show resolved Hide resolved
"@typescript-eslint/eslint-plugin": "^4.0.0",
"@typescript-eslint/parser": "^4.0.0",
"babel-eslint": "^10.0.0",
"babel-preset-react-app": "^10.0.0",
"eslint": "^7.5.0",
"eslint-plugin-flowtype": "^5.2.0",
"eslint-plugin-import": "^2.22.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/react-error-overlay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
"lib/index.js"
],
"devDependencies": {
"@babel/code-frame": "^7.10.4",
"@babel/core": "^7.12.3",
"@babel/code-frame": "7.10.4",
"@babel/core": "7.12.3",
"@babel/eslint-parser": "^7.13.14",
"anser": "1.4.10",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.0",
"babel-loader": "^8.1.0",
"babel-preset-react-app": "^10.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/react-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
},
"types": "./lib/react-app.d.ts",
"dependencies": {
"@babel/core": "^7.12.3",
"@babel/core": "7.12.3",
"@babel/eslint-parser": "^7.13.14",
"@pmmmwh/react-refresh-webpack-plugin": "0.4.3",
"@svgr/webpack": "5.5.0",
"@typescript-eslint/eslint-plugin": "^4.5.0",
"@typescript-eslint/parser": "^4.5.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.0",
"babel-loader": "^8.1.0",
"babel-plugin-named-asset-import": "^0.3.7",
Expand Down
4 changes: 3 additions & 1 deletion packages/react-scripts/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ function build(previousFileSizes) {
messages.warnings.length
) {
// Ignore sourcemap warnings in CI builds. See #8227 for more info.
const filteredWarnings = messages.warnings.filter(w => !/Failed to parse source map/.test(w));
const filteredWarnings = messages.warnings.filter(
w => !/Failed to parse source map/.test(w)
);
Comment on lines +197 to +199
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to have come from Prettier, we can leave it in.

if (filteredWarnings.length) {
console.log(
chalk.yellow(
Expand Down
1 change: 1 addition & 0 deletions packages/react-scripts/scripts/utils/verifyPackageTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function verifyPackageTree() {
// These are packages most likely to break in practice.
// See https://github.com/facebook/create-react-app/issues/1795 for reasons why.
// I have not included Babel here because plugins typically don't import Babel (so it's not affected).
'@babel/eslint-parser',
'babel-jest',
'babel-loader',
'jest',
Expand Down