Repository: ember-cli/ember-cli
Pull request #7443 (2017-11-15 00:03:14)

Use `overrides` for a single `.eslintrc.js`.
Update the `.eslintrc.js` used by apps and addons, to avoid needing separate "sprinkles" of eslint configuration throughout the projects codebase.

Compatible with `eslint@4.1.0`.

Additional reading:

* https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns
* https://github.com/eslint/eslint/pull/8081

rwjblue: I will follow up and make sure that `ember-cli-eslint`'s blueprint is in sync once we settle on this...
kellyselden: I would like to hold off merging until our meeting. I'm not 100% in favor of this. I like getting rid of the first line sprinkles of node files, but I'm not convinced that removing our tests/.eslintrc.js is a good idea. Everybody's documentation and blueprint injection touch that file (globals and test helpers), and it seems to me that it is in it's correct place.
rwjblue: > I would like to hold off merging until our meeting.

Seems good, happy to discuss...

> I like getting rid of the first line sprinkles of node files, but I'm not convinced that removing our tests/.eslintrc.js is a good idea. 

This is where we disagree. The current system of having many `.eslintrc` files all over makes it very difficult to understand what the current ruleset is at any given point (a number of times I've resorted to using `eslint --print-config some/file/path.js` just to figure out what the heck is running). Another issue is that (other than simple things like `env`) its not possible by adding a `.eslintrc` file to handle directories that contain _mixed_ rulesets .

> Everybody's documentation and blueprint injection touch that file (globals and test helpers), and it seems to me that it is in it's correct place.

I think this is actually a separate concern from the others. We should choose the right set of defaults, and recommend them while also providing time and assistance to addons that may need to make modifications. Modifying a single file (`.eslintrc.js`) in general, is easier than having to modify many potential locations...
kellyselden: We decided in the core meeting that this is the way forward. With module unification, test files will be strewn about a project, so wildcard paths inside a single eslint config is the future (TM).
rwjblue: Rebased and addressed all outstanding comments...

Patch:
diff --git a/blueprints/addon/files/addon-config/ember-try.js b/blueprints/addon/files/addon-config/ember-try.js
index 463e7067d..1ab8ae562 100644
--- a/blueprints/addon/files/addon-config/ember-try.js
+++ b/blueprints/addon/files/addon-config/ember-try.js
@@ -1,4 +1,3 @@
-/* eslint-env node */
 module.exports = {
   <% if (yarn) { %>useYarn: true,
   <% } %>scenarios: [
diff --git a/blueprints/addon/files/addon-config/environment.js b/blueprints/addon/files/addon-config/environment.js
index 012a412f6..0dfaed472 100644
--- a/blueprints/addon/files/addon-config/environment.js
+++ b/blueprints/addon/files/addon-config/environment.js
@@ -1,4 +1,3 @@
-/* eslint-env node */
 'use strict';
 
 module.exports = function(/* environment, appConfig */) {
diff --git a/blueprints/addon/files/ember-cli-build.js b/blueprints/addon/files/ember-cli-build.js
index 156e23fa5..dc5a39e1b 100644
--- a/blueprints/addon/files/ember-cli-build.js
+++ b/blueprints/addon/files/ember-cli-build.js
@@ -1,4 +1,3 @@
-/* eslint-env node */
 'use strict';
 
 const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
diff --git a/blueprints/addon/files/index.js b/blueprints/addon/files/index.js
index 465c682f7..8eaaa2f0c 100644
--- a/blueprints/addon/files/index.js
+++ b/blueprints/addon/files/index.js
@@ -1,4 +1,3 @@
-/* eslint-env node */
 'use strict';
 
 module.exports = {
diff --git a/blueprints/app/files/.eslintrc.js b/blueprints/app/files/.eslintrc.js
index 2873e2fcb..450138401 100644
--- a/blueprints/app/files/.eslintrc.js
+++ b/blueprints/app/files/.eslintrc.js
@@ -9,5 +9,34 @@ module.exports = {
     browser: true
   },
   rules: {
-  }
+  },
+  overrides: [
+    // node files
+    {
+      files: [
+        'index.js',
+        'testem.js',
+        'ember-cli-build.js',
+        'config/**/*.js',
+        'tests/dummy/config/**/*.js'
+      ],
+      parserOptions: {
+        sourceType: 'script',
+        ecmaVersion: 2015
+      },
+      env: {
+        browser: false,
+        node: true
+      }
+    },
+
+    // test files
+    {
+      files: ['tests/**/*.js'],
+      excludedFiles: ['tests/dummy/**/*.js'],
+      env: {
+        embertest: true
+      }
+    }
+  ]
 };
diff --git a/blueprints/app/files/config/environment.js b/blueprints/app/files/config/environment.js
index f0c2f71ae..1e14621c9 100644
--- a/blueprints/app/files/config/environment.js
+++ b/blueprints/app/files/config/environment.js
@@ -1,4 +1,3 @@
-/* eslint-env node */
 'use strict';
 
 module.exports = function(environment) {
diff --git a/blueprints/app/files/config/targets.js b/blueprints/app/files/config/targets.js
index df7664c25..082e68b51 100644
--- a/blueprints/app/files/config/targets.js
+++ b/blueprints/app/files/config/targets.js
@@ -1,4 +1,3 @@
-/* eslint-env node */
 module.exports = {
   browsers: [
     'ie 9',
diff --git a/blueprints/app/files/ember-cli-build.js b/blueprints/app/files/ember-cli-build.js
index 9a757ff37..d690a2531 100644
--- a/blueprints/app/files/ember-cli-build.js
+++ b/blueprints/app/files/ember-cli-build.js
@@ -1,4 +1,3 @@
-/* eslint-env node */
 'use strict';
 
 const EmberApp = require('ember-cli/lib/broccoli/ember-app');


Test patch:
diff --git a/blueprints/app/files/testem.js b/blueprints/app/files/testem.js
index 1ffd96bf1..10ecc1045 100644
--- a/blueprints/app/files/testem.js
+++ b/blueprints/app/files/testem.js
@@ -1,4 +1,3 @@
-/* eslint-env node */
 module.exports = {
   test_page: 'tests/index.html?hidepassed',
   disable_watching: true,
diff --git a/blueprints/app/files/tests/.eslintrc.js b/blueprints/app/files/tests/.eslintrc.js
deleted file mode 100644
index fbf255520..000000000
--- a/blueprints/app/files/tests/.eslintrc.js
+++ /dev/null
@@ -1,5 +0,0 @@
-module.exports = {
-  env: {
-    embertest: true
-  }
-};
diff --git a/tests/fixtures/addon/npm/config/ember-try.js b/tests/fixtures/addon/npm/config/ember-try.js
index 3eea72b9a..1c31c5491 100644
--- a/tests/fixtures/addon/npm/config/ember-try.js
+++ b/tests/fixtures/addon/npm/config/ember-try.js
@@ -1,4 +1,3 @@
-/* eslint-env node */
 module.exports = {
   scenarios: [
     {
diff --git a/tests/fixtures/addon/yarn/config/ember-try.js b/tests/fixtures/addon/yarn/config/ember-try.js
index 4adbac942..1a4a5bbd3 100644
--- a/tests/fixtures/addon/yarn/config/ember-try.js
+++ b/tests/fixtures/addon/yarn/config/ember-try.js
@@ -1,4 +1,3 @@
-/* eslint-env node */
 module.exports = {
   useYarn: true,
   scenarios: [