Repository: ember-cli/ember-cli
Pull request #8205 (2018-11-22 12:21:31)

run eslint-plugin-node on apps
I'm finding that it is pretty useful to run eslint-plugin-node on apps, even though the code is unpublished. You get the nice rules that prevent running newer node code and relying on transient deps. Especially if your code is ember-cli-deploy code that doesn't always run with your test suite.

rwjblue: BTW, it seems like this should target beta not release...

Patch:
diff --git a/blueprints/addon/index.js b/blueprints/addon/index.js
index 25eae64be..0ee08b4b7 100644
--- a/blueprints/addon/index.js
+++ b/blueprints/addon/index.js
@@ -69,9 +69,6 @@ module.exports = {
     // add `ember-disable-prototype-extensions` to addons by default
     contents.devDependencies['ember-disable-prototype-extensions'] = '^1.1.3';
 
-    // add `eslint-plugin-node` to addons by default
-    contents.devDependencies['eslint-plugin-node'] = '^8.0.1';
-
     // add ember-try
     contents.devDependencies['ember-try'] = '^1.0.0';
 
diff --git a/blueprints/app/files/.eslintrc.js b/blueprints/app/files/.eslintrc.js
index 944682f66..202996743 100644
--- a/blueprints/app/files/.eslintrc.js
+++ b/blueprints/app/files/.eslintrc.js
@@ -44,11 +44,15 @@ module.exports = {
       env: {
         browser: false,
         node: true
-      }<% if (blueprint !== 'app') { %>,
+      },
       plugins: ['node'],
       rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
-        // add your custom rules and overrides for node files here
-      })<% } %>
+        // add your custom rules and overrides for node files here<% if (blueprint === 'app') { %>
+
+        // this can be removed once the following is fixed
+        // https://github.com/mysticatea/eslint-plugin-node/issues/77
+        'node/no-unpublished-require': 'off'<% } %>
+      })
     }
   ]
 };
diff --git a/blueprints/app/files/package.json b/blueprints/app/files/package.json
index 01989bf43..13a63fb85 100644
--- a/blueprints/app/files/package.json
+++ b/blueprints/app/files/package.json
@@ -42,6 +42,7 @@
     "ember-source": "~3.10.0-beta.1<% if (welcome) { %>",
     "ember-welcome-page": "^4.0.0<% } %>",
     "eslint-plugin-ember": "^6.2.0",
+    "eslint-plugin-node": "^8.0.1",
     "loader.js": "^4.7.0",
     "qunit-dom": "^0.8.4"
   },
diff --git a/blueprints/module-unification-addon/files/.eslintrc.js b/blueprints/module-unification-addon/files/.eslintrc.js
index e956d0e02..9fb3578ff 100644
--- a/blueprints/module-unification-addon/files/.eslintrc.js
+++ b/blueprints/module-unification-addon/files/.eslintrc.js
@@ -44,6 +44,10 @@ module.exports = {
       plugins: ['node'],
       rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
         // add your custom rules and overrides for node files here
+
+        // this can be removed once the following is fixed
+        // https://github.com/mysticatea/eslint-plugin-node/issues/77
+        'node/no-unpublished-require': 'off'
       })
     }
   ]
diff --git a/blueprints/module-unification-app/files/.eslintrc.js b/blueprints/module-unification-app/files/.eslintrc.js
index 33b809b07..11a2f2d0f 100644
--- a/blueprints/module-unification-app/files/.eslintrc.js
+++ b/blueprints/module-unification-app/files/.eslintrc.js
@@ -36,7 +36,15 @@ module.exports = {
       env: {
         browser: false,
         node: true
-      }
+      },
+      plugins: ['node'],
+      rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
+        // add your custom rules and overrides for node files here
+
+        // this can be removed once the following is fixed
+        // https://github.com/mysticatea/eslint-plugin-node/issues/77
+        'node/no-unpublished-require': 'off'
+      })
     }
   ]
 };
diff --git a/blueprints/module-unification-app/files/package.json b/blueprints/module-unification-app/files/package.json
index e01a53d04..aa755fee7 100644
--- a/blueprints/module-unification-app/files/package.json
+++ b/blueprints/module-unification-app/files/package.json
@@ -42,6 +42,7 @@
     "ember-source": "<%= emberCanaryVersion %><% if (welcome) { %>",
     "ember-welcome-page": "^4.0.0<% } %>",
     "eslint-plugin-ember": "^6.2.0",
+    "eslint-plugin-node": "^8.0.1",
     "loader.js": "^4.7.0",
     "qunit-dom": "^0.8.4"
   },


Test patch:
diff --git a/tests/fixtures/app/.eslintrc.js b/tests/fixtures/app/.eslintrc.js
index 28ef895a0..b56c53488 100644
--- a/tests/fixtures/app/.eslintrc.js
+++ b/tests/fixtures/app/.eslintrc.js
@@ -36,7 +36,15 @@ module.exports = {
       env: {
         browser: false,
         node: true
-      }
+      },
+      plugins: ['node'],
+      rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
+        // add your custom rules and overrides for node files here
+
+        // this can be removed once the following is fixed
+        // https://github.com/mysticatea/eslint-plugin-node/issues/77
+        'node/no-unpublished-require': 'off'
+      })
     }
   ]
 };
