From 9d7846d9ce69b2239596d2ef924f918c97719efd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20=28Greg=29=20Zi=C3=B3=C5=82kowski?= Date: Thu, 24 Jan 2019 17:53:40 +0100 Subject: [PATCH] Scripts: Add missing root flag to the default Eslint config (#13483) * Scripts: Add missing root flag to the default Eslint config * scripts: Instruct ESLint to avoid config discovery in defaulting --- packages/scripts/CHANGELOG.md | 4 ++++ packages/scripts/config/.eslintrc.js | 1 + packages/scripts/scripts/lint-js.js | 5 ++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/scripts/CHANGELOG.md b/packages/scripts/CHANGELOG.md index 40210edd4b1391..9e297b5b652d20 100644 --- a/packages/scripts/CHANGELOG.md +++ b/packages/scripts/CHANGELOG.md @@ -5,6 +5,10 @@ - Added support for `build` script ([#12837](https://github.com/WordPress/gutenberg/pull/12837)) - Added support for `start` script ([#12837](https://github.com/WordPress/gutenberg/pull/12837)) +### Bug Fix + +- Avoid inheriting from ESLint configurations in ancestor directories when using the default configuration ([#13483](https://github.com/WordPress/gutenberg/pull/13483)) + ## 2.5.0 (2019-01-09) ### New Features diff --git a/packages/scripts/config/.eslintrc.js b/packages/scripts/config/.eslintrc.js index 5b59ed86f4d2e5..4fa347677ff521 100644 --- a/packages/scripts/config/.eslintrc.js +++ b/packages/scripts/config/.eslintrc.js @@ -1,3 +1,4 @@ module.exports = { + root: true, extends: [ 'plugin:@wordpress/eslint-plugin/recommended' ], }; diff --git a/packages/scripts/scripts/lint-js.js b/packages/scripts/scripts/lint-js.js index 64b6cb2036ffc6..c7346fb76ad88c 100644 --- a/packages/scripts/scripts/lint-js.js +++ b/packages/scripts/scripts/lint-js.js @@ -26,8 +26,11 @@ const hasLintConfig = hasCliArg( '-c' ) || hasProjectFile( '.eslintrc' ) || hasPackageProp( 'eslintConfig' ); +// When a configuration is not provided by the project, use from the default +// provided with the scripts module. Instruct ESLint to avoid discovering via +// the `--no-eslintrc` flag, as otherwise it will still merge with inherited. const config = ! hasLintConfig ? - [ '--config', fromConfigRoot( '.eslintrc.js' ) ] : + [ '--no-eslintrc', '--config', fromConfigRoot( '.eslintrc.js' ) ] : []; const result = spawn(