Skip to content

Commit

Permalink
Scripts: Add default file patterns for linting scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed May 29, 2019
1 parent 03f04f3 commit d6c9cee
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 117 deletions.
123 changes: 22 additions & 101 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
"name": "gutenberg",
"version": "5.8.0",
"private": true,
"description": "A new WordPress editor experience",
"repository": "git+https://github.com/WordPress/gutenberg.git",
"description": "A new WordPress editor experience.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
"keywords": [
"WordPress",
"editor"
],
"homepage": "https://github.com/WordPress/gutenberg/",
"repository": "git+https://github.com/WordPress/gutenberg.git",
"bugs": {
"url": "https://github.com/WordPress/gutenberg/issues"
},
"config": {
"GUTENBERG_PHASE": 2
},
Expand Down Expand Up @@ -177,7 +181,7 @@
"fixtures:generate": "npm run fixtures:server-registered && cross-env GENERATE_MISSING_FIXTURES=y npm run test-unit",
"fixtures:regenerate": "npm run fixtures:clean && npm run fixtures:generate",
"lint": "concurrently \"npm run lint-js\" \"npm run lint-pkg-json\" \"npm run lint-css\"",
"lint-js": "wp-scripts lint-js .",
"lint-js": "wp-scripts lint-js",
"lint-js:fix": "npm run lint-js -- --fix",
"lint-php": "docker-compose run --rm composer run-script lint",
"lint-pkg-json": "wp-scripts lint-pkg-json ./packages",
Expand Down
8 changes: 1 addition & 7 deletions packages/components/src/button/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,7 @@
background-size: 100px 100%;
// Disable reason: This function call looks nicer when each argument is on its own line.
/* stylelint-disable */
background-image: linear-gradient(
-45deg,
theme(primary) 28%,
color(theme(primary) shade(30%)) 28%,
color(theme(primary) shade(30%)) 72%,
theme(primary) 72%
);
background-image: linear-gradient(-45deg, theme(primary) 28%, color(theme(primary) shade(30%)) 28%, color(theme(primary) shade(30%)) 72%, theme(primary) 72%);
/* stylelint-enable */
border-color: color(theme(primary) shade(50%));
}
Expand Down
1 change: 1 addition & 0 deletions packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"eslint": "^5.16.0",
"jest": "^24.7.1",
"jest-puppeteer": "^4.0.0",
"minimist": "^1.2.0",
"npm-package-json-lint": "^3.6.0",
"puppeteer": "1.6.1",
"read-pkg-up": "^1.0.1",
Expand Down
8 changes: 6 additions & 2 deletions packages/scripts/scripts/lint-js.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* External dependencies
*/
const minimist = require( 'minimist' );
const { sync: spawn } = require( 'cross-spawn' );
const { sync: resolveBin } = require( 'resolve-bin' );

Expand All @@ -17,6 +18,9 @@ const {

const args = getCliArgs();

const hasFiles = minimist( args )._.length > 0;
const defaultFilesArgs = ! hasFiles ? [ '.' ] : [];

const hasLintConfig = hasCliArg( '-c' ) ||
hasCliArg( '--config' ) ||
hasProjectFile( '.eslintrc.js' ) ||
Expand All @@ -29,13 +33,13 @@ const hasLintConfig = hasCliArg( '-c' ) ||
// 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 ?
const defaultConfigArgs = ! hasLintConfig ?
[ '--no-eslintrc', '--config', fromConfigRoot( '.eslintrc.js' ) ] :
[];

const result = spawn(
resolveBin( 'eslint' ),
[ ...config, ...args ],
[ ...defaultConfigArgs, ...args, ...defaultFilesArgs ],
{ stdio: 'inherit' }
);

Expand Down
8 changes: 6 additions & 2 deletions packages/scripts/scripts/lint-pkg-json.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* External dependencies
*/
const minimist = require( 'minimist' );
const { sync: spawn } = require( 'cross-spawn' );
const { sync: resolveBin } = require( 'resolve-bin' );

Expand All @@ -17,19 +18,22 @@ const {

const args = getCliArgs();

const hasFiles = minimist( args )._.length > 0;
const defaultFilesArgs = ! hasFiles ? [ '.' ] : [];

const hasLintConfig = hasCliArg( '-c' ) ||
hasCliArg( '--configFile' ) ||
hasProjectFile( '.npmpackagejsonlintrc.json' ) ||
hasProjectFile( 'npmpackagejsonlint.config.js' ) ||
hasPackageProp( 'npmPackageJsonLintConfig' );

const config = ! hasLintConfig ?
const defaultConfigArgs = ! hasLintConfig ?
[ '--configFile', fromConfigRoot( 'npmpackagejsonlint.json' ) ] :
[];

const result = spawn(
resolveBin( 'npm-package-json-lint', { executable: 'npmPkgJsonLint' } ),
[ ...config, ...args ],
[ ...defaultConfigArgs, ...args, defaultFilesArgs ],
{ stdio: 'inherit' }
);

Expand Down
Loading

0 comments on commit d6c9cee

Please sign in to comment.