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

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

Closed
fatfisz opened this issue May 17, 2016 · 23 comments
Closed

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

fatfisz opened this issue May 17, 2016 · 23 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 chore This change is not user-facing infrastructure Relates to the tools used in the ESLint development process

Comments

@fatfisz
Copy link
Contributor

fatfisz commented May 17, 2016

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
       }
@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label May 17, 2016
@nzakas nzakas added infrastructure Relates to the tools used in the ESLint development process accepted There is consensus among the team that this change meets the criteria for inclusion chore This change is not user-facing and removed triage An ESLint team member will look at this issue soon labels May 18, 2016
@nzakas
Copy link
Member

nzakas commented May 18, 2016

Can you share all the errors you're seeing?

@fatfisz
Copy link
Contributor Author

fatfisz commented May 18, 2016

Right - I will paste the short 13-error version then:

  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
      at Function.assert.lengthOf (D:\Projects\eslint\node_modules\chai\lib\chai\interface\assert.js:1086:37)
      at Context.<anonymous> (D:\Projects\eslint\tests\lib\config.js:150:20)
      at callFn (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:315:21)
      at Test.Runnable.run (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:308:7)
      at Runner.runTest (D:\Projects\eslint\node_modules\mocha\lib\runner.js:422:10)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:533:12
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:342:14)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:352:7
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:284:14)
      at Immediate._onImmediate (D:\Projects\eslint\node_modules\mocha\lib\runner.js:320:5)

  2) Config findLocalConfigFiles() should return package.json only when no other config files are found:
     AssertionError: expected [ Array(3) ] to have a length of 2 but got 3
      at Function.assert.lengthOf (D:\Projects\eslint\node_modules\chai\lib\chai\interface\assert.js:1086:37)
      at Context.<anonymous> (D:\Projects\eslint\tests\lib\config.js:160:20)
      at callFn (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:315:21)
      at Test.Runnable.run (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:308:7)
      at Runner.runTest (D:\Projects\eslint\node_modules\mocha\lib\runner.js:422:10)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:533:12
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:342:14)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:352:7
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:284:14)
      at Immediate._onImmediate (D:\Projects\eslint\node_modules\mocha\lib\runner.js:320:5)

  3) Config findLocalConfigFiles() should return the only one config file even if there are multiple found:
     AssertionError: expected 2 to equal 1
      at Context.<anonymous> (D:\Projects\eslint\tests\lib\config.js:172:20)
      at callFn (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:315:21)
      at Test.Runnable.run (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:308:7)
      at Runner.runTest (D:\Projects\eslint\node_modules\mocha\lib\runner.js:422:10)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:533:12
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:342:14)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:352:7
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:284:14)
      at Immediate._onImmediate (D:\Projects\eslint\node_modules\mocha\lib\runner.js:320:5)

  4) Config findLocalConfigFiles() should return all possible files when multiple are found:

      AssertionError: expected [ Array(4) ] to deeply equal [ Array(3) ]
      + expected - actual

       [
         "D:\\Temp\\eslint\\fixtures\\config-hierarchy\\fileexts\\subdir\\subsubdir\\.eslintrc.json"
         "D:\\Temp\\eslint\\fixtures\\config-hierarchy\\fileexts\\subdir\\.eslintrc.yml"
         "D:\\Temp\\eslint\\fixtures\\config-hierarchy\\fileexts\\.eslintrc.js"
      -  "D:\\.eslintrc"
       ]

      at Function.assert.deepEqual (D:\Projects\eslint\node_modules\chai\lib\chai\interface\assert.js:216:32)
      at Context.<anonymous> (D:\Projects\eslint\tests\lib\config.js:186:20)
      at callFn (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:315:21)
      at Test.Runnable.run (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:308:7)
      at Runner.runTest (D:\Projects\eslint\node_modules\mocha\lib\runner.js:422:10)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:533:12
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:342:14)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:352:7
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:284:14)
      at Immediate._onImmediate (D:\Projects\eslint\node_modules\mocha\lib\runner.js:320:5)

  5) Config findLocalConfigFiles() should return an empty array when a package.json file is not found:
     AssertionError: expected [ 'D:\\.eslintrc' ] to have a length of 0 but got 1
      at Function.assert.lengthOf (D:\Projects\eslint\node_modules\chai\lib\chai\interface\assert.js:1086:37)
      at Context.<anonymous> (D:\Projects\eslint\tests\lib\config.js:194:20)
      at callFn (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:315:21)
      at Test.Runnable.run (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:308:7)
      at Runner.runTest (D:\Projects\eslint\node_modules\mocha\lib\runner.js:422:10)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:533:12
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:342:14)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:352:7
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:284:14)
      at Immediate._onImmediate (D:\Projects\eslint\node_modules\mocha\lib\runner.js:320:5)

  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
       }

      at Function.assert.deepEqual (D:\Projects\eslint\node_modules\chai\lib\chai\interface\assert.js:216:32)
      at assertConfigsEqual (D:\Projects\eslint\tests\lib\config.js:61:16)
      at Context.<anonymous> (D:\Projects\eslint\tests\lib\config.js:445:13)
      at callFn (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:315:21)
      at Test.Runnable.run (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:308:7)
      at Runner.runTest (D:\Projects\eslint\node_modules\mocha\lib\runner.js:422:10)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:533:12
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:342:14)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:352:7
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:284:14)
      at Immediate._onImmediate (D:\Projects\eslint\node_modules\mocha\lib\runner.js:320:5)

  7) Config getConfig() should merge configs when local .eslintrc overrides parent and grandparent .eslintrc:

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

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

      at Function.assert.deepEqual (D:\Projects\eslint\node_modules\chai\lib\chai\interface\assert.js:216:32)
      at assertConfigsEqual (D:\Projects\eslint\tests\lib\config.js:61:16)
      at Context.<anonymous> (D:\Projects\eslint\tests\lib\config.js:466:13)
      at callFn (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:315:21)
      at Test.Runnable.run (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:308:7)
      at Runner.runTest (D:\Projects\eslint\node_modules\mocha\lib\runner.js:422:10)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:533:12
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:342:14)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:352:7
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:284:14)
      at Immediate._onImmediate (D:\Projects\eslint\node_modules\mocha\lib\runner.js:320:5)

  8) Config getConfig() should merge command line config when config file adds to local .eslintrc:

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

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

      at Function.assert.deepEqual (D:\Projects\eslint\node_modules\chai\lib\chai\interface\assert.js:216:32)
      at assertConfigsEqual (D:\Projects\eslint\tests\lib\config.js:61:16)
      at Context.<anonymous> (D:\Projects\eslint\tests\lib\config.js:504:13)
      at callFn (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:315:21)
      at Test.Runnable.run (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:308:7)
      at Runner.runTest (D:\Projects\eslint\node_modules\mocha\lib\runner.js:422:10)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:533:12
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:342:14)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:352:7
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:284:14)
      at Immediate._onImmediate (D:\Projects\eslint\node_modules\mocha\lib\runner.js:320:5)

  9) Config getConfig() should merge command line config when config file overrides local .eslintrc:

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

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

      at Function.assert.deepEqual (D:\Projects\eslint\node_modules\chai\lib\chai\interface\assert.js:216:32)
      at assertConfigsEqual (D:\Projects\eslint\tests\lib\config.js:61:16)
      at Context.<anonymous> (D:\Projects\eslint\tests\lib\config.js:527:13)
      at callFn (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:315:21)
      at Test.Runnable.run (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:308:7)
      at Runner.runTest (D:\Projects\eslint\node_modules\mocha\lib\runner.js:422:10)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:533:12
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:342:14)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:352:7
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:284:14)
      at Immediate._onImmediate (D:\Projects\eslint\node_modules\mocha\lib\runner.js:320:5)

  10) Config getConfig() should merge command line config when config file adds to local and parent .eslintrc:

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

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

      at Function.assert.deepEqual (D:\Projects\eslint\node_modules\chai\lib\chai\interface\assert.js:216:32)
      at assertConfigsEqual (D:\Projects\eslint\tests\lib\config.js:61:16)
      at Context.<anonymous> (D:\Projects\eslint\tests\lib\config.js:552:13)
      at callFn (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:315:21)
      at Test.Runnable.run (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:308:7)
      at Runner.runTest (D:\Projects\eslint\node_modules\mocha\lib\runner.js:422:10)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:533:12
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:342:14)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:352:7
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:284:14)
      at Immediate._onImmediate (D:\Projects\eslint\node_modules\mocha\lib\runner.js:320:5)

  11) Config getConfig() should merge command line config when config file overrides local and parent .eslintrc:

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

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

      at Function.assert.deepEqual (D:\Projects\eslint\node_modules\chai\lib\chai\interface\assert.js:216:32)
      at assertConfigsEqual (D:\Projects\eslint\tests\lib\config.js:61:16)
      at Context.<anonymous> (D:\Projects\eslint\tests\lib\config.js:576:13)
      at callFn (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:315:21)
      at Test.Runnable.run (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:308:7)
      at Runner.runTest (D:\Projects\eslint\node_modules\mocha\lib\runner.js:422:10)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:533:12
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:342:14)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:352:7
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:284:14)
      at Immediate._onImmediate (D:\Projects\eslint\node_modules\mocha\lib\runner.js:320:5)

  12) Config getConfig() should merge command line config and rule when rule and config file overrides local .eslintrc:

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

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

      at Function.assert.deepEqual (D:\Projects\eslint\node_modules\chai\lib\chai\interface\assert.js:216:32)
      at assertConfigsEqual (D:\Projects\eslint\tests\lib\config.js:61:16)
      at Context.<anonymous> (D:\Projects\eslint\tests\lib\config.js:602:13)
      at callFn (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:315:21)
      at Test.Runnable.run (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:308:7)
      at Runner.runTest (D:\Projects\eslint\node_modules\mocha\lib\runner.js:422:10)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:533:12
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:342:14)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:352:7
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:284:14)
      at Immediate._onImmediate (D:\Projects\eslint\node_modules\mocha\lib\runner.js:320:5)

  13) Config getConfig() with env in a child configuration file should overwrite parserOptions of the parent with env of the child:

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

       {
         "commonjs": true
      -  "es6": true
       }

      at Function.assert.deepEqual (D:\Projects\eslint\node_modules\chai\lib\chai\interface\assert.js:216:32)
      at assertConfigsEqual (D:\Projects\eslint\tests\lib\config.js:61:16)
      at Context.<anonymous> (D:\Projects\eslint\tests\lib\config.js:732:17)
      at callFn (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:315:21)
      at Test.Runnable.run (D:\Projects\eslint\node_modules\mocha\lib\runnable.js:308:7)
      at Runner.runTest (D:\Projects\eslint\node_modules\mocha\lib\runner.js:422:10)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:533:12
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:342:14)
      at D:\Projects\eslint\node_modules\mocha\lib\runner.js:352:7
      at next (D:\Projects\eslint\node_modules\mocha\lib\runner.js:284:14)
      at Immediate._onImmediate (D:\Projects\eslint\node_modules\mocha\lib\runner.js:320:5)

