Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

linter-eslint can't find package.json in lerna repo, but the CLI can #1304

Open
@kaiyoma

Description

@kaiyoma

Issue Type

Question

Issue Description

I have a lerna repo configured in a pretty standard way:

my-project
├── .eslintrc.json
├── package.json
└─┬ packages
  ├─┬ package1
  | ├── .eslintrc.json
  | └── package.json
  └─┬ package2
    ├── .eslintrc.json
    └── package.json

When I enter into a package directory and run yarn run lint, everything is great. If I run lerna run lint from the root of the repo, everything is also great (because under the hood, lerna will cd into each package directory). However, if I open any source file in Atom, I get this error:

The package.json file could not be found. (import/no-extraneous-dependencies)

For each of my packages, I have the following defined in the local .eslintrc.json file:

    "import/no-extraneous-dependencies": ["error", {
      "packageDir": [".", "../.."]
    }],

This tells eslint to look at the local package.json (the one in the package directory) and the one in the root of the repo, since we define our dependencies in both places. The fact that Atom is reporting this error suggests to me that the context (current working directory) is wrong somehow. For a lerna repo, the current working directory should be the package directory, not the root of the repo. Is there a way for linter-eslint to do the right thing here and use the package directory as the current working directory?

Bug Checklist

  • Restart Atom
  • Verify the eslint CLI gives the proper result, while linter-eslint does not
  • Paste the output of the Linter Eslint: Debug command from the Command Palette below
Atom version: 1.40.1
linter-eslint version: 8.5.5
ESLint version: 6.3.0
Hours since last Atom restart: 4.7
Platform: win32
Using local project ESLint from: <redacted>\node_modules\eslint
Current file's scopes: [
  "source.js",
  "support.variable"
]
linter-eslint configuration: {
  "disabling": {
    "disableWhenNoEslintConfig": true,
    "rulesToSilenceWhileTyping": []
  },
  "scopes": [
    "source.ts",
    "source.tsx",
    "source.js",
    "source.jsx",
    "source.flow",
    "source.babel",
    "source.js-semantic"
  ],
  "lintHtmlFiles": false,
  "autofix": {
    "fixOnSave": false,
    "ignoreFixableRulesWhileTyping": false,
    "rulesToDisableWhileFixing": []
  },
  "global": {
    "useGlobalEslint": false,
    "eslintrcPath": "",
    "globalNodePath": ""
  },
  "advanced": {
    "disableEslintIgnore": false,
    "disableFSCache": false,
    "showRuleIdInMessage": true,
    "eslintRulesDirs": [],
    "localNodeModules": ""
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions