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

Do not consider configs in ~/ for Disable when no Eslint Config is found setting #773

Closed
miljan-aleksic opened this issue Dec 25, 2016 · 12 comments

Comments

@miljan-aleksic
Copy link

Issue Type

Bug on version 8.0.0

Issue Description

In my project I have no package.json nor a .eslintrc and when saving an .js file an error prompt about Error: Failed to load plugin html: Cannot find module 'eslint-plugin-html rise.

I just want to use nasty js code for this project, why this plugin cares so much!? :)

Let me know if you need any additional information.

@IanVS
Copy link
Member

IanVS commented Dec 25, 2016 via email

@miljan-aleksic
Copy link
Author

No, I don't. This is my project.

screen shot 2016-12-25 at 22 02 58

screen shot 2016-12-25 at 22 15 55

@IanVS
Copy link
Member

IanVS commented Dec 25, 2016

If I wasn't clear, I meant your user home, as in ~.

Can you provide the output of the Linter Eslint: Debug command when you have your file open?

@miljan-aleksic
Copy link
Author

Ah sorry, yes, seems there is one I didn't know it even exist. That's quite confusing, in the Settings there is an option that states Disable when no Eslint Config is found (in package.json or .eslintrc). A package is always local, thus one would assume is referencing the local .eslintrc. Fallback to the global configuration seems a very bad decision, IMHO, it should allow disabling that and at very last state it more clearly in the settings.

It becomes even more confusing when checking that the useGlobalEslint setting is disabled.

atom version: 1.12.7
linter-eslint version: 8.0.0
eslint version: 3.7.1
hours since last atom restart: 0.1
platform: darwin
Using bundled fallback eslint from /Users/miljan/.atom/packages/linter-eslint/node_modules/eslint
linter-eslint configuration: {
  "disableWhenNoEslintrcFileInPath": true,
  "lintHtmlFiles": true,
  "useGlobalEslint": false,
  "showRuleIdInMessage": true,
  "disableWhenNoEslintConfig": true,
  "eslintrcPath": "",
  "globalNodePath": "",
  "advancedLocalNodeModules": "",
  "eslintRulesDir": "",
  "disableEslintIgnore": false,
  "disableFSCache": false,
  "fixOnSave": false,
  "scopes": [
    "source.js",
    "source.jsx",
    "source.js.jsx",
    "source.babel",
    "source.js-semantic"
  ],
  "rulesToSilenceWhileTyping": []
}

@nickjanssen
Copy link

Same here, linter-eslint is definitely running even though there is no .eslintrc nor mention of it in package.json. What is going on? I'm just trying to browse source code of a project I just downloaded and atom is going crazy with eslint errors.

$ ls -a
.            .DS_Store    .exponent    components   main.js      package.json
..           .babelrc     assets       exp.json     node_modules

The error

Error: Failed to load plugin flow-vars: Cannot find module 'eslint-plugin-flow-vars'

Debug info

atom version: 1.12.7
linter-eslint version: 8.0.0
eslint version: 3.10.0
hours since last atom restart: 0.4
platform: darwin
Using bundled fallback eslint from /Users/nickjanssen/.atom/packages/linter-eslint/node_modules/eslint
linter-eslint configuration: {
  "lintHtmlFiles": false,
  "useGlobalEslint": false,
  "showRuleIdInMessage": true,
  "disableWhenNoEslintConfig": true,
  "eslintrcPath": "",
  "globalNodePath": "",
  "advancedLocalNodeModules": "",
  "eslintRulesDir": "",
  "disableEslintIgnore": false,
  "disableFSCache": false,
  "fixOnSave": false,
  "scopes": [
    "source.js",
    "source.jsx",
    "source.js.jsx",
    "source.babel",
    "source.js-semantic"
  ],
  "rulesToSilenceWhileTyping": []
}

@IanVS
Copy link
Member

IanVS commented Jan 4, 2017

@nickjanssen, can you check for a config file in you user home directory?

@nickjanssen
Copy link

@IanVS there is no .eslintrc file in my home directory. Even if there was one, it should be ignored as I'm not using eslint globally, right?

@nickjanssen
Copy link

Ah, it turns out that the error was being thrown because of an .eslintrc file in the parent directory of the project I was in.

The repo in question: https://github.com/exponent/ex-navigation
I was opening the example/ folder in atom, and apparently it tries to read the root .eslintrc file. Note that I did not open the root folder but the actual example project, like this:
image
So I don't understand why it tries to load the one in the parent directory.

@IanVS
Copy link
Member

IanVS commented Jan 5, 2017

Even if there was one, it should be ignored as I'm not using eslint globally, right?

No, the eslint executable used has no bearing on how it calculates configuration for a file. The standard behavior of eslint, no matter how it is installed (locally or globally), is to combine any config files found between the file being linted and the root of the filestystem, falling back to looking in ~ if no other config files can be found. You can read more about how this works at http://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy

I don't understand why it tries to load the one in the parent directory.

It is because of the configuration cascade as described in the link above. This is standard behavior of ESLint, and is not changed by linter-eslint. It is working as expected in your case.

@IanVS
Copy link
Member

IanVS commented Jan 5, 2017

it should allow disabling that [fallback to config in ~] and at very last state it more clearly in the settings.

Are you proposing that when the option Disable when no Eslint Config is found is checked, that we do not fall back to the config in ~ (which is standard ESLint behavior)? I could see an argument for doing that, since having a config in the home directory basically makes that option pointless. If a user has a config file in ~ (which will apply to all files without any other config), it wouldn't make sense to also try to avoid linting files without any other config.

Anyways, I think I'm 👍 for not allowing ~/.eslintrc to prevent disabling linting when that option is checked. What do you think, @Arcanemagus?

@IanVS IanVS changed the title Disable when no config set setting ignored Do not consider configs in ~/ for Disable when no Eslint Config is found setting Jan 5, 2017
@IanVS
Copy link
Member

IanVS commented Jan 5, 2017

Some more details:

Assuming Disable when no ESLint config is found is checked,

  • Currently, linter-eslint will not try to lint a file which is outside of a user's ~, even if there is an eslint config file at a user's ~.
  • But, linter-eslint will try to lint a file within a subfolder of ~ if there's a config file at ~.

For example:

touch ~/.eslintrc

/somewhere/else/example.js // <- won't be linted

~/code/example.js // <- will be linted

As ~/.eslintrc is supposed to be a last-resort fallback to only be used if no other configs are found, I believe the will lint case above is a bug in linter-eslint, and is what I'm proposing to fix.

@Arcanemagus
Copy link
Member

Okay, from reading the above, and from this comment over in ESLint I'm going to go with a ~/.eslintrc file not satisfying the "config file has been found" condition. If people want that to take effect they can simply disable that check and then it will either only check for syntax errors (no config at all), or use this default config in their home directory.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants