-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Closed
Closed
Copy link
Labels
acceptedThere is consensus among the team that this change meets the criteria for inclusionThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionThis issue has been archived; please open a new issue for any further discussionbugESLint is working incorrectlyESLint is working incorrectlycoreRelates to ESLint's core APIs and featuresRelates to ESLint's core APIs and featuresrepro:yesIssues with a reproducible exampleIssues with a reproducible example
Description
Environment
Node version: v18.10.0
npm version: v8.19.2
Local ESLint version: v8.25.0 (Currently used)
Global ESLint version: Not found
Operating System: darwin 21.6.0
What parser are you using?
Default (Espree)
What did you do?
I was running some unit tests for a custom formatter against the new flat config API, and I noticed that getRulesMetaForResults
is now throwing a TypeError
for results that contain messages without a ruleId
.
I found this to be the case for parser errors, for messages about unused eslint-disable
directives and for warnings about ignored files. There could be other cases, too - my tests are not exhaustive.
Example 1: Parser error
const { default: { FlatESLint } } = await import('eslint/use-at-your-own-risk');
const eslint = new FlatESLint({ overrideConfigFile: true });
const results = await eslint.lintText('syntax error');
eslint.getRulesMetaForResults(results); // throws TypeError
Example 2: Unused eslint-disable
directive
const { default: { FlatESLint } } = await import('eslint/use-at-your-own-risk');
const eslint = new FlatESLint({ overrideConfigFile: true, reportUnusedDisableDirectives: 'warn' });
const results = await eslint.lintText('// eslint-disable-line');
eslint.getRulesMetaForResults(results); // throws TypeError
Example 3: Ignored file
const { default: { FlatESLint } } = await import('eslint/use-at-your-own-risk');
const eslint = new FlatESLint({ overrideConfigFile: true });
const results = await eslint.lintText('', { filePath: '/.ignored.js', warnIgnored: true });
eslint.getRulesMetaForResults(results); // throws TypeError
What did you expect to happen?
getRulesMetaForResults
should run without errors.
What actually happened?
A TypeError
was thrown (the same for all examples):
.../node_modules/eslint/lib/config/flat-config-helpers.js:22 if (ruleId.includes("/")) { ^ TypeError: Cannot read properties of null (reading 'includes') at parseRuleId (...node_modules/eslint/lib/config/flat-config-helpers.js:22:16) at getRuleFromConfig (.../node_modules/eslint/lib/config/flat-config-helpers.js:52:38) at FlatESLint.getRulesMetaForResults (.../node_modules/eslint/lib/eslint/flat-eslint.js:703:30) at file://.../example.mjs:5:8
Participation
- I am willing to submit a pull request for this issue.
Additional comments
No response
Metadata
Metadata
Assignees
Labels
acceptedThere is consensus among the team that this change meets the criteria for inclusionThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionThis issue has been archived; please open a new issue for any further discussionbugESLint is working incorrectlyESLint is working incorrectlycoreRelates to ESLint's core APIs and featuresRelates to ESLint's core APIs and featuresrepro:yesIssues with a reproducible exampleIssues with a reproducible example
Type
Projects
Status
Complete