Skip to content

Commit

Permalink
Scripts: Add default file patterns for linting scripts (#15890)
Browse files Browse the repository at this point in the history
* Scripts: Add default file patterns for linting scripts

* Add CHANGELOG entry
  • Loading branch information
gziolo committed Jun 5, 2019
1 parent a488920 commit 941c6ec
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 122 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 @@ -182,7 +186,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
3 changes: 3 additions & 0 deletions packages/scripts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

### New Features

- The `lint-js` command lints now JS files in the entire project's directories by default ([15890](https://github.com/WordPress/gutenberg/pull/15890)).
- The `lint-pkg-json` command lints now `package.json` files in the entire project's directories by default ([15890](https://github.com/WordPress/gutenberg/pull/15890)).
- The `lint-style` command lints now CSS and SCSS files in the entire project's directories by default ([15890](https://github.com/WordPress/gutenberg/pull/15890)).
- The `lint-js`, `lint-pkg-json` and `lint-style` commands ignore now files located in `build` and `node_modules` folders by default ([15977](https://github.com/WordPress/gutenberg/pull/15977)).

## 3.2.0 (2019-05-21)
Expand Down
31 changes: 21 additions & 10 deletions packages/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ _Example:_
"scripts": {
"build": "wp-scripts build",
"check-engines": "wp-scripts check-engines",
"check-licenses": "wp-scripts check-licenses --production",
"lint:css": "wp-scripts lint-style '**/*.css'",
"lint:js": "wp-scripts lint-js .",
"lint:pkg-json": "wp-scripts lint-pkg-json .",
"check-licenses": "wp-scripts check-licenses",
"lint:css": "wp-scripts lint-style",
"lint:js": "wp-scripts lint-js",
"lint:pkg-json": "wp-scripts lint-pkg-json",
"start": "wp-scripts start",
"test:e2e": "wp-scripts test-e2e",
"test:unit": "wp-scripts test-unit-js"
Expand Down Expand Up @@ -101,7 +101,7 @@ _Example:_
_Flags_:

- `--prod` (or `--production`): When present, validates only `dependencies` and not `devDependencies`
- `--dev` (or `--development`): When present, validates both `dependencies` and `devDependencies`
- `--dev` (or `--development`): When present, validates only `devDependencies` and not `dependencies`
- `--gpl2`: Validates against [GPLv2 license compatibility](https://www.gnu.org/licenses/license-list.en.html)
- `--ignore=a,b,c`: A comma-separated set of package names to ignore for validation. This is intended to be used primarily in cases where a dependency's `license` field is malformed. It's assumed that any `ignored` package argument would be manually vetted for compatibility by the project owner.

Expand All @@ -114,15 +114,18 @@ _Example:_
```json
{
"scripts": {
"lint:js": "wp-scripts lint-js ."
"lint:js": "wp-scripts lint-js",
"lint:js:src": "wp-scripts lint-js ./src"
}
}
```

This is how you execute the script with presented setup:

* `npm run lint:js` - lints JavaScript files in the entire project's directories.
* `npm run lint:js:src` - lints JavaScript files in the project's `src` subfolder's directories.

When you run commands similar to the `npm run lint:js:src` example above, you can provide a file, a directory, or `glob` syntax or any combination of them. See [more examples](https://eslint.org/docs/user-guide/command-line-interface).

By default, files located in `build` and `node_modules` folders are ignored.

Expand All @@ -139,14 +142,18 @@ _Example:_
```json
{
"scripts": {
"lint:pkg-json": "wp-scripts lint-pkg-json ."
"lint:pkg-json": "wp-scripts lint-pkg-json",
"lint:pkg-json:src": "wp-scripts lint-pkg-json ./src"
}
}
```

This is how you execute those scripts using the presented setup:

* `npm run lint:pkg-json` - lints `package.json` file in the project's root folder.
* `npm run lint:pkg-json` - lints `package.json` file in the entire project's directories.
* `npm run lint:pkg-json:src` - lints `package.json` file in the project's `src` subfolder's directories.

When you run commands similar to the `npm run lint:pkg-json:src` example above, you can provide one or multiple directories to scan as well. See [more examples](https://github.com/tclindner/npm-package-json-lint/blob/HEAD/README.md#examples).

By default, files located in `build` and `node_modules` folders are ignored.

Expand All @@ -163,14 +170,18 @@ _Example:_
```json
{
"scripts": {
"lint:css": "wp-scripts lint-style '**/*.css'"
"lint:style": "wp-scripts lint-style",
"lint:css:src": "wp-scripts lint-style 'src/**/*.css'"
}
}
```

This is how you execute the script with presented setup:

* `npm run lint:css` - lints CSS files in the whole project's directory.
* `npm run lint:style` - lints CSS and SCSS files in the entire project's directories.
* `npm run lint:css:src` - lints only CSS files in the project's `src` subfolder's directories.

When you run commands similar to the `npm run lint:css:src` example above, be sure to include the quotation marks around file globs. This ensures that you can use the powers of [globby](https://github.com/sindresorhus/globby) (like the `**` globstar) regardless of your shell. See [more examples](https://github.com/stylelint/stylelint/blob/HEAD/docs/user-guide/cli.md#examples).

By default, files located in `build` and `node_modules` folders are ignored.

Expand Down
Loading

0 comments on commit 941c6ec

Please sign in to comment.