diff --git a/tests/fixtures/app/npm/package.json b/tests/fixtures/app/npm/package.json
index f1ad86a74..b08a1c071 100644
--- a/tests/fixtures/app/npm/package.json
+++ b/tests/fixtures/app/npm/package.json
@@ -41,6 +41,7 @@
     "ember-resolver": "^5.0.1",
     "ember-source": "~3.10.0-beta.1",
     "eslint-plugin-ember": "^6.2.0",
+    "eslint-plugin-node": "^8.0.1",
     "loader.js": "^4.7.0",
     "qunit-dom": "^0.8.4"
   },
diff --git a/tests/fixtures/app/yarn/package.json b/tests/fixtures/app/yarn/package.json
index b51431cb5..87dbad631 100644
--- a/tests/fixtures/app/yarn/package.json
+++ b/tests/fixtures/app/yarn/package.json
@@ -42,6 +42,7 @@
     "ember-source": "~3.10.0-beta.1",
     "ember-welcome-page": "^4.0.0",
     "eslint-plugin-ember": "^6.2.0",
+    "eslint-plugin-node": "^8.0.1",
     "loader.js": "^4.7.0",
     "qunit-dom": "^0.8.4"
   },
diff --git a/tests/fixtures/module-unification-addon/.eslintrc.js b/tests/fixtures/module-unification-addon/.eslintrc.js
index e956d0e02..9fb3578ff 100644
--- a/tests/fixtures/module-unification-addon/.eslintrc.js
+++ b/tests/fixtures/module-unification-addon/.eslintrc.js
@@ -44,6 +44,10 @@ module.exports = {
       plugins: ['node'],
       rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
         // add your custom rules and overrides for node files here
+
+        // this can be removed once the following is fixed
+        // https://github.com/mysticatea/eslint-plugin-node/issues/77
+        'node/no-unpublished-require': 'off'
       })
     }
   ]
diff --git a/tests/fixtures/module-unification-app/.eslintrc.js b/tests/fixtures/module-unification-app/.eslintrc.js
index 33b809b07..11a2f2d0f 100644
--- a/tests/fixtures/module-unification-app/.eslintrc.js
+++ b/tests/fixtures/module-unification-app/.eslintrc.js
@@ -36,7 +36,15 @@ module.exports = {
       env: {
         browser: false,
         node: true
-      }
+      },
+      plugins: ['node'],
+      rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
+        // add your custom rules and overrides for node files here
+
+        // this can be removed once the following is fixed
+        // https://github.com/mysticatea/eslint-plugin-node/issues/77
+        'node/no-unpublished-require': 'off'
+      })
     }
   ]
 };
diff --git a/tests/fixtures/module-unification-app/npm/package.json b/tests/fixtures/module-unification-app/npm/package.json
index 0830643c6..ec05d7782 100644
--- a/tests/fixtures/module-unification-app/npm/package.json
+++ b/tests/fixtures/module-unification-app/npm/package.json
@@ -41,6 +41,7 @@
     "ember-resolver": "^5.0.1",
     "ember-source": "<%= emberCanaryVersion %>",
     "eslint-plugin-ember": "^6.2.0",
+    "eslint-plugin-node": "^8.0.1",
     "loader.js": "^4.7.0",
     "qunit-dom": "^0.8.4"
   },
diff --git a/tests/fixtures/module-unification-app/yarn/package.json b/tests/fixtures/module-unification-app/yarn/package.json
index 7c0581782..a5f48b551 100644
--- a/tests/fixtures/module-unification-app/yarn/package.json
+++ b/tests/fixtures/module-unification-app/yarn/package.json
@@ -42,6 +42,7 @@
     "ember-source": "<%= emberCanaryVersion %>",
     "ember-welcome-page": "^4.0.0",
     "eslint-plugin-ember": "^6.2.0",
+    "eslint-plugin-node": "^8.0.1",
     "loader.js": "^4.7.0",
     "qunit-dom": "^0.8.4"
   },
diff --git a/tests/unit/blueprints/addon-test.js b/tests/unit/blueprints/addon-test.js
index d3eb777e9..690463437 100644
--- a/tests/unit/blueprints/addon-test.js
+++ b/tests/unit/blueprints/addon-test.js
@@ -82,8 +82,7 @@ describe('blueprint - addon', function() {
   "devDependencies": {\n\
     "ember-disable-prototype-extensions": "^1.1.3",\n\
     "ember-source-channel-url": "^1.1.0",\n\
-    "ember-try": "^1.0.0",\n\
-    "eslint-plugin-node": "^8.0.1"\n\
+    "ember-try": "^1.0.0"\n\
   },\n\
   "ember-addon": {\n\
     "configPath": "tests/dummy/config"\n\