@fatfisz
Copy link
Contributor Author

fatfisz commented May 18, 2016

As you can see, the errors can be grouped into these categories:

  • expected the array containing .eslintrc files to have one element less
  • expected the array containing .eslintrc files to match an array without the root config file (D:\.eslintrc)
  • expected parserOptions not to contain the "es6": true setting (which is a setting that comes from the root config file)

@fatfisz
Copy link
Contributor Author

fatfisz commented May 18, 2016

@nzakas I can also post the 70-error version if it will help.

@btmills
Copy link
Member

btmills commented May 19, 2016

While we should still add root: true to our config, I'm curious about your use case for this. Do you intentionally want to modify project configs that don't specify root: true, or are you really just looking to provide your own personal default for projects that don't specify a config at all? If all you're going for is a fallback config, you can move your .eslintrc to your user home directory. If ESLint doesn't find any other configs as it traverses up to the root directory, it will grab a default .eslintrc from the user's home directory. That would unbreak your workflow for projects that haven't yet added root: true, though at the cost of a quick PR to a new project every so often 😏

@fatfisz
Copy link
Contributor Author

fatfisz commented May 19, 2016

@btmills Oooh, I didn't know about that. Yes, I was using this as a fallback config for my new projects, thanks for the advice.

@ilyavolodin
Copy link
Member

