tooling: update pre-commit hook to stop failure propagation of no-import rule of missing dependencies
Description
This PR updates the pre-commit hook to reliably lint, analyze, and format only the staged files using ESLint, Lit Analyzer, Stylelint, and Prettier. The script has been rewritten as a standalone shell script with strict error handling using set -e. It ensures that the commit process is blocked if any linting or analysis tool fails. Additionally, genversion is executed and the resulting file is re-staged for inclusion in the commit.
Related issue(s)
- N/A
Motivation and context
Previously, the pre-commit hook used a bash << EOF heredoc block, which caused failures in expected linting behavior. Errors from linters were not blocking commits as expected due to the lack of strict failure propagation in the heredoc context. This update resolves that by using a standard shell script with correct error handling and scoped linting to staged files only.
How has this been tested?
Manually tested in a local development environment using the following steps:
-
[x] Test case 1
- Make a change to a
.tsfile that introduces an ESLint error. - Attempt to commit.
- Verify that the commit is blocked with the lint error shown.
- Make a change to a
-
[x] Test case 2
- Make changes to
.cssand.tsfiles without lint issues. - Attempt to commit.
- Verify that the commit goes through and the version file is updated and re-staged.
- Make changes to
-
[x] Test case 3
- Remove
@spectrum-web-components/reactive-controllerfrom the dependencies inpackages/icon/package.json. - Attempt to commit.
- Verify that the commit is blocked with the lint error shown.
import/no-extraneous-dependenciesrule is blocking the commit due to missing dependencies
- Remove
-
[x] Did it pass in Desktop?
-
[x] Did it pass in Mobile?
-
[x] Did it pass in iPad?
Screenshots (if appropriate)
N/A
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)
- [x] Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)
Checklist
- [x] I have signed the Adobe Open Source CLA.
- [x] 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.
- [x] All new and existing tests passed.
- [ ] I have reviewed at the Accessibility Practices for this feature, see: Aria Practices
🦋 Changeset detected
Latest commit: f32711d44630f60923bf188211eefb4e90e89ae7
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 84 packages
| Name | Type |
|---|---|
| @spectrum-web-components/icon | Minor |
| @spectrum-web-components/accordion | Minor |
| @spectrum-web-components/action-button | Minor |
| @spectrum-web-components/action-menu | Minor |
| @spectrum-web-components/button | Minor |
| @spectrum-web-components/checkbox | Minor |
| @spectrum-web-components/coachmark | Minor |
| @spectrum-web-components/combobox | Minor |
| @spectrum-web-components/field-label | Minor |
| @spectrum-web-components/icons-ui | Minor |
| @spectrum-web-components/icons-workflow | Minor |
| @spectrum-web-components/menu | Minor |
| @spectrum-web-components/number-field | Minor |
| @spectrum-web-components/picker-button | Minor |
| @spectrum-web-components/picker | Minor |
| @spectrum-web-components/search | Minor |
| @spectrum-web-components/swatch | Minor |
| @spectrum-web-components/table | Minor |
| @spectrum-web-components/tabs | Minor |
| @spectrum-web-components/textfield | Minor |
| @spectrum-web-components/toast | Minor |
| @spectrum-web-components/bundle | Minor |
| @spectrum-web-components/action-group | Minor |
| @spectrum-web-components/contextual-help | Minor |
| @spectrum-web-components/overlay | Minor |
| @spectrum-web-components/vrt-compare | Minor |
| @spectrum-web-components/breadcrumbs | Minor |
| @spectrum-web-components/action-bar | Minor |
| @spectrum-web-components/alert-banner | Minor |
| @spectrum-web-components/alert-dialog | Minor |
| @spectrum-web-components/button-group | Minor |
| @spectrum-web-components/dialog | Minor |
| @spectrum-web-components/infield-button | Minor |
| @spectrum-web-components/tags | Minor |
| example-project-rollup | Patch |
| example-project-webpack | Patch |
| @spectrum-web-components/card | Minor |
| @spectrum-web-components/switch | Minor |
| @spectrum-web-components/meter | Minor |
| @spectrum-web-components/progress-bar | Minor |
| @spectrum-web-components/slider | Minor |
| @spectrum-web-components/custom-vars-viewer | Minor |
| @spectrum-web-components/story-decorator | Minor |
| @spectrum-web-components/help-text | Minor |
| @spectrum-web-components/top-nav | Minor |
| @spectrum-web-components/color-field | Minor |
| documentation | Patch |
| @spectrum-web-components/popover | Minor |
| @spectrum-web-components/tooltip | Minor |
| @spectrum-web-components/truncated | Minor |
| @spectrum-web-components/field-group | Minor |
| @spectrum-web-components/radio | Minor |
| @spectrum-web-components/eslint-plugin | Minor |
| @spectrum-web-components/asset | Minor |
| @spectrum-web-components/avatar | Minor |
| @spectrum-web-components/badge | Minor |
| @spectrum-web-components/clear-button | Minor |
| @spectrum-web-components/close-button | Minor |
| @spectrum-web-components/color-area | Minor |
| @spectrum-web-components/color-handle | Minor |
| @spectrum-web-components/color-loupe | Minor |
| @spectrum-web-components/color-slider | Minor |
| @spectrum-web-components/color-wheel | Minor |
| @spectrum-web-components/divider | Minor |
| @spectrum-web-components/dropzone | Minor |
| @spectrum-web-components/icons | Minor |
| @spectrum-web-components/iconset | Minor |
| @spectrum-web-components/illustrated-message | Minor |
| @spectrum-web-components/link | Minor |
| @spectrum-web-components/modal | Minor |
| @spectrum-web-components/progress-circle | Minor |
| @spectrum-web-components/sidenav | Minor |
| @spectrum-web-components/split-view | Minor |
| @spectrum-web-components/status-light | Minor |
| @spectrum-web-components/thumbnail | Minor |
| @spectrum-web-components/tray | Minor |
| @spectrum-web-components/underlay | Minor |
| @spectrum-web-components/base | Minor |
| @spectrum-web-components/grid | Minor |
| @spectrum-web-components/opacity-checkerboard | Minor |
| @spectrum-web-components/reactive-controllers | Minor |
| @spectrum-web-components/shared | Minor |
| @spectrum-web-components/styles | Minor |
| @spectrum-web-components/theme | Minor |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
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:
- Spectrum | Light | Medium | LTR
- Spectrum | Dark | Large | RTL
- Express | Light | Medium | LTR
- Express | Dark | Large | RTL
- Spectrum-two | Light | Medium | LTR
- Spectrum-two | Dark | Large | RTL
- High Contrast Mode | Medium | LTR
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.
Tachometer results
Chrome
icon permalink
test-basic
| Version | Bytes | Avg Time | vs remote | vs branch |
|---|---|---|---|---|
| npm latest | 444 kB | 14.51ms - 14.78ms | - | faster ✔ 1% - 4% 0.20ms - 0.55ms |
| branch | 422 kB | 14.91ms - 15.13ms | slower ❌ 1% - 4% 0.20ms - 0.55ms |
- |
Firefox
icon permalink
test-basic
| Version | Bytes | Avg Time | vs remote | vs branch |
|---|---|---|---|---|
| npm latest | 444 kB | 35.71ms - 39.33ms | - | unsure 🔍 -6% - +6% -2.27ms - +2.23ms |
| branch | 422 kB | 36.19ms - 38.89ms | unsure 🔍 -6% - +6% -2.23ms - +2.27ms |
- |
Resolved in main