Skip to content

Bug: @typescript-eslint/keyword-spacing crashes #6060

Closed
@andreashuber69

Description

@andreashuber69

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Issue Description

When running eslint on the repo as is, everything works as expected. However, when upgrading to v5.44 first, the lint crashes with the message below. See Repro Steps for more info.

Oops! Something went wrong! :(

ESLint: 8.28.0

TypeError: Cannot read properties of undefined (reading 'after')
Occurred while linting /home/a/git/async-css-plugin/src/AsyncCssPlugin.ts:2
Rule: "@typescript-eslint/keyword-spacing"
    at ImportDeclaration[importKind=type] (/home/a/git/async-css-plugin/node_modules/@typescript-eslint/eslint-plugin/dist/rules/keyword-spacing.js:65:40)
    at ruleErrorHandler (/home/a/git/async-css-plugin/node_modules/eslint/lib/linter/linter.js:1115:28)
    at /home/a/git/async-css-plugin/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/home/a/git/async-css-plugin/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/home/a/git/async-css-plugin/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (/home/a/git/async-css-plugin/node_modules/eslint/lib/linter/node-event-generator.js:326:22)
    at NodeEventGenerator.enterNode (/home/a/git/async-css-plugin/node_modules/eslint/lib/linter/node-event-generator.js:340:14)
    at CodePathAnalyzer.enterNode (/home/a/git/async-css-plugin/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:795:23)
    at /home/a/git/async-css-plugin/node_modules/eslint/lib/linter/linter.js:1150:32

Reproduction Repository Link

https://github.com/andreashuber69/async-css-plugin

Repro Steps

git clone https://github.com/andreashuber69/async-css-plugin
cd async-css-plugin
npm install
npx eslint src --ext .js,.ts

The lint should complete without error. If you then continue with:

npm install @typescript-eslint/eslint-plugin @typescript-eslint/parser
npx eslint src --ext .js,.ts

(the above installs v5.44 of both packages, v5.43 was installed before)
The lint crashes, see output above.

Versions

package version
@typescript-eslint/eslint-plugin 5.44.0
@typescript-eslint/parser 5.44.0
TypeScript 4.9.3
ESLint 8.28.0
node 18.12.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinggood first issueGood for newcomerspackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions