-
Notifications
You must be signed in to change notification settings - Fork 222
chore: lint-staged tooling to simplify pre-commit workflows #5393
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
base: main
Are you sure you want to change the base?
Conversation
|
yarn genversion --es6 --semi $VERSION_FILE | ||
git add $VERSION_FILE | ||
EOF | ||
yarn lint-staged --allow-empty |
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.
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
@@ -7,6 +7,6 @@ bracketSpacing: true | |||
arrowParens: always | |||
htmlWhitespaceSensitivity: ignore | |||
overrides: | |||
- files: '{tools,packages}/*/src/spectrum-*.css' | |||
- files: '{tools,packages}/*/src/*.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.
All CSS assets benefit from this expanded line-length in order to prevent var function wraps that could block proper downstream minification efforts.
@@ -91,11 +91,10 @@ The `:nonbreaking` variant lets us release patch updates quickly in cases where | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This git status command checks first if there are uncommitted assets and adds them before linting.
@@ -90,7 +84,7 @@ | |||
"test:watch:flags:focus": "yarn build && run-p build:watch \"test:start --watch --group {1} --config web-test-runner.config.ci-chromium-flags.js\" --", | |||
"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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I don't think we need this script anymore for cut-off?
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.
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.
@@ -217,7 +217,6 @@ jobs: | |||
- run: | |||
name: Lint | |||
command: yarn lint | |||
- run: yarn analyze |
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 runs as part of the lint task if the appropriate files are edited
d45da11
to
4e4d4a0
Compare
919df82
to
2593a58
Compare
@@ -90,7 +84,7 @@ | |||
"test:watch:flags:focus": "yarn build && run-p build:watch \"test:start --watch --group {1} --config web-test-runner.config.ci-chromium-flags.js\" --", | |||
"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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I don't think we need this script anymore for cut-off?
@@ -386,7 +380,7 @@ | |||
] | |||
}, | |||
"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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Maybe comment out this also?
116824d
to
e16703a
Compare
38ec2eb
to
66f6f45
Compare
66f6f45
to
abe0543
Compare
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 lint
to 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 lint
to verify the correct commands are triggered. Assets do not need to be staged when running theyarn lint
alias however, you can also verify runningyarn lint-staged
directly and expect the same results (as long as the files are staged first).::slotted([slot='icon']) { flex-shrink: 0; }
)yarn lint
to run the stylelint and prettier commandsyarn lint
to run the eslint commandyarn lint
to 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
.