chore: lint-staged tooling to simplify pre-commit workflows#5393
chore: lint-staged tooling to simplify pre-commit workflows#5393castastrophe merged 3 commits intomainfrom
Conversation
|
| yarn genversion --es6 --semi $VERSION_FILE | ||
| git add $VERSION_FILE | ||
| EOF | ||
| yarn lint-staged --allow-empty |
There was a problem hiding this comment.
Much less complexity! 🥳
Branch previewReview the following VRT differencesWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
If the changes are expected, update the |
Tachometer resultsCurrently, no packages are changed by this PR... |
.prettierrc.yaml
Outdated
| htmlWhitespaceSensitivity: ignore | ||
| overrides: | ||
| - files: '{tools,packages}/*/src/spectrum-*.css' | ||
| - files: '{tools,packages}/*/src/*.css' |
There was a problem hiding this comment.
All CSS assets benefit from this expanded line-length in order to prevent var function wraps that could block proper downstream minification efforts.
| There are several commands that can be useful in specific scenarios: | ||
|
|
||
| - `yarn build:clear-cache` to remove previously created artifacts of the `tsc build` process. | ||
| - `yarn spectrum-vars` to ensure that theme files are up-to-date. |
There was a problem hiding this comment.
This command is no longer called directly so I removed it from the docs. All other updates are whitespace fixes from prettier.
| governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| export default { |
There was a problem hiding this comment.
This mimics our existing linting rules
package.json
Outdated
| "lint:js": "pretty-quick --pattern \"tasks/**/*.js\" && pretty-quick --pattern \"scripts/**/*.js\"", | ||
| "lint:packagejson": "pretty-quick --pattern package.json --pattern \"packages/*/package.json\" --pattern \"projects/*/package.json\" --pattern \"tools/*/package.json\" --pattern \"react/*/package.json\"", | ||
| "lint:ts": "pretty-quick --pattern \"packages/**/*.ts\" && eslint -f pretty \"packages/**/*.ts\" && pretty-quick --pattern \"tools/**/*.ts\" && eslint -f pretty \"tools/**/*.ts\"", | ||
| "lint": "git status --porcelain && git add . && yarn lint-staged", |
There was a problem hiding this comment.
This git status command checks first if there are uncommitted assets and adds them before linting.
| "test:watch:focus": "yarn build && run-p build:watch \"test:start --watch --group {1}\" --", | ||
| "update:spectrum-css": "node ./scripts/update-spectrum-css.js --latest || yarn update:spectrum-css:cleanup", | ||
| "update:spectrum-css:cleanup": "yarn lint:packagejson && yarn --ignore-scripts && yarn process-spectrum", | ||
| "update:spectrum-css:cleanup": "yarn --ignore-scripts && yarn process-spectrum && yarn lint", |
There was a problem hiding this comment.
I moved this order around because you can't run the linter until you've installed with yarn first anyway.
There was a problem hiding this comment.
nit: I don't think we need this script anymore for cut-off?
There was a problem hiding this comment.
True but since we haven't merged the cutoff work yet, this PR was built to merge either before or after. If after, I'd just rebase the branch and update this bit.
| - run: | ||
| name: Lint | ||
| command: yarn lint | ||
| - run: yarn analyze |
There was a problem hiding this comment.
This runs as part of the lint task if the appropriate files are edited
d45da11 to
4e4d4a0
Compare
919df82 to
2593a58
Compare
| "test:watch:focus": "yarn build && run-p build:watch \"test:start --watch --group {1}\" --", | ||
| "update:spectrum-css": "node ./scripts/update-spectrum-css.js --latest || yarn update:spectrum-css:cleanup", | ||
| "update:spectrum-css:cleanup": "yarn lint:packagejson && yarn --ignore-scripts && yarn process-spectrum", | ||
| "update:spectrum-css:cleanup": "yarn --ignore-scripts && yarn process-spectrum && yarn lint", |
There was a problem hiding this comment.
nit: I don't think we need this script anymore for cut-off?
| }, | ||
| "process-spectrum": { | ||
| "command": "node ./scripts/spectrum-vars.js && node ./tasks/process-spectrum.js && node ./scripts/generate-tokens.js && yarn format:css", | ||
| "command": "node ./scripts/spectrum-vars.js && node ./tasks/process-spectrum.js && node ./scripts/generate-tokens.js && yarn lint", |
There was a problem hiding this comment.
nit: Maybe comment out this also?
116824d to
e16703a
Compare
66f6f45 to
abe0543
Compare
8c5669b to
5139513
Compare
Rajdeepc
left a comment
There was a problem hiding this comment.
Looks good.
Nit: should we expect the prettier to pick up all the css files in the project and not only the global-vars?
5139513 to
c7a2251
Compare
c7a2251 to
97eb082
Compare
|
@Rajdeepc To answer your question re: prettier applying to all CSS, yes, we definitely do want that line length increase for all CSS because we don't want to introduce whitespace into var functions (what it's doing now when it exceeds line-length 80) because that can't be properly minified downstream. |
Description
Swap out pretty-quick and manual linting calls in favor of the lint-staged tool which lets us define commands to run only when certain files are edited. These actions are only performed on files edited in a pull request or in git history to prevent leaking unrelated changes into pull requests which could expand scope of existing work.
Related issue(s)
How has this been tested?
yarn lintto run after the spectrum CSS assets are built; should run stylelint and prettierFor the below commands, we are editing committed assets and then running
yarn lintto verify the correct commands are triggered. Assets do not need to be staged when running theyarn lintalias however, you can also verify runningyarn lint-stageddirectly and expect the same results (as long as the files are staged first).::slotted([slot='icon']) { flex-shrink: 0; })yarn lintto run the stylelint and prettier commandsyarn lintto run the eslint commandyarn lintto run the genversion and constraints commandsTypes of changes
Checklist
Best practices
This repository uses conventional commit syntax for each commit message; note that the GitHub UI does not use this by default so be cautious when accepting suggested changes. Avoid the "Update branch" button on the pull request and opt instead for rebasing your branch against
main.