-
Notifications
You must be signed in to change notification settings - Fork 217
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
chore: improve css import results; optimize precommit runs #5200
base: main
Are you sure you want to change the base?
Conversation
|
"spectrum-css": "wireit", | ||
"spectrum-tokens": "wireit", | ||
"spectrum-vars": "wireit", |
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.
These commands don't exist in wireit and haven't for a long while - seems safe to remove the alias'es right?
"peerDependencies": { | ||
"common-tags": "^1.8.0" | ||
}, |
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.
This implies consumers checking out the monorepo root would need to install common-tags locally for themselves in order to be able to build this project but I don't believe that is the case. Can we remove this? I don't think the monorepo root has any required peerDeps.
@@ -385,7 +379,7 @@ | |||
] | |||
}, | |||
"process-spectrum": { | |||
"command": "node ./scripts/spectrum-vars.js && node ./tasks/process-spectrum.js && node ./scripts/generate-tokens.js && yarn lint:css --fix && pretty-quick --pattern \"{packages,tools}/**/*.css\" && pretty-quick --pattern \"packages/dialog/src/spectrum-dialog.css\"", | |||
"command": "node ./scripts/spectrum-vars.js && node ./tasks/process-spectrum.js && node ./scripts/generate-tokens.js && yarn lint:css --fix && pretty-quick --pattern \"{packages,tools}/**/*.css\"", |
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 removed the additional pretty-quick run against spectrum-dialog because it's already included in the pattern for the previous pretty-quick run.
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... |
@@ -1,8 +1,13 @@ | |||
STAGED_FILES_TO_LINT=$(git diff --name-only --cached --diff-filter=d -- "*.ts" "*.js") | |||
STAGED_FILES_TO_ANALYZE=$(git diff --name-only --cached --diff-filter=d -- "{packages,tools}/*/src/**/!(*.css).ts") |
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.
This is nice! :)
Just for my knowledge, is git diff
op faster than globbing through packages?
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.
What do you mean by "globbing through packages"? Git diff is the only way, as far as I know, to fetch the list of files changed: https://git-scm.com/docs/git-diff
4324c96
to
fa86913
Compare
fa86913
to
26eee28
Compare
Description
Pre-commit improvements
Previous the husky pre-commit task was running analysis and linting on files whether they were present in the commit or not. This update adds a specificity to the pre-commit tool by ensuring commands are run only on those files being modified by that commit.
Most relevantly,
yarn analyze
was running the lit-analyzer on 5,840 files every single commit even if no changes were made to lit-based assets.CSS import improvements
Prettier's line wrapping for CSS does not have exceptions for var functions; adding whitespace or newlines to var functions cannot be minified safely downstream (and many minifiers won't) because whitespace is valid in a CSS var function. By increasing the line-length for CSS, we prevent invalid newlines being adding into var functions.
This PR adds a spectrum-*.css exception to prettier to allow for up-to-500 characters per line to prevent aggressive line wrapping that will break that downstream minification.
It also swaps stylelint configurations to only lean on the header plugin by default and adds the stylelint-config settings for files not being imported from Spectrum CSS. Spectrum CSS already processes the assets according to rigorous Stylelint configurations and these were stripping important vendor prefixes from the results.
How has this been tested?
Setup: Before testing the husky pre-commit hooks, add
exit 1
to the bottom of the pre-commit script. Docs. Remove this once testing is complete and do not commit that change.*.ts
file in the project,git add . && git commit -m "chore: testing pre-commit hook
. Expect it to run eslint against that file (but no others).packages/*/src/**/*.ts
file in the project,git add . && git commit -m "chore: testing pre-commit hook
. Expect it to run lit-analyzer against that file (but no others).packages/**/*.css
file in the project,git add . && git commit -m "chore: testing pre-commit hook
. Expect it to run stylelint against that file (but no others).packages/*/src/spectrum-*.css
files which now have significantly fewer line breaks inside of var functions.packages/accordion/src/accordion.css
to remove the copyright and add-webkit-animation: alternate;
to the:host
selector. Runyarn lint:css
and expect to see:packages/accordion/src/accordion.css 1:1 ✖ Header not found header/header 6:5 ✖ Expected empty line before declaration declaration-empty-line-before 6:5 ✖ Unexpected vendor-prefix "-webkit-animation" property-no-vendor-prefix
Types 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
.