Skip to content

Commit

Permalink
Update babel-eslint → @babel/eslint-parser (#20085)
Browse files Browse the repository at this point in the history
  • Loading branch information
anomiex authored Jun 29, 2021
1 parent 8463c84 commit 3128bbe
Show file tree
Hide file tree
Showing 29 changed files with 458 additions and 91 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ projects/plugins/jetpack/modules/custom-css/custom-css/js/core-customizer-css.co
projects/plugins/jetpack/modules/custom-css/custom-css/js/core-customizer-css.js
projects/plugins/jetpack/modules/widgets/search/js/search-widget-admin.js

projects/plugins/jetpack/tests/e2e/output/
projects/plugins/jetpack/vendor/

# Temporary ignore until Jest is set up
Expand All @@ -33,5 +34,7 @@ projects/*/*/vendor
projects/github-actions/*/dist
projects/packages/*/wordpress
projects/packages/connection-ui/build
projects/packages/identity-crisis/build
projects/packages/jitm/src/js/jetpack-jitm.js
projects/packages/lazy-images/dist
projects/plugins/backup/build
20 changes: 4 additions & 16 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
root: true,
parser: 'babel-eslint',
extends: [ 'wpcalypso/react', 'plugin:jsx-a11y/recommended', 'prettier' ],
parser: '@babel/eslint-parser',
extends: [ 'wpcalypso', 'plugin:jsx-a11y/recommended', 'prettier' ],
env: {
browser: true,
es6: true,
Expand All @@ -15,12 +15,9 @@ module.exports = {
ecmaFeatures: {
jsx: true,
},
requireConfigFile: false,
},
settings: {
react: {
version: 'detect', // React version. "detect" automatically picks the version you have installed.
},
},
settings: {},
plugins: [ 'jsx-a11y', 'lodash', 'jsdoc' ],
rules: {
// REST API objects include underscores
Expand Down Expand Up @@ -60,15 +57,6 @@ module.exports = {
],
'padded-blocks': [ 2, 'never' ],
'prefer-const': 2,
'react/jsx-curly-spacing': [ 2, 'always' ],
'react/jsx-no-bind': 2,
// 'react/jsx-space-before-closing': 2,
'react/jsx-tag-spacing': [ 2, { beforeSelfClosing: 'always' } ],
'react/no-danger': 2,
'react/no-did-mount-set-state': 2,
'react/no-did-update-set-state': 2,
'react/no-is-mounted': 2,
'react/prefer-es6-class': 1,
semi: 2,
'semi-spacing': 2,
'space-before-blocks': [ 2, 'always' ],
Expand Down
40 changes: 40 additions & 0 deletions .eslintrc.react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// eslint config for react-using projects. Extend this instead of .eslintrc.js, probably like this:
//
// ```
// module.exports = {
// // This project uses react, so load the shared react config.
// root: true,
// extends: [ '../../../.eslintrc.react.js' ],
// parserOptions: {
// babelOptions: {
// configFile: require.resolve( './babel.config.js' ),
// },
// },
// };
// ```

module.exports = {
root: true,
parser: '@babel/eslint-parser',
extends: [ 'wpcalypso/react', './.eslintrc.js' ],
parserOptions: {
requireConfigFile: true,
},
settings: {
react: {
version: 'detect', // React version. "detect" automatically picks the version you have installed.
},
},
rules: {
'react/jsx-curly-spacing': [ 2, 'always' ],
'react/jsx-no-bind': 2,
// 'react/jsx-space-before-closing': 2,
'react/jsx-tag-spacing': [ 2, { beforeSelfClosing: 'always' } ],
'react/no-danger': 2,
'react/no-did-mount-set-state': 2,
'react/no-did-update-set-state': 2,
'react/no-is-mounted': 2,
'react/prefer-es6-class': 1,
'react/no-string-refs': 0,
},
};
1 change: 1 addition & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
js:
# If any JS file changed, they need checking.
- added|modified:
- '**.cjs'
- '**.js'
- '**.jsx'
excludelist:
Expand Down
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
save-exact = true
prefer-workspace-packages = true

# Default, minus eslint.
public-hoist-pattern=['*types*', '@prettier/plugin-*', '*prettier-plugin-*']
23 changes: 4 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@
"docker:wp": "printf '\\e[30;43m`pnpm run docker:wp` is deprected. Use the Jetpack CLI instead.\\e[0m\\n'; jetpack docker wp",
"install-if-deps-outdated": "pnpm install --no-prod --frozen-lockfile",
"lint": "pnpm run lint-file -- .",
"lint-changed": "eslint-changed --ext .js,.jsx --git",
"lint-file": "eslint --ext .js,.jsx",
"lint-changed": "eslint-changed --ext .js,.jsx,.cjs --git",
"lint-file": "eslint --ext .js,.jsx,.cjs",
"lint-required": "node -e \"const fs = require('fs'); fs.copyFileSync('.eslintignore','.eslintignore-required'); const w=fs.createWriteStream('.eslintignore-required',{flags:'a'}); w.write('\\n# tools/eslint-excludelist.json\\n'); w.end(JSON.parse(fs.readFileSync('tools/eslint-excludelist.json','utf8')).join('\\n')+'\\n')\" && pnpm run lint -- --max-warnings=0 --ignore-path .eslintignore-required",
"php:autofix": "composer phpcs:fix",
"php:compatibility": "composer phpcs:compatibility",
"php:lint": "composer phpcs:lint",
"reformat-files": "prettier --ignore-path .eslintignore --write \"**/*.{js,jsx,json}\"",
"reformat-files": "prettier --ignore-path .eslintignore --write \"**/*.{js,jsx,cjs,json}\"",
"validate-es5": "pnpx eslint --parser-options=ecmaVersion:5 --no-eslintrc --no-ignore",
"version-packages": "bash ./tools/version-packages.sh"
},
Expand All @@ -84,25 +84,10 @@
"chalk": "4.1.1"
},
"devDependencies": {
"@automattic/eslint-changed": "workspace:1.0.1-alpha",
"@wordpress/eslint-plugin": "7.4.0",
"babel-eslint": "10.1.0",
"eslint": "7.25.0",
"eslint-config-prettier": "8.3.0",
"eslint-config-wpcalypso": "6.1.0",
"eslint-loader": "4.0.2",
"eslint-plugin-es5": "1.5.0",
"eslint-plugin-inclusive-language": "1.2.1",
"eslint-plugin-jest": "24.3.6",
"eslint-plugin-jsdoc": "32.3.3",
"eslint-plugin-jsx-a11y": "6.4.1",
"eslint-plugin-lodash": "7.2.0",
"eslint-plugin-prettier": "3.4.0",
"eslint-plugin-react": "7.23.2",
"eslint-plugin-wpcalypso": "5.0.0",
"glob": "7.1.6",
"husky": "4.3.8",
"jetpack-cli": "workspace:1.0.0",
"jetpack-eslint": "workspace:*",
"parse-diff": "0.8.1",
"prettier": "npm:[email protected]",
"semver": "7.3.5",
Expand Down
Loading

0 comments on commit 3128bbe

Please sign in to comment.