I still think the original issue is correct and we should add root: true to our config. I know I've ran into an issue when I created .eslintrc file for testing in the folder above eslint, and then all of my unit tests started failing within ESLint. Took me a little while to figure out what's going on.

@gyandeeps
Copy link
Member

gyandeeps commented May 19, 2016

Our project .eslintrc has root: true in it. I think the test are failing because some of the test gets copied into the temp folder for execution and thats when it goes and hits the home directory .eslintrc file. I think i have this right, but correct me if i am wrong.

@fatfisz
Copy link
Contributor Author

fatfisz commented May 19, 2016

@gyandeeps Yes, I think I saw some error reports coming from files contained in D:\Temp, which is my default temporary directory.

Edit:
Though I don't know if all of the errors are coming from those files.

@gyandeeps
Copy link
Member

When I tried on my machine (Windows 7), i got 11 errors but only 5 had error output 😕

  10707 passing (46s)
  11 failing

  1) Config findLocalConfigFiles() should return an empty array when an .eslintrc file is not found:
     AssertionError: expected [ 'C:\\Users\\gs025879\\.eslintrc' ] to have a length of 0 but got 1
      at Function.assert.lengthOf (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\chai\lib\chai\interface\assert.js:1086:37)
      at Context.<anonymous> (C:\Users\gs025879\Documents\webstrom\eslint\tests\lib\config.js:150:20)
      at callFn (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runnable.js:315:21)
      at Test.Runnable.run (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runnable.js:308:7)
      at Runner.runTest (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:422:10)
      at C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:533:12
      at next (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:342:14)
      at C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:352:7
      at next (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:284:14)
      at Immediate._onImmediate (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:320:5)

  2) Config findLocalConfigFiles() should return package.json only when no other config files are found:
     AssertionError: expected [ Array(3) ] to have a length of 2 but got 3
      at Function.assert.lengthOf (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\chai\lib\chai\interface\assert.js:1086:37)
      at Context.<anonymous> (C:\Users\gs025879\Documents\webstrom\eslint\tests\lib\config.js:160:20)
      at callFn (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runnable.js:315:21)
      at Test.Runnable.run (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runnable.js:308:7)
      at Runner.runTest (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:422:10)
      at C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:533:12
      at next (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:342:14)
      at C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:352:7
      at next (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:284:14)
      at Immediate._onImmediate (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:320:5)

  3) Config findLocalConfigFiles() should return the only one config file even if there are multiple found:
     AssertionError: expected 2 to equal 1
      at Context.<anonymous> (C:\Users\gs025879\Documents\webstrom\eslint\tests\lib\config.js:172:20)
      at callFn (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runnable.js:315:21)
      at Test.Runnable.run (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runnable.js:308:7)
      at Runner.runTest (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:422:10)
      at C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:533:12
      at next (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:342:14)
      at C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:352:7
      at next (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:284:14)
      at Immediate._onImmediate (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:320:5)

  4) Config findLocalConfigFiles() should return all possible files when multiple are found:

      AssertionError: expected [ Array(4) ] to deeply equal [ Array(3) ]
      + expected - actual

       [
         "C:\\Users\\gs025879\\AppData\\Local\\Temp\\eslint\\fixtures\\config-hierarchy\\fileexts\\subdir\\subsubdir\\.eslintrc.json"
         "C:\\Users\\gs025879\\AppData\\Local\\Temp\\eslint\\fixtures\\config-hierarchy\\fileexts\\subdir\\.eslintrc.yml"
         "C:\\Users\\gs025879\\AppData\\Local\\Temp\\eslint\\fixtures\\config-hierarchy\\fileexts\\.eslintrc.js"
      -  "C:\\Users\\gs025879\\.eslintrc"
       ]

      at Function.assert.deepEqual (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\chai\lib\chai\interface\assert.js:216:32)
      at Context.<anonymous> (C:\Users\gs025879\Documents\webstrom\eslint\tests\lib\config.js:186:20)
      at callFn (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runnable.js:315:21)
      at Test.Runnable.run (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runnable.js:308:7)
      at Runner.runTest (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:422:10)
      at C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:533:12
      at next (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:342:14)
      at C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:352:7
      at next (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:284:14)
      at Immediate._onImmediate (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:320:5)

  5) Config findLocalConfigFiles() should return an empty array when a package.json file is not found:
     AssertionError: expected [ 'C:\\Users\\gs025879\\.eslintrc' ] to have a length of 0 but got 1
      at Function.assert.lengthOf (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\chai\lib\chai\interface\assert.js:1086:37)
      at Context.<anonymous> (C:\Users\gs025879\Documents\webstrom\eslint\tests\lib\config.js:194:20)
      at callFn (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runnable.js:315:21)
      at Test.Runnable.run (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runnable.js:308:7)
      at Runner.runTest (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:422:10)
      at C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:533:12
      at next (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:342:14)
      at C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:352:7
      at next (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:284:14)
      at Immediate._onImmediate (C:\Users\gs025879\Documents\webstrom\eslint\node_modules\mocha\lib\runner.js:320:5)

