Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripts: Add default file patterns for linting scripts #15890

Merged
merged 2 commits into from
Jun 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It validates all dependencies installed in the project, not only those used for production. We check regular and dev dependencies in Gutenberg, so I thought we should recommend both for other projects as well.

"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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this, it ties in with what you mentioned here: #15890 (comment)

}
}
```

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