From 80c523999a6633a3b26cef51fdd44fc5a83fd0af Mon Sep 17 00:00:00 2001 From: Stephen Edgar Date: Sun, 2 Feb 2020 14:46:48 +1100 Subject: [PATCH] Fix, update, and sort _rc_ `hasProjectFile` filenames (#19994) * Update and fix `hasProjectFile` filenames * Sort `hasProjectFile` filenames * Update CHANGELOG.md --- packages/scripts/CHANGELOG.md | 3 +++ packages/scripts/scripts/format-js.js | 8 ++++---- packages/scripts/scripts/lint-js.js | 3 ++- packages/scripts/scripts/lint-md-docs.js | 3 ++- packages/scripts/scripts/lint-pkg-json.js | 6 +++++- packages/scripts/scripts/lint-style.js | 6 +++--- packages/scripts/utils/config.js | 5 ++++- 7 files changed, 23 insertions(+), 11 deletions(-) diff --git a/packages/scripts/CHANGELOG.md b/packages/scripts/CHANGELOG.md index 6cf2ebd32f4d0..f22a8d37f8fe6 100644 --- a/packages/scripts/CHANGELOG.md +++ b/packages/scripts/CHANGELOG.md @@ -14,6 +14,9 @@ - Add `lint-md-docs` script to lint the markup of markdown files, uses the `markdownlint` module ([#19855](https://github.com/WordPress/gutenberg/pull/19855)). - Add `packages-update` script to update WordPress packages to the latest version automatically ([#19448](https://github.com/WordPress/gutenberg/pull/19448)). +### Bug Fixes +- Fixes and updates valid _rc_ configuration filenames for Babel, ESLint, markdownlint, npmpackagejsonlint, stylelint, and Prettier ([#19994](https://github.com/WordPress/gutenberg/pull/19994)). + ## 6.1.1 (2020-01-01) ### Bug Fixes diff --git a/packages/scripts/scripts/format-js.js b/packages/scripts/scripts/format-js.js index e5c436ac95cf8..112978a379471 100644 --- a/packages/scripts/scripts/format-js.js +++ b/packages/scripts/scripts/format-js.js @@ -61,13 +61,13 @@ function checkPrettier() { // See: https://prettier.io/docs/en/configuration.html const hasProjectPrettierConfig = - hasProjectFile( '.prettierrc' ) || + hasProjectFile( '.prettierrc.js' ) || hasProjectFile( '.prettierrc.json' ) || + hasProjectFile( '.prettierrc.toml' ) || hasProjectFile( '.prettierrc.yaml' ) || hasProjectFile( '.prettierrc.yml' ) || - hasProjectFile( '.prettierrc.js' ) || - hasProjectFile( '.prettierrc.config.js' ) || - hasProjectFile( '.prettierrc.toml' ) || + hasProjectFile( 'prettier.config.js' ) || + hasProjectFile( '.prettierrc' ) || hasPackageProp( 'prettier' ); if ( ! hasProjectPrettierConfig ) { diff --git a/packages/scripts/scripts/lint-js.js b/packages/scripts/scripts/lint-js.js index 1f664dd9e05a9..317a05e9e0899 100644 --- a/packages/scripts/scripts/lint-js.js +++ b/packages/scripts/scripts/lint-js.js @@ -25,9 +25,10 @@ const hasLintConfig = hasArgInCLI( '-c' ) || hasArgInCLI( '--config' ) || hasProjectFile( '.eslintrc.js' ) || + hasProjectFile( '.eslintrc.json' ) || hasProjectFile( '.eslintrc.yaml' ) || hasProjectFile( '.eslintrc.yml' ) || - hasProjectFile( '.eslintrc.json' ) || + hasProjectFile( 'eslintrc.config.js' ) || hasProjectFile( '.eslintrc' ) || hasPackageProp( 'eslintConfig' ); diff --git a/packages/scripts/scripts/lint-md-docs.js b/packages/scripts/scripts/lint-md-docs.js index d43d589c25d3b..740d3e5af7304 100644 --- a/packages/scripts/scripts/lint-md-docs.js +++ b/packages/scripts/scripts/lint-md-docs.js @@ -26,7 +26,8 @@ const hasLintConfig = hasArgInCLI( '--config' ) || hasProjectFile( '.markdownlint.json' ) || hasProjectFile( '.markdownlint.yaml' ) || - hasProjectFile( '.markdownlint.yml' ); + hasProjectFile( '.markdownlint.yml' ) || + hasProjectFile( '.markdownlintrc' ); // When a configuration is not provided by the project, use from the default // provided with the scripts module. diff --git a/packages/scripts/scripts/lint-pkg-json.js b/packages/scripts/scripts/lint-pkg-json.js index 93a0ed36e9d6d..44c9126829ba5 100644 --- a/packages/scripts/scripts/lint-pkg-json.js +++ b/packages/scripts/scripts/lint-pkg-json.js @@ -20,12 +20,16 @@ const args = getArgsFromCLI(); const defaultFilesArgs = hasFileArgInCLI() ? [] : [ '.' ]; -// See: https://github.com/tclindner/npm-package-json-lint/wiki/configuration#configuration. +// See: https://npmpackagejsonlint.org/docs/en/configuration const hasLintConfig = hasArgInCLI( '-c' ) || hasArgInCLI( '--configFile' ) || + hasProjectFile( '.npmpackagejsonlintrc.js' ) || hasProjectFile( '.npmpackagejsonlintrc.json' ) || + hasProjectFile( '.npmpackagejsonlintrc.yaml' ) || + hasProjectFile( '.npmpackagejsonlintrc.yml' ) || hasProjectFile( 'npmpackagejsonlint.config.js' ) || + hasProjectFile( '.npmpackagejsonlintrc' ) || hasPackageProp( 'npmpackagejsonlint' ) || // npm-package-json-lint v3.x used a different prop name. hasPackageProp( 'npmPackageJsonLintConfig' ); diff --git a/packages/scripts/scripts/lint-style.js b/packages/scripts/scripts/lint-style.js index a1f41c1e2c172..43bbfaa6e5524 100644 --- a/packages/scripts/scripts/lint-style.js +++ b/packages/scripts/scripts/lint-style.js @@ -20,15 +20,15 @@ const args = getArgsFromCLI(); const defaultFilesArgs = hasFileArgInCLI() ? [] : [ '**/*.{css,scss}' ]; -// See: https://github.com/stylelint/stylelint/blob/master/docs/user-guide/configuration.md#loading-the-configuration-object. +// See: https://stylelint.io/user-guide/configuration const hasLintConfig = hasArgInCLI( '--config' ) || - hasProjectFile( '.stylelintrc' ) || hasProjectFile( '.stylelintrc.js' ) || hasProjectFile( '.stylelintrc.json' ) || hasProjectFile( '.stylelintrc.yaml' ) || hasProjectFile( '.stylelintrc.yml' ) || - hasProjectFile( '.stylelint.config.js' ) || + hasProjectFile( 'stylelint.config.js' ) || + hasProjectFile( '.stylelintrc' ) || hasPackageProp( 'stylelint' ); const defaultConfigArgs = ! hasLintConfig diff --git a/packages/scripts/utils/config.js b/packages/scripts/utils/config.js index 5c7f47ec47c5e..2524f7d17168a 100644 --- a/packages/scripts/utils/config.js +++ b/packages/scripts/utils/config.js @@ -15,10 +15,13 @@ const { const { fromConfigRoot, hasProjectFile } = require( './file' ); const { hasPackageProp } = require( './package' ); +// See https://babeljs.io/docs/en/config-files#configuration-file-types const hasBabelConfig = () => - hasProjectFile( '.babelrc' ) || hasProjectFile( '.babelrc.js' ) || + hasProjectFile( '.babelrc.json' ) || hasProjectFile( 'babel.config.js' ) || + hasProjectFile( 'babel.config.json' ) || + hasProjectFile( '.babelrc' ) || hasPackageProp( 'babel' ); const hasJestConfig = () =>