Used the same steps as @fatfisz mentioned above.

@nzakas
Copy link
Member

nzakas commented May 19, 2016

Since the errors are limited to the Config file, we can probably just go through all the fixtures for Config and add root:true.

@gyandeeps
Copy link
Member

gyandeeps commented May 19, 2016

I dont think just adding root: true would completely solve the problem. Function under testing is findLocalConfigFiles whose job is to discover all the files with a particular file name from a directory to all the way up to home/base directory. Since its just discovering the files up the chain and not looking inside the content of file, we need to figure out a different solution.

@nzakas
Copy link
Member

nzakas commented May 20, 2016

Ah, good point.

@gyandeeps
Copy link
Member

gyandeeps commented May 20, 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.

@kaicataldo
Copy link
Member

mock-fs is great!

@nzakas
Copy link
Member

nzakas commented May 21, 2016

If someone wants to give it a try, go for it!

I had a lot of trouble with mock-fs when I tried to use it in some tests previously, but it's entirely possible I didn't know what I was doing. :)

@gyandeeps
Copy link
Member

Here I have a sample work done for findLocalConfigFiles tests inside config.
1b7b823

With this change now the unit test are not failing using the same scenario as described in this issue.
I think like this we can fake all our fixtures in the future. 😄
@eslint/eslint-team thoughts?

