Skip to content

tooling: update pre-commit hook to stop failure propagation of no-import rule of missing dependencies #5430

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/swift-lizards-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@spectrum-web-components/icon': minor
---

fix: added missing reactive controller dependency for IconBase which was importing SystemContextResolution for context switching
26 changes: 13 additions & 13 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/usr/bin/env bash
bash << EOF
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")
STAGED_CSS_FILES=$(git diff --name-only --cached --diff-filter=d -- "{packages,tools}/**/*.css")
VERSION_FILE=$(dirname "$0")/../tools/base/src/version.js
#!/bin/bash
set -e
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah I've noticed this issue as well, however here's the documentation around why we added the bash wrapper: https://typicode.github.io/husky/how-to.html#bash

We're not currently supporting Windows so it seemed a fine compromise. The if syntax however is Bash syntax so removing that would be a potential issue. What do you suggest?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was thinking we could migrate all these rules into a lint-staged config and just run the yarn lint-staged command here instead of all this logic. What are your thoughts? Was playing around with that here: #5393

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like the idea of migrate these in a module in a lint-staged config. More scalable. Let me update this here and test. Please feel free to add your thoughts too!


[ -z "$STAGED_FILES_TO_LINT" ] || yarn eslint -f pretty $STAGED_FILES_TO_LINT
[ -z "$STAGED_FILES_TO_ANALYZE" ] || yarn lit-analyzer $STAGED_FILES_TO_ANALYZE
[ -z "$STAGED_CSS_FILES" ] || yarn stylelint $STAGED_CSS_FILES
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/*/src/**/*.ts tools/*/src/**/*.ts)
STAGED_CSS_FILES=$(git diff --name-only --cached --diff-filter=d -- 'packages/**/*.css' 'tools/**/*.css')
VERSION_FILE=$(dirname "$0")/../tools/base/src/version.js

yarn pretty-quick --staged
[ -z "$STAGED_FILES_TO_LINT" ] || yarn eslint -f pretty $STAGED_FILES_TO_LINT
[ -z "$STAGED_FILES_TO_ANALYZE" ] || yarn lit-analyzer $STAGED_FILES_TO_ANALYZE
[ -z "$STAGED_CSS_FILES" ] || yarn stylelint $STAGED_CSS_FILES

yarn genversion --es6 --semi $VERSION_FILE
git add $VERSION_FILE
EOF
yarn pretty-quick --staged

yarn genversion --es6 --semi "$VERSION_FILE"
git add "$VERSION_FILE"
15 changes: 14 additions & 1 deletion packages/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,26 @@
"es6": true
},
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "notice", "@spectrum-web-components"],
"plugins": [
"@typescript-eslint",
"notice",
"@spectrum-web-components",
"import"
],
"extends": [
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:lit-a11y/recommended"
],
"rules": {
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": false,
"optionalDependencies": false,
"peerDependencies": false
}
],
"no-debugger": 2,
"no-console": [
"error",
Expand Down
3 changes: 2 additions & 1 deletion packages/icon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@
],
"dependencies": {
"@spectrum-web-components/base": "1.6.0",
"@spectrum-web-components/iconset": "1.6.0"
"@spectrum-web-components/iconset": "1.6.0",
"@spectrum-web-components/reactive-controllers": "1.6.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

good catch here

},
"devDependencies": {
"@spectrum-css/icon": "9.1.0"
Expand Down
1 change: 0 additions & 1 deletion packages/icon/src/IconBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export class IconBase extends SpectrumElement {
public static override get styles(): CSSResultArray {
return [iconStyles];
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you mean to remove this whitespace? It seems useful to delineate the two properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah! I was testing the linting with some additional fail checks here. Should be removed. Thanks for catching this

private unsubscribeSystemContext: (() => void) | null = null;

@state()
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7979,6 +7979,7 @@ __metadata:
"@spectrum-css/icon": "npm:9.1.0"
"@spectrum-web-components/base": "npm:1.6.0"
"@spectrum-web-components/iconset": "npm:1.6.0"
"@spectrum-web-components/reactive-controllers": "npm:1.6.0"
languageName: unknown
linkType: soft

Expand Down
Loading