Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.eslintrc is ignored when cwd is the home directory #3846

Closed
lo1tuma opened this issue Sep 18, 2015 · 5 comments
Closed

.eslintrc is ignored when cwd is the home directory #3846

lo1tuma opened this issue Sep 18, 2015 · 5 comments
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features

Comments

@lo1tuma
Copy link
Member

lo1tuma commented Sep 18, 2015

Given the following directory structure:

/app
├── lib
│   ├── foo.js
│   ├── .eslintrc
├── .eslintrc

where /app is the home directory of the current user AND the current working directory of the eslint process.

When I run DEBUG=eslint:* eslint /app/lib/foo.js, I get the following output:

  eslint:cli Running on files +0ms
  eslint:cli-engine Processing /app/lib/foo.js +29ms
  eslint:cli-engine Linting /app/lib/foo.js +2ms
  eslint:config Constructing config for /app/lib/foo.js +0ms
  eslint:config Using .eslintrc and package.json files +1ms
  eslint:config Loading /app/lib/.eslintrc +1ms
  eslint:config Using /app/lib/.eslintrc +91ms
  eslint:config Loading /app/package.json +0ms
  eslint:config Merging command line environment settings +7ms
  eslint:cli-engine Load plugin react +18ms
  eslint:cli-engine Linting complete in: 126ms +2ms

As you can see, /app/lib/.eslintrc is used but not /app/.eslintrc. This is because .eslintrc files in the home directory are always ignored when retrieving the local config for a given file. The documentation says that this should only happen in the absence of ANY configuration.


When I remove /app/lib/.eslintrc then I get the following output:

DEBUG=eslint:* ./node_modules/.bin/eslint /app/lib/foo.js
  eslint:cli Running on files +0ms
  eslint:cli-engine Processing /app/lib/foo.js +35ms
  eslint:cli-engine Linting /app/lib/foo.js +2ms
  eslint:config Constructing config for /app/lib/foo.js +1ms
  eslint:config Using .eslintrc and package.json files +0ms
  eslint:config Loading /app/package.json +1ms
  eslint:config Using personal config +10ms
  eslint:config Merging command line environment settings +97ms
  eslint:cli-engine Load plugin react +18ms
  eslint:cli-engine Linting complete in: 136ms +2ms

Now the personal config was used because no other .eslintrc was found, which is not correct because there is a config file in the current working directory.


My current workaround is to rename the /app/.eslintrc file to /app/eslint-config and load it explicitly via the -c CLI flag:

$ eslint -c eslint-config /app/lib/foo.js
@lo1tuma lo1tuma added bug ESLint is working incorrectly core Relates to ESLint's core APIs and features labels Sep 18, 2015
@gyandeeps
Copy link
Member

Questions:

  • What version of eslint are you using?
  • Do you have root: true in any .eslintrc file?

@lo1tuma
Copy link
Member Author

lo1tuma commented Sep 18, 2015

ESLint version: 1.4.3
root is not set at all for my examples above, but I’ve tried it and it doesn’t have any impact.

@lo1tuma
Copy link
Member Author

lo1tuma commented Sep 18, 2015

FWIW: the workaround mentioned above doesn’t work if you have multiple .eslintrc files. Putting the content of the /app/.eslintrc file into the package.json works.

@nzakas
Copy link
Member

nzakas commented Sep 18, 2015

Sounds like we need an exception if the cwd is the home directory?

@nzakas nzakas added the accepted There is consensus among the team that this change meets the criteria for inclusion label Sep 18, 2015
@lo1tuma
Copy link
Member Author

lo1tuma commented Sep 18, 2015

Yes, I think an exception is needed to fix this.

nzakas added a commit that referenced this issue Sep 20, 2015
Fix: don’t ignore config if cwd is the home dir (fixes #3846)
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 7, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features
Projects
None yet
Development

No branches or pull requests

3 participants