-
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
Conversation
d6c9cee
to
2b26699
Compare
hasPackageProp, | ||
hasProjectFile, | ||
} = require( '../utils' ); | ||
|
||
const args = getCliArgs(); | ||
|
||
const defaultFilesArgs = ! hasFileInCliArgs ? [ '.' ] : []; |
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.
Should we use ./src
instead of .
to align with wp-scripts build
?
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.
In #15977, I propose we ignore build
and node_modules
folders by default, so this should be less important than at the moment.
hasProjectFile, | ||
hasPackageProp, | ||
} = require( '../utils' ); | ||
|
||
const args = getCliArgs(); | ||
|
||
const defaultFilesArgs = ! hasFileInCliArgs ? [ '**/*.{css,scss}' ] : []; |
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.
**/*.{css,scss}
- I'm not convinced about this proposal so I'm happy to revisit based on the feedback.
I also consider myself: src/**/*.{css,scss}
to be ready for integration with wp-scripts build
. We can always revisit later once we have #14801 implemented.
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.
In #15977, I propose we ignore build
and node_modules
folders by default, so this should be less important than at the moment.
2b26699
to
9493897
Compare
@@ -114,14 +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 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)
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.
LGTM 👍🏼
9493897
to
b96a34a
Compare
b96a34a
to
16b1936
Compare
This seems to have broken the
See build: https://travis-ci.com/WordPress/gutenberg/jobs/205608992 |
@@ -38,7 +41,7 @@ const defaultIgnoreArgs = ! hasIgnoredFiles ? | |||
|
|||
const result = spawn( | |||
resolveBin( 'npm-package-json-lint', { executable: 'npmPkgJsonLint' } ), | |||
[ ...config, ...defaultIgnoreArgs, ...args ], | |||
[ ...defaultConfigArgs, ...defaultIgnoreArgs, ...args, defaultFilesArgs ], |
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.
Guessing this is meant to be spread ...defaultFileArgs
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.
🙈
@@ -25,10 +25,10 @@ _Example:_ | |||
"scripts": { | |||
"build": "wp-scripts build", | |||
"check-engines": "wp-scripts check-engines", | |||
"check-licenses": "wp-scripts check-licenses --production", |
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.
Description
This PR adds default patterns to match files for linting scripts in
@wordpress/scripts
package. See updated docs for more details:The rationale behind those changes is that everything should work out of the box and plugin developer shouldn't be concerned about file patterns when using those commands. It's still possible to override them but for the majority of cases, it should work seamlessly.
How has this been tested?
I ensured all commands work as expected with Gutenberg:
npm run lint-js
npm run lint-js:fix
npx wp-scripts lint-js packages/e2e-tests/specs/plugins/
- you should see less warnings than when runningnpm run lint-js
npm run lint-css
npm run lint-css:fix
npx wp-scripts lint-style "vendor/"
- you should see tons of errors :)npm run lint-pkg-json
npx wp-scripts lint-pkg-json ./packages
- you should see errrors in the rootpackage.json
fileYou can also introduce errors yourself and check if they are detected.
Checklist: