-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
@@ -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. | ||
|
||
|
@@ -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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
||
|
@@ -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. | ||
|
||
|
@@ -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. | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.