-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
🪟🧹 Stylelint #15452
🪟🧹 Stylelint #15452
Conversation
airbyte-webapp/.stylelintrc
Outdated
"font-family-name-quotes": null, | ||
"scss/dollar-variable-empty-line-before": null, | ||
"scss/dollar-variable-pattern": ".*", | ||
"scss/percent-placeholder-pattern": ".*", |
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 enforces kebab case in s/css class names, which doesn't work well for us thanks to modules.
airbyte-webapp/build.gradle
Outdated
@@ -12,7 +12,8 @@ def commonConfigs = [ | |||
'package.json', | |||
'package-lock.json', | |||
'tsconfig.json', | |||
'.prettierrc.js' | |||
'.prettierrc.js', | |||
'.stylelintrc' |
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.
Can remove, felt it didn't hurt to add.
airbyte-webapp/package.json
Outdated
"license-check": "node ./scripts/license-check.js", | ||
"generate-client": "orval", | ||
"validate-links": "ts-node --skip-project ./scripts/validate-links.ts" | ||
"validate-links": "ts-node --skip-project ./scripts/validate-links.ts", | ||
"stylelint-check": "stylelint-config-prettier-scss-check" |
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.
Not sure if we should add this to a pipeline somewhere, or just ignore.
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.
We should def run that on CI, since it's otherwise not really linting anything. For that we should add a new task to our build.gradle file (you can see similar type: NpmTask
in there), and make the gradle check
step depend on this (line 108 you can just add a new task that should run for checks).
We should make also sure that the task running on CI fails if it would restyle any SCSS file, i.e. make git dirty by running. Ideally we see if any of the stylelint
commands actually has a flag to automatically fail if it needs to touch a SCSS file (and separate this here into two tasks: one that does reformat for running locally, and one for CI that fails when it would reformat).
If it doesn't exist we'll need to build into gradle a check that validates that no file got touched after running the stylelint
task.
border-radius: 8px; | ||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); | ||
box-shadow: 0 1px 2px rgba(0, 0, 0, 25%); |
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.
Some of these the linter was able to auto-fix so I let it.
@@ -3,6 +3,7 @@ body, html { | |||
height: 100%; |
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.
We may want to yeet this whole file.
div:hover > div > &, | ||
div:hover > div > div > &, | ||
div:hover > & { | ||
div:hover > div > div > & { |
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.
stylelint gets picky about order
@@ -30,45 +62,45 @@ | |||
&:checked + .slider { | |||
background-color: colors.$blue; | |||
|
|||
&:before { | |||
@include knobTransform(right, false); | |||
&::before { |
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.
::before
is the modern syntax
@@ -43,6 +43,7 @@ export async function render< | |||
renderResult = await rtlRender<Q, Container>(<div>{ui}</div>, { wrapper: Wrapper, ...renderOptions }); | |||
}); | |||
|
|||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion |
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.
Just some linting cleanup
@@ -2,7 +2,7 @@ | |||
@use "./DiffSection.module.scss"; | |||
|
|||
.accordionSubHeader { | |||
@extend .sectionSubHeader; | |||
@extend %sectionSubHeader; |
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.
Can revert, but linter wanted us to use placeholders over classes as classes can result in unintended side effects.
airbyte-webapp/src/views/Connection/ConnectionForm/components/SyncCatalogField.module.scss
Show resolved
Hide resolved
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.
Seems probably worth getting more than one input, but I'm generally on board with letting a linter think about things so I don't have to.
Here's some more context around the placeholders straight from SASS. I'm not entirely sure from this that it does the same thing?: https://sass-lang.com/documentation/at-rules/extend#placeholder-selectors
airbyte-webapp/src/views/Connection/CatalogDiffModal/components/StreamRow.module.scss
Outdated
Show resolved
Hide resolved
airbyte-webapp/build.gradle
Outdated
@@ -104,8 +105,15 @@ task copyNginx(type: Copy) { | |||
into "build/docker/bin/nginx" | |||
} | |||
|
|||
task lint(type: NpmTask) { | |||
dependsOn npmInstall | |||
args = ['run', '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.
We actually don't need to run lint
completely, since Create React App already runs eslint as part of the run build
(and thus we'd simply run it twice now). It should be enough just running the stylelint task individually via Gradle.
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.
Should I make an npm run stylelint
or should I invoke it directly?
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.
LGTM
Lets wait final approve from @timroes
airbyte-webapp/build.gradle
Outdated
@@ -23,6 +23,7 @@ node { | |||
npm_run_build { | |||
inputs.files commonConfigs | |||
inputs.file '.eslintrc' | |||
inputs.file '.stylelintrc' |
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.
Sorry, one last thing 😅 But with running stylelint as a separate task, we should move this as an input to the stylelint
task below. The npm run build
task would have no different output if this file changes.
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.
Fixed I think. You know gradle better than I :)
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.
One last comment about the gradle build file. Once that is resolved LGTM.
* Stylelint added * lint staged addition * Found the right incantation * WIP * Typescript import * stylelint --fix * Stylelint runs clean! * More linting! * paths are hard * linting * Tim Code Review * lint part of build * Better selector class pattern rule * Tim CR * Linting + --fix * Fixing stylelint issue * Tim CR
* Stylelint added * lint staged addition * Found the right incantation * WIP * Typescript import * stylelint --fix * Stylelint runs clean! * More linting! * paths are hard * linting * Tim Code Review * lint part of build * Better selector class pattern rule * Tim CR * Linting + --fix * Fixing stylelint issue * Tim CR
Solves #13230
Adds stylelint to the app.
Some relevant reading regarding our use of extends: http://8gramgorilla.com/mastering-sass-extends-and-placeholders/