Skip to content

Bug: config files and ignores elements are not being validated #17434

Closed
@fasttime

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

acceptedThere 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 discussionbugESLint is working incorrectlyrepro:yesIssues with a reproducible example

Type

No type

Projects

  • Status

    Complete

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions