Bug: config files
and ignores
elements are not being validated #17434
Closed
Description
opened on Jul 30, 2023
Environment
Node version: v20.5.0
npm version: v9.8.0
Local ESLint version: v8.46.0 (Currently used)
Global ESLint version: Not found
Operating System: darwin 22.5.0
What parser are you using?
Default (Espree)
What did you do?
I run eslint .
with a config that contains an invalid element in the files
array, e.g.:
Configuration
export default [
{
files: [
"**/*.js",
undefined
]
}
];
What did you expect to happen?
There should be an error message indicating that files
contains an invalid value.
What actually happened?
A generic error message:
Oops! Something went wrong! :( ESLint: 8.46.0 TypeError: Unexpected matcher type undefined.
For comparison, here is the error message printed by an eslintrc config with overrides: [{ files: ["**/*.js", undefined] }]
:
Oops! Something went wrong! :( ESLint: 8.46.0 Error: ESLint configuration in .eslintrc.js is invalid: - Property "overrides[0].files" is the wrong type (expected string but got `["**/*.js",null]`). - Property "overrides[0].files[1]" is the wrong type (expected string but got `undefined`). - "overrides[0].files" should match exactly one schema in oneOf. Value: ["**/*.js",null].
Link to Minimal Reproducible Example
https://stackblitz.com/edit/stackblitz-starters-vmehy7?file=eslint.config.js&view=editor
Participation
- I am willing to submit a pull request for this issue.
Additional comments
A similar problem occurs when an ignores
pattern is invalid. For example, when running eslint .
with this config:
export default [
{
files: ["**/*.js"],
ignores: [1],
}
];
The error message looks like this:
Oops! Something went wrong! :( ESLint: 8.46.0 TypeError: matcher.startsWith is not a function
Metadata
Assignees
Labels
Type
Projects
Status
Complete
Activity