Skip to content

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

@comrem

Description

@comrem
  • 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

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy