'Node must be provided when reporting error if location is not provided. Error with no-unused-vars when running ESLint 7.11.0

I'm getting an error when trying to run ESLint on one of the repos I'm working on. I've boiled the issue down to that, for some reason, ESLint throws errors on a few specific files because they contain enums. I believe other files in the repo contain enums as well, but for some reason only these ones crash the linter. When I comment the enums out, lint runs perfectly fine. I've looked into the issue a bit, but I'm not exactly sure what the solution is. The .eslintrc file has no-unused-vars and @typescript-eslint/no-unused-vars, which I've read is an issue, but I've messed around with enabling and disabling each of them individually to no avail. Setting either of them to active will create the same error, and the only way for the linter to run is to disable both.

Here is the error that gets thrown when running lint:

AssertionError [ERR_ASSERTION]: Node must be provided when reporting error if location is not provided
    at assertValidNodeInfo (/home/simon/code/janus-api/node_modules/eslint/lib/linter/report-translator.js:98:9)
    at /home/simon/code/janus-api/node_modules/eslint/lib/linter/report-translator.js:311:9
    at Object.report (/home/simon/code/janus-api/node_modules/eslint/lib/linter/linter.js:920:41)
    at Program:exit (/home/simon/code/janus-api/node_modules/eslint/lib/rules/no-unused-vars.js:622:33)
    at /home/simon/code/janus-api/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/home/simon/code/janus-api/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/home/simon/code/janus-api/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/home/simon/code/janus-api/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.leaveNode (/home/simon/code/janus-api/node_modules/eslint/lib/linter/node-event-generator.js:306:14)

and when running with --debug I get this error:

eslint:linter Line: 1 +0ms
  eslint:linter Parser Options: {
  ecmaFeatures: { globalReturn: false },
  ecmaVersion: 11,
  sourceType: 'module',
  project: './tsconfig.json'
} +0ms
  eslint:linter Parser Path: /home/simon/code/janus-api/node_modules/@typescript-eslint/parser/dist/index.js +0ms
  eslint:linter Settings: {} +0ms

Thanks!



Solution 1:[1]

doing the following solved the issue for me.

// .eslintrc
"rules": {
    ...
    "no-unused-vars": "off",
    "@typescript-eslint/no-unused-vars": [
        "error",
        { "argsIgnorePattern": "^_" }
    ]
    ...
}

Solution 2:[2]

.eslintrc.json

  "extends": [
   -> "eslint:recommended", <-
    "plugin:@angular-eslint/recommended",
    "plugin:@angular-eslint/ng-cli-compat",
    "plugin:@angular-eslint/ng-cli-compat--formatting-add-on",
    "plugin:@angular-eslint/template/process-inline-templates",
    "plugin:prettier/recommended"
  ],

My guess is that you are importing something that pulls in no-unused-vars and @typescript-eslint/no-unused-vars. But without your eslintrc, it could be something else. If you have a chance, please add this to your question.

For example, removing eslint:recommended fixed it for me.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Umair Jibran
Solution 2 TamusJRoyce