question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Having .eslintrc in the root dir causes eslint tests to fail

See original GitHub issue

What version of ESLint are you using? 2.10.2 What did you do? I cloned the eslint repo and ran tests. What did you expect to happen? No errors. What actually happened? A few errors (about 70 or so).

I think I might be the only one that has such a troubling configuration, because I’ve already created a few PRs to other quite popular repos, which added "root": true to the .eslintrc config file.

The problem is this: I have a “global” .eslintrc file that sits in the root dir. So every project that uses eslint and doesn’t have "root": true set is also using my “global” config. It turns out that eslint itself has this problem, or rather eslint tests 😄

Changing the name of my “global” config file to something random solved the problem (all tests passed).

The simplest way to reproduce this is to create an .eslintrc file in the root dir with this content:

{
  "env": {
    "es6": true
  }
}

For me this caused 13 errors to emerge, for example:

  1) Config findLocalConfigFiles() should return an empty array when an .eslintrc file is not found:
     AssertionError: expected [ 'D:\\.eslintrc' ] to have a length of 0 but got 1

and

  6) Config getConfig() should merge configs when local .eslintrc overrides parent .eslintrc:

      AssertionError: expected { es6: true, node: true } to deeply equal { node: true }
      + expected - actual

       {
      -  "es6": true
         "node": true
       }

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:23 (23 by maintainers)

github_iconTop GitHub Comments

1reaction
gyandeepscommented, May 21, 2016

So far https://github.com/tschaub/mock-fs looks promising as we can fake the directory structure rather than using the real directory structure. Really this would cutout a lot of our real fixtures in the future. We dont need to make physical files.

0reactions
fatfiszcommented, Jun 17, 2016

@gyandeeps Tried it right now and it worked (so Windows is ok with the changes). Great work!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration Files - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
eslint working with the .eslintrc.js and not ... - Stack Overflow
ESLint keeps going up the directory structure and merges each configuration file it finds, until it reaches your root directory.
Read more >
true` in ESLint configuration when setting a working directory
For testing, I've created a project based on the description of 'root: true' in the ESLint docs (see the part that starts with...
Read more >
How to use ESLint with TypeScript | Khalil Stemmler
ESLint is a JavaScript linter that you can use to lint either TypeScript or JavaScript code. In this post, we'll walk through how...
Read more >
Configuring ESLint - ESLint - Pluggable JavaScript linter
Setting parser options helps ESLint determine what is a parsing error. ... projectA which has "root": true set in the .eslintrc file in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found