-
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: lint-styles
--fix tries to fix all files when passing the list of files
#30466
Comments
I don't immediately see examples of passing multiple files to stylelint in their docs: https://stylelint.io/user-guide/usage/cli. @ntwb, do you know why the following in "lint-staged": {
"*.{css,scss}": [
"wp-scripts lint-style --fix"
]
}, I can reproduce it also in Gutenberg. |
lint-styles
--fix tries to fix all files when passing the list of files
lint-styles
--fix tries to fix all files when passing the list of fileslint-styles
--fix tries to fix all files when passing the list of files
It looks like the implementation of gutenberg/packages/scripts/utils/cli.js Line 24 in 176748c
So the issue is that it assumes that wp-scripts lint-style --fix= In general, if there is more than one file passed by |
I added the option ( const minimist = require("minimist")
// Not correctly parsed...
console.log( minimist(['--fix', 'aaa.scss', 'bbb.scss', 'ccc.scss'])._ );
// Correctly parsed (temporary Fix equal sign)
console.log( minimist(['--fix=', 'aaa.scss', 'bbb.scss', 'ccc.scss'])._ );
// Correctly parsed (use boolean option)
console.log( minimist(['--fix', 'aaa.scss', 'bbb.scss', 'ccc.scss'], {boolean: true})._ ); |
@t-hamano, that looks promising. Let's try that approach 👍🏻 Good news is that native experimental args parsing came to Node 18.3: https://nodejs.org/api/util.html#utilparseargsconfig They develop it also as a package available on npm: https://github.com/pkgjs/parseargs. |
I'm trying to use
wp-scripts
to lint the Sass and CSS files in the themes repo. It works well to catch errors in staged files (using lint-staged) but when I pass the--fix
argument to the command it tries to fix all the files in the repo, not just those that are staged. You can see the PR here: Automattic/themes#3611cc @gziolo since you worked on #15890
The text was updated successfully, but these errors were encountered: