-
-
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 discussioncoreRelates to ESLint's core APIs and featuresRelates to ESLint's core APIs and featuresenhancementThis change enhances an existing feature of ESLintThis change enhances an existing feature of ESLint
Description
ESLint version
next
What problem do you want to solve?
Currently flat config does not have any special handling for undefined being passed in causing an "accessed property on undefined" error:
Oops! Something went wrong! :(
ESLint: 8.56.0
TypeError: Cannot read properties of undefined (reading 'ignores')
at FlatConfigArray.get ignores [as ignores] ([redacted]/node_modules/@humanwhocodes/config-array/api.js:648:15)
at FlatConfigArray.isDirectoryIgnored ([redacted]/node_modules/@humanwhocodes/config-array/api.js:1012:10)
at FlatConfigArray.getConfig ([redacted]/node_modules/@humanwhocodes/config-array/api.js:806:12)
at FlatConfigArray.isFileIgnored ([redacted]/node_modules/@humanwhocodes/config-array/api.js:962:15)
at [redacted]/node_modules/eslint/lib/eslint/eslint-helpers.js:312:49
at Array.reduce (<anonymous>)
at entryFilter ([redacted]/node_modules/eslint/lib/eslint/eslint-helpers.js:299:28)
at Object.isAppliedFilter ([redacted]/node_modules/@nodelib/fs.walk/out/readers/common.js:12:31)
at AsyncReader._handleEntry ([redacted]/node_modules/@nodelib/fs.walk/out/readers/async.js:86:20)
at [redacted]/node_modules/@nodelib/fs.walk/out/readers/async.js:65:22
This is confusing because undefined is commonly expected if you try to use a config that doesn't exist but the error message looks more like a potential bug in ESLint:
const jestPlugin = require('eslint-plugin-jest');
module.exports = [
{
// enable jest rules on test files
files: ['test/**'],
...jestPlugin.configs['flat/recommended'],
},
// explodes, as we're removing this in our next major!
jestPlugin.configs['flat/snapshots'],
];This is a real-world example of where I hit this as I was testing for eslint-plugin-jest's upcoming major in which we're removing the flat/snapshots config.
What do you think is the correct solution?
I'd like ESLint to explicitly check for undefined and raise an error along the lines of "you've passed undefined as a config - this usually happens when you're trying to reference a config that doesn't exist"
Participation
- I am willing to submit a pull request for this change.
Additional comments
Born from #18094 & #18094 (comment)
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 discussioncoreRelates to ESLint's core APIs and featuresRelates to ESLint's core APIs and featuresenhancementThis change enhances an existing feature of ESLintThis change enhances an existing feature of ESLint
Type
Projects
Status
Complete