From 79db534f6afc0be1c9b1a6c7c3fdf825cbe52827 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sat, 24 Apr 2021 14:52:21 +0200 Subject: [PATCH] Add @babel/eslint-plugin (#187) Closes #186. --- .eslintrc.base.js | 5 ++-- README.md | 3 +++ babel.config.json | 3 +++ index.js | 2 ++ package-lock.json | 65 ++++++++++++++++++++++++++++++--------------- package.json | 5 +++- test-lint/@babel.js | 6 +++++ test-lint/babel.js | 2 +- 8 files changed, 65 insertions(+), 26 deletions(-) create mode 100644 babel.config.json create mode 100644 test-lint/@babel.js diff --git a/.eslintrc.base.js b/.eslintrc.base.js index df6d454..59fbd85 100644 --- a/.eslintrc.base.js +++ b/.eslintrc.base.js @@ -23,7 +23,7 @@ module.exports = { ), ], parserOptions: { - parser: "babel-eslint", + parser: "@babel/eslint-parser", ecmaVersion: 2018, sourceType: "script", // Needed for the lint-verify-fail.test.js test. @@ -63,9 +63,10 @@ module.exports = { "unicorn/prefer-module": "off", "unicorn/prefer-spread": "off", "unicorn/prevent-abbreviations": "off", - // Force a conflict with Prettier in test-lint/babel.js. + // Force a conflict with Prettier in test-lint/@babel.js. and test-lint/babel.js. "object-curly-spacing": "off", "babel/object-curly-spacing": ["error", "never"], + "@babel/object-curly-spacing": ["error", "never"], }, overrides: [ { diff --git a/README.md b/README.md index 21de154..4a55917 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ Then, add `"prettier"` to the "extends" array in your `.eslintrc.*` file. Make s That’s it! Extending `"prettier"` turns off a bunch of core ESLint rules, as well as a few rules from these plugins: - [@typescript-eslint/eslint-plugin] +- [@babel/eslint-plugin] - [eslint-plugin-babel] - [eslint-plugin-flowtype] - [eslint-plugin-react] @@ -655,6 +656,7 @@ eslint-config-prettier has been tested with: - eslint-config-prettier 2.10.0 and older were tested with ESLint 4.x - eslint-config-prettier 2.1.1 and older were tested with ESLint 3.x - prettier 2.2.1 +- @babel/eslint-plugin 7.13.16 - @typescript-eslint/eslint-plugin 4.22.0 - eslint-plugin-babel 5.3.1 - eslint-plugin-flowtype 5.7.2 @@ -710,6 +712,7 @@ When you’re done, run `npm test` to verify that you got it all right. It runs [MIT](LICENSE). +[@babel/eslint-plugin]: https://github.com/babel/babel/tree/main/eslint/babel-eslint-plugin [@typescript-eslint/eslint-plugin]: https://github.com/typescript-eslint/typescript-eslint [@typescript-eslint/quotes]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/quotes.md [arrow-body-style]: https://eslint.org/docs/rules/arrow-body-style diff --git a/babel.config.json b/babel.config.json new file mode 100644 index 0000000..69ac40b --- /dev/null +++ b/babel.config.json @@ -0,0 +1,3 @@ +{ + "plugins": ["@babel/plugin-syntax-jsx", "@babel/plugin-syntax-flow"] +} diff --git a/index.js b/index.js index d1163bd..5bbaff1 100644 --- a/index.js +++ b/index.js @@ -92,6 +92,8 @@ module.exports = { "wrap-iife": "off", "wrap-regex": "off", "yield-star-spacing": "off", + "@babel/object-curly-spacing": "off", + "@babel/semi": "off", "@typescript-eslint/brace-style": "off", "@typescript-eslint/comma-dangle": "off", "@typescript-eslint/comma-spacing": "off", diff --git a/package-lock.json b/package-lock.json index 9e85307..00f7757 100644 --- a/package-lock.json +++ b/package-lock.json @@ -130,6 +130,15 @@ } } }, + "@babel/eslint-plugin": { + "version": "7.13.16", + "resolved": "https://registry.npmjs.org/@babel/eslint-plugin/-/eslint-plugin-7.13.16.tgz", + "integrity": "sha512-RNL0dLHBvjXW857JwzToTHxtbOZfGcvdSegcgXC1c1PqfE+o/QN8MugkgKj2vXFxCcMByfxJrmpCbLzVBVlgIA==", + "dev": true, + "requires": { + "eslint-rule-composer": "^0.3.0" + } + }, "@babel/generator": { "version": "7.11.6", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.11.6.tgz", @@ -521,6 +530,23 @@ "@babel/helper-plugin-utils": "^7.10.4" } }, + "@babel/plugin-syntax-flow": { + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.12.13.tgz", + "integrity": "sha512-J/RYxnlSLXZLVR7wTRsozxKT8qbsx1mNKJzXEEjQ0Kjx1ZACcyHgbanNWNCFtc36IzuWhYWPpvJFFoexoOWFmA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.12.13" + }, + "dependencies": { + "@babel/helper-plugin-utils": { + "version": "7.13.0", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.13.0.tgz", + "integrity": "sha512-ZPafIPSwzUlAoWT8DKs1W2VyF2gOWthGd5NGFMsBcMMol+ZhK+EQY/e6V96poa6PA/Bh+C9plWN0hXO1uB8AfQ==", + "dev": true + } + } + }, "@babel/plugin-syntax-import-meta": { "version": "7.10.4", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", @@ -539,6 +565,23 @@ "@babel/helper-plugin-utils": "^7.8.0" } }, + "@babel/plugin-syntax-jsx": { + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.12.13.tgz", + "integrity": "sha512-d4HM23Q1K7oq/SLNmG6mRt85l2csmQ0cHRaxRXjKW0YFdEXqlZ5kzFQKH5Uc3rDJECgu+yCRgPkG04Mm98R/1g==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.12.13" + }, + "dependencies": { + "@babel/helper-plugin-utils": { + "version": "7.13.0", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.13.0.tgz", + "integrity": "sha512-ZPafIPSwzUlAoWT8DKs1W2VyF2gOWthGd5NGFMsBcMMol+ZhK+EQY/e6V96poa6PA/Bh+C9plWN0hXO1uB8AfQ==", + "dev": true + } + } + }, "@babel/plugin-syntax-logical-assignment-operators": { "version": "7.10.4", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", @@ -1726,28 +1769,6 @@ "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==", "dev": true }, - "babel-eslint": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.1.0.tgz", - "integrity": "sha512-ifWaTHQ0ce+448CYop8AdrQiBsGrnC+bMgfyKFdi6EsPLTAWG+QfyDeM6OH+FmWnKvEq5NnBMLvlBUPKQZoDSg==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.7.0", - "@babel/traverse": "^7.7.0", - "@babel/types": "^7.7.0", - "eslint-visitor-keys": "^1.0.0", - "resolve": "^1.12.0" - }, - "dependencies": { - "eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true - } - } - }, "babel-jest": { "version": "26.6.3", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-26.6.3.tgz", diff --git a/package.json b/package.json index a6eb183..69bb90f 100644 --- a/package.json +++ b/package.json @@ -14,9 +14,12 @@ "build": "node scripts/build.js" }, "devDependencies": { + "@babel/eslint-parser": "7.13.14", + "@babel/eslint-plugin": "7.13.16", + "@babel/plugin-syntax-flow": "7.12.13", + "@babel/plugin-syntax-jsx": "7.12.13", "@typescript-eslint/eslint-plugin": "4.22.0", "@typescript-eslint/parser": "4.22.0", - "babel-eslint": "10.1.0", "doctoc": "2.0.0", "eslint": "7.25.0", "eslint-config-google": "0.14.0", diff --git a/test-lint/@babel.js b/test-lint/@babel.js new file mode 100644 index 0000000..ff36568 --- /dev/null +++ b/test-lint/@babel.js @@ -0,0 +1,6 @@ +/* eslint-disable quotes, babel/object-curly-spacing */ +"use strict"; + +// Prettier wants spacing between curly braces, but +// `@babel/object-curly-spacing` doesn’t. +module.exports = { foo: "bar" }; diff --git a/test-lint/babel.js b/test-lint/babel.js index 8f53c26..3dd5ec2 100644 --- a/test-lint/babel.js +++ b/test-lint/babel.js @@ -1,4 +1,4 @@ -/* eslint-disable quotes */ +/* eslint-disable quotes, @babel/object-curly-spacing */ "use strict"; // Prettier wants spacing between curly braces, but `babel/object-curly-spacing`