Skip to content

Bug: "Error: Could not find config file." #18287

@branislavbrincko

Description

@branislavbrincko

Environment

Environment Info:

Node version: v18.18.2
npm version: v9.8.1
Local ESLint version: v9.0.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 initialized node.js project with:

npm init -y 

I added index.js file with the following content:

const a = '5'

I initialized eslint via npm init @eslint/config which generated the following .eslintrc.json (I added "no-unused-vars" rule):

{
    "env": {
        "browser": true,
        "commonjs": true,
        "es2021": true
    },
    "overrides": [],
    "parserOptions": {
        "ecmaVersion": "latest"
    },
    "rules": {
        "no-unused-vars": "warn"
    }
}

Then I tried to run npx eslint index.js which resulted in the following error:

Oops! Something went wrong! :(

ESLint: 9.0.0

Error: Could not find config file.
    at locateConfigFileToUse (/Users/branislav/Documents/code/t/eslint-test/node_modules/eslint/lib/eslint/eslint.js:349:21)
    at async calculateConfigArray (/Users/branislav/Documents/code/t/eslint-test/node_modules/eslint/lib/eslint/eslint.js:384:49)
    at async ESLint.lintFiles (/Users/branislav/Documents/code/t/eslint-test/node_modules/eslint/lib/eslint/eslint.js:814:25)
    at async Object.execute (/Users/branislav/Documents/code/t/eslint-test/node_modules/eslint/lib/cli.js:461:23)
    at async main (/Users/branislav/Documents/code/t/eslint-test/node_modules/eslint/bin/eslint.js:165:22)

Downgrading the eslint to 8.57.0 fixes the issue - running the npx eslint index.js gives:

  1:7  warning  'a' is assigned a value but never used  no-unused-vars

✖ 1 problem (0 errors, 1 warning)

What did you expect to happen?

Running eslint should not error out.

What actually happened?

Running eslint returned the following error:

Oops! Something went wrong! :(

ESLint: 9.0.0

Error: Could not find config file.
    at locateConfigFileToUse (/Users/branislav/Documents/code/t/eslint-test/node_modules/eslint/lib/eslint/eslint.js:349:21)
    at async calculateConfigArray (/Users/branislav/Documents/code/t/eslint-test/node_modules/eslint/lib/eslint/eslint.js:384:49)
    at async ESLint.lintFiles (/Users/branislav/Documents/code/t/eslint-test/node_modules/eslint/lib/eslint/eslint.js:814:25)
    at async Object.execute (/Users/branislav/Documents/code/t/eslint-test/node_modules/eslint/lib/cli.js:461:23)
    at async main (/Users/branislav/Documents/code/t/eslint-test/node_modules/eslint/bin/eslint.js:165:22)

Link to Minimal Reproducible Example

https://github.com/branislavbrincko/eslint-test

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    archived due to ageThis issue has been archived; please open a new issue for any further discussionworks as intendedThe behavior described in this issue is working correctly

    Type

    No type

    Projects

    Status

    Complete

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions