Skip to content

Commit

Permalink
Bug 1622717: When parsing an AST allow the chosen parser to override …
Browse files Browse the repository at this point in the history
…the default scope manager and visitor keys. r=Standard8

There appears to be a bug in babel-eslint where it still uses the old
`ExperimentalSpreadProperty` and `ExperimentalRestProperty` node types when
babel itself (and hence the AST visitor keys) have switched to `SpreadElement`
and `RestElement`. I suspect there isn't much point in filing a babel-eslint
issue for this, they are currently in the process of working on v11 which does
fix the issue but is currently only available as a beta release.

There are three alternatives:

1. Use the beta babel-eslint.
2. Hack the visitor keys to include the old node types.
3. Traverse the AST changing the nodes from the old types to the new types.

Using a beta version is probably not a great idea so this patch does 2 which is
the simplest of the other options. It does have the drawback however that if
any eslint rules we use rely on the new node type names they will fail to work.

Differential Revision: https://phabricator.services.mozilla.com/D66998
  • Loading branch information
Mossop committed Mar 23, 2020
1 parent 1875266 commit 0174c49
Show file tree
Hide file tree
Showing 10 changed files with 566 additions and 192 deletions.
207 changes: 141 additions & 66 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"license": "MPL-2.0",
"dependencies": {},
"devDependencies": {
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3",
"@babel/plugin-syntax-optional-chaining": "^7.8.3",
"@babel/core": "7.8.3",
"@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",
Expand Down
7 changes: 7 additions & 0 deletions tools/lint/eslint/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@
"use strict";

module.exports = {
// eslint-plugin-mozilla runs under node, so we need a more restrictive
// environment / parser setup here than the rest of mozilla-central.
env: {
browser: false,
node: true,
},
parser: "espree",
parserOptions: {
ecmaVersion: 10,
},

rules: {
camelcase: ["error", { properties: "never" }],
Expand Down
Loading

0 comments on commit 0174c49

Please sign in to comment.