Skip to content

Commit

Permalink
Fix overridden ESLint "import/no-extraneous-dependencies" rule
Browse files Browse the repository at this point in the history
The import/no-extraneous-dependencies (1) rule allows to define a array
of glob pattern that are allowed to define import `devDependencies`. In
GH-15 the rule was overridden to include the project specific path
`**/.gatsby/**` which whitelists all Gatsby specific scripts.
Unfortunately this removes all glob pattern defined in the used
"eslint-config-arcticicestudio" (2) (rule is defined in the `-base`
package) resulting in errors in other projects paths like tests.
This has been fixed by importing the paths defined in the preset from
the "eslint-config-arcticicestudio-base" (3) package and merge it with
the additional **/.gatsby/**` path.

References:
  (1) https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
  (2) https://www.npmjs.com/package/eslint-config-arcticicestudio
  (3) https://www.npmjs.com/package/eslint-config-arcticicestudio-base

Fixes GH-41
  • Loading branch information
arcticicestudio committed Nov 24, 2018
1 parent 7a4d356 commit 7eccff4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 12 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
*/

const { resolve } = require("path");
/* eslint-disable import/no-extraneous-dependencies */
const {
rules: { "import/no-extraneous-dependencies": noExtraneousDependencies }
} = require("eslint-config-arcticicestudio-base/rules/import/helpful-warnings");
/* eslint-enable import/no-extraneous-dependencies */

module.exports = {
extends: "arcticicestudio",
Expand All @@ -38,8 +43,13 @@ module.exports = {
rules: {
"prettier/prettier": "error",
"no-confusing-arrow": "off",
/* Suppress errors when importing development dependencies */
"import/no-extraneous-dependencies": ["error", { devDependencies: ["./.gatsby/**/*.js"] }],
/* Also suppress errors when importing development dependencies in project specific scripts. */
"import/no-extraneous-dependencies": [
"error",
{
devDependencies: noExtraneousDependencies[1].devDependencies.concat(["**/.gatsby/**"])
}
],
/*
* Enable support for experimental features:
*
Expand Down
3 changes: 1 addition & 2 deletions .gatsby/onCreateWebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
*/

const { resolve: resolvePath } = require("path");
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable-next-line import/no-extraneous-dependencies */
const webpack = require("webpack");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
const GitRevisionPlugin = require("git-revision-webpack-plugin");
/* eslint-enable import/no-extraneous-dependencies */

const { BASE_DIR_BUILD_REPORTS } = require("../src/config/internal/constants");

Expand Down

0 comments on commit 7eccff4

Please sign in to comment.