Skip to content
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

Merged
merged 29 commits into from
Aug 29, 2022
Merged

🪟🧹 Stylelint #15452

merged 29 commits into from
Aug 29, 2022

Conversation

krishnaglick
Copy link
Contributor

@krishnaglick krishnaglick commented Aug 9, 2022

Solves #13230

Adds stylelint to the app.

Some relevant reading regarding our use of extends: http://8gramgorilla.com/mastering-sass-extends-and-placeholders/

@github-actions github-actions bot added area/platform issues related to the platform area/frontend Related to the Airbyte webapp labels Aug 9, 2022
@krishnaglick krishnaglick linked an issue Aug 9, 2022 that may be closed by this pull request
@krishnaglick krishnaglick added area/frontend technical-debt issues to fix code smell and removed area/platform issues related to the platform labels Aug 9, 2022
@github-actions github-actions bot added the area/platform issues related to the platform label Aug 9, 2022
"font-family-name-quotes": null,
"scss/dollar-variable-empty-line-before": null,
"scss/dollar-variable-pattern": ".*",
"scss/percent-placeholder-pattern": ".*",
Copy link
Contributor Author

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.

@@ -12,7 +12,8 @@ def commonConfigs = [
'package.json',
'package-lock.json',
'tsconfig.json',
'.prettierrc.js'
'.prettierrc.js',
'.stylelintrc'
Copy link
Contributor Author

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.

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

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.

Copy link
Contributor

@timroes timroes Aug 11, 2022

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%);
Copy link
Contributor Author

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%;
Copy link
Contributor Author

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

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

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
Copy link
Contributor Author

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;
Copy link
Contributor Author

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.

@krishnaglick krishnaglick marked this pull request as ready for review August 10, 2022 14:34
@krishnaglick krishnaglick requested a review from a team as a code owner August 10, 2022 14:34
@krishnaglick krishnaglick changed the title Stylelint 🧹 Stylelint Aug 10, 2022
Copy link
Contributor

@teallarson teallarson left a 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

@krishnaglick krishnaglick changed the title 🧹 Stylelint 🪟🧹 Stylelint Aug 11, 2022
@krishnaglick krishnaglick requested a review from timroes August 12, 2022 14:17
@krishnaglick krishnaglick requested a review from dizel852 August 22, 2022 14:18
@@ -104,8 +105,15 @@ task copyNginx(type: Copy) {
into "build/docker/bin/nginx"
}

task lint(type: NpmTask) {
dependsOn npmInstall
args = ['run', 'lint']
Copy link
Contributor

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.

Copy link
Contributor Author

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?

@krishnaglick krishnaglick requested a review from timroes August 22, 2022 17:57
Copy link
Contributor

@dizel852 dizel852 left a 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

@@ -23,6 +23,7 @@ node {
npm_run_build {
inputs.files commonConfigs
inputs.file '.eslintrc'
inputs.file '.stylelintrc'
Copy link
Contributor

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.

Copy link
Contributor Author

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 :)

Copy link
Contributor

@timroes timroes left a 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.

@krishnaglick krishnaglick merged commit 78ca6c7 into master Aug 29, 2022
@krishnaglick krishnaglick deleted the kc/stylelint branch August 29, 2022 16:31
rodireich pushed a commit that referenced this pull request Aug 29, 2022
* 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
robbinhan pushed a commit to robbinhan/airbyte that referenced this pull request Sep 29, 2022
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend Related to the Airbyte webapp area/platform issues related to the platform technical-debt issues to fix code smell
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add stylelint to the webapp
4 participants