Skip to content

[comma-spacing] Cannot read properties of undefined (reading 'type') #4867

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

Closed
3 tasks done
comrem opened this issue Apr 26, 2022 · 0 comments · Fixed by #4868
Closed
3 tasks done

[comma-spacing] Cannot read properties of undefined (reading 'type') #4867

comrem opened this issue Apr 26, 2022 · 0 comments · Fixed by #4868
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@comrem
Copy link
Contributor

comrem commented Apr 26, 2022

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "parser": "@typescript-eslint/parser",
  "plugins": [
    "@typescript-eslint",
  ],
  "extends": [
    "plugin:@typescript-eslint/recommended",
    "plugin:@typescript-eslint/eslint-recommended",
  ],
  "rules": {
    "comma-spacing": "off",
    "@typescript-eslint/comma-spacing": [ "error" ],
  }
}
let a,

Expected Result

Expect no error on "@typescript-eslint/comma-spacing" rule.

Actual Result

There is an error in lint execution, caused by this line.

Additional Info

Just creating this ticket to be referenced in my PR.

The issue is specially bothering when using an editor extension linting your code while you edit it. When writing code it'll trigger errors in lint execution.

[Info  - 11:28:54] ESLint server is starting
[Info  - 11:28:55] ESLint server running in node v16.13.0
[Info  - 11:28:55] ESLint server is running.
[Info  - 11:28:55] ESLint library loaded from: /my-project-dir/node_modules/eslint/lib/api.js
[Error - 11:29:01] ESLint stack trace:
[Error - 11:29:01] TypeError: Cannot read properties of undefined (reading 'type')
Occurred while linting /my-project-dir/src/test.ts:1
Rule: "@typescript-eslint/comma-spacing"
    at isPunctuatorTokenWithValue (/my-project-dir/node_modules/eslint-utils/index.js:90:18)
    at isCommaToken (/my-project-dir/node_modules/eslint-utils/index.js:108:12)
    at /my-project-dir/node_modules/@typescript-eslint/eslint-plugin/dist/rules/comma-spacing.js:135:62
    at Array.forEach (<anonymous>)
    at Program:exit (/my-project-dir/node_modules/@typescript-eslint/eslint-plugin/dist/rules/comma-spacing.js:127:35)
    at ruleErrorHandler (/my-project-dir/node_modules/eslint/lib/linter/linter.js:1107:28)
    at /my-project-dir/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/my-project-dir/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/my-project-dir/node_modules/eslint/lib/linter/node-event-generator.js:297:26)

Versions

package version
@typescript-eslint/eslint-plugin 5.20.0
@typescript-eslint/parser 5.20.0
TypeScript 4.5.5
ESLint 8.14.0
node 16.13.0
@comrem comrem added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Apr 26, 2022
@JoshuaKGoldberg JoshuaKGoldberg added bug Something isn't working good first issue Good for newcomers accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for team members to take a look labels Apr 27, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants