Skip to content

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

castastrophe
Copy link
Collaborator

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)

Motivation and context

How has this been tested?

  • Test case 1

    1. Go here
    2. Do this
  • Test case 2

    1. Go here
    2. Do this
  • Did it pass in Desktop?

  • Did it pass in Mobile?

  • Did it pass in iPad?

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

Checklist

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • If my change required a change to the documentation, I have updated the documentation in this pull request.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices

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.

Copy link

changeset-bot bot commented Apr 23, 2025

⚠️ No Changeset found

Latest commit: f46b5a0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

yarn genversion --es6 --semi $VERSION_FILE
git add $VERSION_FILE
EOF
yarn lint-staged --allow-empty
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much less complexity! 🥳

Copy link

Branch preview

Review the following VRT differences

When 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 current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

Copy link

Tachometer results

Currently, no packages are changed by this PR...

@@ -7,6 +7,6 @@ bracketSpacing: true
arrowParens: always
htmlWhitespaceSensitivity: ignore
overrides:
- files: '{tools,packages}/*/src/spectrum-*.css'
- files: '{tools,packages}/*/src/*.css'
Copy link
Collaborator Author

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.
Copy link
Collaborator Author

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 {
Copy link
Collaborator Author

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

],
'{packages,tools}/*/src/**/!(*.css).ts': ['yarn lit-analyzer'],
'package.json': () => [
'genversion --es6 --semi tools/base/src/version.js',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I correct that we only want to run genversion when the package.json is updated?

"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",
Copy link
Collaborator Author

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",
Copy link
Collaborator Author

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.

@@ -217,7 +217,6 @@ jobs:
- run:
name: Lint
command: yarn lint
- run: yarn analyze
Copy link
Collaborator Author

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

@castastrophe castastrophe force-pushed the castastrophe/chore-lint-staged-tooling branch from 105dc3d to f46b5a0 Compare April 25, 2025 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant