eslint crash when upgrading to 1.4.1
bloody-ux opened this issue · 13 comments
When we upgrade esquery to 1.4.1, eslint will crash, below is the log:
eslint ./src --ext .jsx,.js,.ts,.tsx
Oops! Something went wrong! :(
ESLint: 7.32.0
TypeError: Cannot read properties of undefined (reading 'type')
Occurred while linting /Users/bhtbed/workspace/特价版/merge-radish/src/app.ts:1
at /Users/bhtbed/workspace/特价版/merge-radish/node_modules/_esquery@1.4.1@esquery/dist/esquery.min.js:1:29531
at /Users/bhtbed/workspace/特价版/merge-radish/node_modules/_esquery@1.4.1@esquery/dist/esquery.min.js:1:30574
at Function.b.matches (/Users/bhtbed/workspace/特价版/merge-radish/node_modules/_esquery@1.4.1@esquery/dist/esquery.min.js:1:34910)
at NodeEventGenerator.applySelector (/Users/bhtbed/workspace/特价版/merge-radish/node_modules/_eslint@7.32.0@eslint/lib/linter/node-event-generator.js:292:21)
at NodeEventGenerator.applySelectors (/Users/bhtbed/workspace/特价版/merge-radish/node_modules/_eslint@7.32.0@eslint/lib/linter/node-event-generator.js:320:22)
at NodeEventGenerator.enterNode (/Users/bhtbed/workspace/特价版/merge-radish/node_modules/_eslint@7.32.0@eslint/lib/linter/node-event-generator.js:336:14)
at CodePathAnalyzer.enterNode (/Users/bhtbed/workspace/特价版/merge-radish/node_modules/_eslint@7.32.0@eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
at /Users/bhtbed/workspace/特价版/merge-radish/node_modules/_eslint@7.32.0@eslint/lib/linter/linter.js:960:32
at Array.forEach ()
same problem
- output
> file-box@1.7.0 lint:es
> eslint --ignore-pattern fixtures/ "src/**/*.ts" "tests/**/*.ts"
Oops! Something went wrong! :(
ESLint: 8.34.0
TypeError: Cannot read properties of undefined (reading 'type')
Occurred while linting /Users/binsee/code/file-box/src/config.ts:1
at /Users/binsee/code/file-box/node_modules/esquery/dist/esquery.min.js:1:29496
at /Users/binsee/code/file-box/node_modules/esquery/dist/esquery.min.js:1:30539
at Function.b.matches (/Users/binsee/code/file-box/node_modules/esquery/dist/esquery.min.js:1:34875)
at NodeEventGenerator.applySelector (/Users/binsee/code/file-box/node_modules/eslint/lib/linter/node-event-generator.js:296:21)
at NodeEventGenerator.applySelectors (/Users/binsee/code/file-box/node_modules/eslint/lib/linter/node-event-generator.js:324:22)
at NodeEventGenerator.enterNode (/Users/binsee/code/file-box/node_modules/eslint/lib/linter/node-event-generator.js:340:14)
at CodePathAnalyzer.enterNode (/Users/binsee/code/file-box/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:795:23)
at /Users/binsee/code/file-box/node_modules/eslint/lib/linter/linter.js:1153:32
at Array.forEach (<anonymous>)
at runRules (/Users/binsee/code/file-box/node_modules/eslint/lib/linter/linter.js:1148:15)
- package-lock.json
"node_modules/esquery": {
"version": "1.4.1",
"resolved": "https://registry.npmmirror.com/esquery/-/esquery-1.4.1.tgz",
"integrity": "sha512-3ZggxvMv5EEY1ssUVyHSVt0oPreyBfbUi1XikJVfjFiBeBDLdrb0IWoDiEwqT/2sUQi0TGaWtFhOGDD8RTpXgQ==",
"dev": true,
"dependencies": {
"estraverse": "^5.1.0"
},
"engines": {
"node": ">=0.10"
}
},
We are facing this too
Got it affecting a number of modules, including the @typescript-eslint/require-await
rule from https://github.com/typescript-eslint/typescript-eslint, as seen in typescript-eslint/typescript-eslint#6477
For anyone looking for a quick/temporary fix, run npm install --save-dev --save-exact esquery@1.4.0
to force the working 1.4.0 version to install. An npm upgrade
will break it again, so just re-run it to re-download 1.4.0 until a fixed 1.4.2 is released.
same problem with my eslint config
A mocha test case for the repo which should pass, but fails in the latest version
it("child not", function () {
const program = {
type: "Program",
body: [
{
type: "VariableDeclaration",
declarations: [
{
type: "VariableDeclarator",
id: { type: "Identifier", name: "x" },
init: { type: "Literal", value: 1, raw: "1" },
},
],
kind: "var",
},
],
};
const matches = esquery(program, "VariableDeclarator[init] > *");
assert.includeMembers(matches, [
program.body[0].declarations[0].id,
program.body[0].declarations[0].init,
]);
});
Running this test against the v1.4.0
tag passes.
Bisecting I think this was introduced in 44e1ff5 (this PR - #134) cc @jviide
@michaelficarra Yes, can confirm this issue, and that @binsee's PR #136 is a good fix for it.
Same issue here.
As workaround, on the top app level I install the older version:
npm install --save-dev esquery@1.4.0
Same issue here. As workaround, on the top app level I install the older version:
npm install --save-dev esquery@1.4.0
You can also add to your package.json
:
"overrides": {
"esquery": "1.4.0"
},
In yarn, you can use resolutions in your package.json file
"resolutions": {
"eslint/esquery": "1.4.0"
},
afterwards, run yarn
. I think this is a better workaround than adding a fixed esquery version as a dependency of your project.
This should be fixed by 1.4.2
. Please confirm.
@michaelficarra Upgrading to 1.4.2
solved the issue for me.
This should be fixed by
1.4.2
. Please confirm.
It works for me