Scripts: Ignore linting files located in build folders by default #15977
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.
Description
Closes #15407.
It should give very good defaults with the related proposal #15890 which provides defaults for file pattern matching.
This PR ensures that by default all files located in
build
andnode_modules
folders are ignored when usingwp-scripts
for all 3 types of linter:lint-js
lint-pkg-json
lint-style
How has this been tested?
This is quite difficult to test without publishing to npm. I personally tested it with Gutenberg repository by playing with configuration files. This is how you can run commands:
npx wp-scripts lint-js .
npx wp-scripts lint-pkg-json .
npx wp-scripts lint-style '**/*.scss'
I deleted
.eslintignore
from the root folder of Gutenberg and played with defaults:packages/scripts/config/.eslintignore
packages/scripts/config/.npmpackagejsonlintignore
packages/scripts/config/.stylelintignore
I had to add some linting errors in random files to ensure it all works.
Then I reverted changes in those config files and copied them to the root folder. I tried again to modify those config files in the root folder running all commands again.
I also ensured that when I add violations to files inside
build
ornode_modules
nested subfolder, those errors are ignored.