Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] no-webpack-loader-syntax/TypeScript: avoid crash on missing name #1947

Merged

Conversation

leonardodino
Copy link
Contributor

Tiny fix 馃槃

Every time I was manually adding a import on a typescript in vscode file it would trigger this rule, because the parser interprets the code as valid, passing an incomplete AST node down.

The test case seems a bit weird, but it's what naturally happens when typing on the top part of a file, and having eslint constantly running 馃槃

Logs from a usual session:

[Error] ESLint stack trace:
[Error] TypeError: Cannot read property 'indexOf' of undefined
Occurred while linting /redacted/file.tsx:1
    at reportIfNonStandard (/redacted/node_modules/eslint-plugin-import/lib/rules/no-webpack-loader-syntax.js:5:12)
    at handleImports (/redacted/node_modules/eslint-plugin-import/lib/rules/no-webpack-loader-syntax.js:24:9)
    at /redacted/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/redacted/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/redacted/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/redacted/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/redacted/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/redacted/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /redacted/node_modules/eslint/lib/linter/linter.js:952:32

@coveralls
Copy link

Coverage Status

Coverage decreased (-2.1%) to 95.774% when pulling 6797bff on leonardodino:avoid-crash-no-webpack-loader-syntax into 957092a on benmosher:master.

@coveralls
Copy link

coveralls commented Nov 16, 2020

Coverage Status

Coverage remained the same at 97.904% when pulling dd4e416 on leonardodino:avoid-crash-no-webpack-loader-syntax into 957092a on benmosher:master.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks great! (assuming the test fails without the fix)

@ljharb ljharb force-pushed the avoid-crash-no-webpack-loader-syntax branch from 6797bff to dd4e416 Compare November 17, 2020 10:41
@ljharb ljharb merged commit dd4e416 into import-js:master Nov 17, 2020
@JounQin
Copy link
Collaborator

JounQin commented May 12, 2021

@ljharb It seems this fix has not been released yet?

https://unpkg.com/browse/eslint-plugin-import@2.22.1/lib/rules/no-webpack-loader-syntax.js

Can you help to release it??

@ljharb
Copy link
Member

ljharb commented May 12, 2021

That's correct, it hasn't been. Until yesterday, we've been blocked by #1986.

After I move through all the open PRs, I'll cut a release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants