Skip to content

Cannot run eslint in a subdirectory of a project #255

Closed
@jfx2006

Description

@jfx2006

Short version: If you run eslint from a subdirectory of a project, when the no-unsanitized plugin loads, it fails because of the readFileSync("./package.json") line in index.js.

This caused a problem for Thunderbird which always runs mach eslint in the comm/ subdirectory so it uses the right eslint configuration.

STR:

  • In a mozilla-central clone, run ../mach eslint base/content/*.js from the browser/ directory.

Fails with:
Error: Failed to load plugin 'no-unsanitized' declared in '../.eslintrc.js » plugin:mozilla/recommended': ENOENT: no such file or directory, open './package.json'

I was able to minimally reproduce with a small js project with eslint and no-unsantized as well.

I suspect the intent was to read the package.json from this package to fill in the plugin metadata version?

Bug 1921150 filed with workaround fix for Thunderbird. Workaround is to create an empty package.json prior to running eslint and then remove it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions