From 8aefbf2bdc0098f080c20eb0aafeb8ec9522fad3 Mon Sep 17 00:00:00 2001 From: Dave Townsend <dtownsend@oxymoronical.com> Date: Fri, 13 Mar 2020 19:15:11 +0000 Subject: [PATCH] Bug 1617959: Switch to the babel-eslint parser and turn on support for optional chaining and nullish coalescing operator syntaxes. r=Standard8 The babel-eslint parser defaults to assuming all scripts are modules. Although we're moving in that direction it seems reasonable to set the default as regular scripts for now. All the places that were previously overriding the parser are already specifying the sourceType in their eslint configs. I chose to put the babel config in a file that babel itself won't look to avoid the risk of this config impacting the use of babel elsewhere in the tree. Differential Revision: https://phabricator.services.mozilla.com/D66127 --HG-- extra : moz-landing-system : lando --- .babel-eslint.rc.js | 6 +++ .eslintrc.js | 7 +++ browser/components/newtab/.eslintrc.js | 1 - devtools/client/debugger/.eslintrc.js | 1 - package-lock.json | 62 ++++++++++++++++++-------- package.json | 2 + tools/lint/eslint/manifest.tt | 4 +- 7 files changed, 60 insertions(+), 23 deletions(-) create mode 100644 .babel-eslint.rc.js diff --git a/.babel-eslint.rc.js b/.babel-eslint.rc.js new file mode 100644 index 0000000000000..afc7d7c98a4ce --- /dev/null +++ b/.babel-eslint.rc.js @@ -0,0 +1,6 @@ +module.exports = { + plugins: [ + "@babel/plugin-syntax-optional-chaining", + "@babel/plugin-syntax-nullish-coalescing-operator", + ], +}; diff --git a/.eslintrc.js b/.eslintrc.js index b3f451641fee3..8a29e700fe217 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -50,6 +50,13 @@ const ignorePatterns = [ ]; module.exports = { + parser: "babel-eslint", + parserOptions: { + sourceType: "script", + babelOptions: { + configFile: path.join(__dirname, ".babel-eslint.rc.js"), + }, + }, ignorePatterns, // Ignore eslint configurations in parent directories. root: true, diff --git a/browser/components/newtab/.eslintrc.js b/browser/components/newtab/.eslintrc.js index 8dd83fe84371a..7d5055ff707bb 100644 --- a/browser/components/newtab/.eslintrc.js +++ b/browser/components/newtab/.eslintrc.js @@ -1,6 +1,5 @@ module.exports = { // When adding items to this file please check for effects on sub-directories. - parser: "babel-eslint", parserOptions: { ecmaVersion: 2018, ecmaFeatures: { diff --git a/devtools/client/debugger/.eslintrc.js b/devtools/client/debugger/.eslintrc.js index 6fbb800f373cf..98e5389af4217 100644 --- a/devtools/client/debugger/.eslintrc.js +++ b/devtools/client/debugger/.eslintrc.js @@ -3,7 +3,6 @@ * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ module.exports = { - parser: "babel-eslint", plugins: [ "react", "mozilla", diff --git a/package-lock.json b/package-lock.json index 8657b5e81b3ab..a212e854af815 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,9 +13,9 @@ } }, "@babel/generator": { - "version": "7.8.7", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.8.7.tgz", - "integrity": "sha512-DQwjiKJqH4C3qGiyQCAExJHoZssn49JTMJgZ8SANGgVFdkupcUhLOdkAeoC6kmHZCPfoDG5M0b6cFlSN5wW7Ew==", + "version": "7.8.8", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.8.8.tgz", + "integrity": "sha512-HKyUVu69cZoclptr8t8U5b6sx6zoWjh8jiUhnuj3MpZuKT2dJ8zPTuiy31luq32swhI0SpwItCIlU8XW7BZeJg==", "dev": true, "requires": { "@babel/types": "^7.8.7", @@ -44,6 +44,12 @@ "@babel/types": "^7.8.3" } }, + "@babel/helper-plugin-utils": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.8.3.tgz", + "integrity": "sha512-j+fq49Xds2smCUNYmEHF9kGNkhbet6yVIBp4e6oeQpH1RUs/Ir06xUKzDjDkGcaaokPiTNs2JBWHjaE4csUkZQ==", + "dev": true + }, "@babel/helper-split-export-declaration": { "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.8.3.tgz", @@ -65,11 +71,29 @@ } }, "@babel/parser": { - "version": "7.8.7", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.8.7.tgz", - "integrity": "sha512-9JWls8WilDXFGxs0phaXAZgpxTZhSk/yOYH2hTHC0X1yC7Z78IJfvR1vJ+rmJKq3I35td2XzXzN6ZLYlna+r/A==", + "version": "7.8.8", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.8.8.tgz", + "integrity": "sha512-mO5GWzBPsPf6865iIbzNE0AvkKF3NE+2S3eRUpE+FE07BOAkXh6G+GW/Pj01hhXjve1WScbaIO4UlY1JKeqCcA==", "dev": true }, + "@babel/plugin-syntax-nullish-coalescing-operator": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", + "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.8.0" + } + }, + "@babel/plugin-syntax-optional-chaining": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", + "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.8.0" + } + }, "@babel/runtime": { "version": "7.8.7", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.8.7.tgz", @@ -598,9 +622,9 @@ }, "dependencies": { "globals": { - "version": "12.3.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-12.3.0.tgz", - "integrity": "sha512-wAfjdLgFsPZsklLJvOBUBmzYE8/CwhEqSBEMRXA3qxIiNtyqvjYurAtIfDh6chlEPUfmTY3MnZh5Hfh4q0UlIw==", + "version": "12.4.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", + "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", "dev": true, "requires": { "type-fest": "^0.8.1" @@ -880,12 +904,12 @@ "dev": true }, "espree": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.0.tgz", - "integrity": "sha512-Xs8airJ7RQolnDIbLtRutmfvSsAe0xqMMAantCN/GMoqf81TFbeI1T7Jpd56qYu1uuh32dOG5W/X9uO+ghPXzA==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.1.tgz", + "integrity": "sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw==", "dev": true, "requires": { - "acorn": "^7.1.0", + "acorn": "^7.1.1", "acorn-jsx": "^5.2.0", "eslint-visitor-keys": "^1.1.0" } @@ -1159,9 +1183,9 @@ "dev": true }, "inquirer": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.6.tgz", - "integrity": "sha512-7SVO4h+QIdMq6XcqIqrNte3gS5MzCCKZdsq9DO4PJziBFNYzP3PGFbDjgadDb//MCahzgjCxvQ/O2wa7kx9o4w==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.1.0.tgz", + "integrity": "sha512-5fJMWEmikSYu0nv/flMc475MhGbB7TSPd/2IpFV4I4rMklboCH2rQjYY5kKiYGHqUF9gvaambupcJFFG9dvReg==", "dev": true, "requires": { "ansi-escapes": "^4.2.1", @@ -1780,9 +1804,9 @@ } }, "regenerator-runtime": { - "version": "0.13.4", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.4.tgz", - "integrity": "sha512-plpwicqEzfEyTQohIKktWigcLzmNStMGwbOUbykx51/29Z3JOGYldaaNGK7ngNXV+UcoqvIMmloZ48Sr74sd+g==", + "version": "0.13.5", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz", + "integrity": "sha512-ZS5w8CpKFinUzOwW3c83oPeVXoNsrLsaCoLtJvAClH135j/R77RuymhiSErhm2lKcwSCIpmvIWSbDkIfAqKQlA==", "dev": true }, "regexp.prototype.flags": { diff --git a/package.json b/package.json index 59d304b64cc39..d5409926e1b14 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,8 @@ "license": "MPL-2.0", "dependencies": {}, "devDependencies": { + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", + "@babel/plugin-syntax-optional-chaining": "^7.8.3", "babel-eslint": "10.1.0", "eslint": "6.8.0", "eslint-config-prettier": "6.10.0", diff --git a/tools/lint/eslint/manifest.tt b/tools/lint/eslint/manifest.tt index 1d4b3e03ec5f0..d1c51dd855790 100644 --- a/tools/lint/eslint/manifest.tt +++ b/tools/lint/eslint/manifest.tt @@ -4,7 +4,7 @@ "visibility": "public", "filename": "eslint.tar.gz", "unpack": true, - "digest": "9426eacaf88ad4b81a5c02f3424a00e0dd424ccb46710acedc1e100bbe710a24b4ad407fe0d5b6540371cc860725cfb191094fcbd7a39a8a47a353d35eaec4d3", - "size": 9817597 + "digest": "7e5f5db70f8b7ab6ec389392257ea10480c5b7e3c1721d44d4451ac16427f94b90723c79914eb31715611c5b85683c700344091c457e2f38bbb5a21012627f91", + "size": 9905333 } ] \ No newline at end of file -- GitLab