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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unicorn/prefer-top-level-await crash in autofixer #1945

Closed
bmish opened this issue Nov 3, 2022 · 1 comment · Fixed by #1950
Closed

unicorn/prefer-top-level-await crash in autofixer #1945

bmish opened this issue Nov 3, 2022 · 1 comment · Fixed by #1950
Assignees
Labels

Comments

@bmish
Copy link
Sponsor Contributor

bmish commented Nov 3, 2022

Crash output:

ESLint: 8.26.0

TypeError: Cannot read properties of null (reading 'type')
Occurred while linting foo.js:3
Rule: "unicorn/prefer-top-level-await"
    at CallExpression:not(:function *)[callee.type="Identifier"] (node_modules/eslint-plugin-unicorn/rules/prefer-top-level-await.js:98:13)
    at node_modules/eslint-plugin-unicorn/rules/utils/rule.js:39:18

Rule: unicorn/prefer-top-level-await

eslint-plugin-unicorn v44.0.2

Code sample that triggered crash:

for (const statement of statements) {
  good.push(
    `${statement('@book')}`,
  );
}
@bmish bmish added the bug label Nov 3, 2022
@fisker
Copy link
Collaborator

fisker commented Nov 3, 2022

Can't believe forgot that init of Variable[kind="const"] can be null.

const value = definition.type === 'Variable' && definition.kind === 'const'

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

Successfully merging a pull request may close this issue.

2 participants