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.

Change for relative path algorithm #1338

Open
@brettz9

Description

@brettz9

Issue Type

Issue Description

I have some ESLint in my HOME, with its own .eslintignore, node_modules (including eslint copy), etc.

In one project, I did not have an .eslintignore. This caused getRelativePath of src/worker-helpers.js to look up in a higher directory (here, HOME) and finding an ignore file there, set that as the cwd (e.g., for eslint).

The ignore files are not what eslint itself looks at for determining hierarchy, though I understand per a note in source that you use the position of the ignore file (rather than using a config file which may be present at different paths within the project hierarchy) as the project root:

// If we can find an .eslintignore file, we can set cwd there
// (because they are expected to be at the project root)

However, perhaps the result of findCached could be checked to make sure it is not at a higher directory than the project path.

The following change seems to have fixed it:

Changing the following line from getRelativePath:

if (ignoreFile) {

...to:

if (ignoreFile &&
  // The ignore file could be higher than the Atom projectPath if the Atom project has no ignore but the containing folder (e.g., HOME) does:
  (!projectPath || Path.dirname(projectPath).includes(ignoreFile))) {

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

(I got the following message, as my HOME eslint plugin copy was outdated, but I wasn't expecting it to use the HOME config since I didn't specify that as my config)

Linter Eslint: Definition for rule 'unicorn/better-regex' was not found. (unicorn/better-regex)

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