@nzakas
Copy link
Member

nzakas commented May 24, 2016

Very cool! Is there a way to split up that giant blob of data? Maybe each test can register just what it needs?

@gyandeeps
Copy link
Member

gyandeeps commented May 24, 2016

Yes, ideally i want to create a json file for each kind of fixture and keep the file their. So the one I have is the exact json version of our fixtures/config-hierarchy (physical version). So basically reacd the json file and load it through mock-fs.
Since its going to be a massive overtaking to convert all the files, i would propose to move to mock-fs from here on. Also as we touch different parts then we can slowly convert them.

Here is the dirty script which reads the physical version of the file structure and creates json version out of it: https://gist.github.com/gyandeeps/23a4c836b54f91d9d3cfed7ab37e7a0b

@nzakas
Copy link
Member

nzakas commented May 24, 2016

I think we can probably start with just updating these few failing tests so we can unblock potential contributors. Agree that we should use mock-fs going forward.

@gyandeeps
Copy link
Member

@fatfisz If you have time plz, can try changes from #6402 on your machine to see if all the test pass. I created the same scenario on my machine as you described and it worked for me now. Just want to double check with you Thanks

@nzakas nzakas closed this as completed in 77697a7 Jun 15, 2016
@fatfisz
Copy link
Contributor Author

fatfisz commented Jun 16, 2016

@gyandeeps Sure, I will probably do it over the weekend :)

@fatfisz
Copy link
Contributor Author

fatfisz commented Jun 17, 2016

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

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 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 6, 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 chore This change is not user-facing infrastructure Relates to the tools used in the ESLint development process
Projects
None yet
Development

No branches or pull requests

7 participants