Skip to content

Commit 65ae2f1

Browse files
feat: introduce stylelint plugin (nodejs#7644)
* feat: introduce stylelint plugin * Update packages/ui-components/stylelint.plugin.mjs Co-authored-by: Aviv Keller <[email protected]> Signed-off-by: Caner Akdas <[email protected]> * refactor: review suggestions * chore(docs): align Tailwind usage with official documentation in docs and Stylelint config --------- Signed-off-by: Caner Akdas <[email protected]> Co-authored-by: Aviv Keller <[email protected]>
1 parent 9d0b590 commit 65ae2f1

File tree

14 files changed

+278
-31
lines changed

14 files changed

+278
-31
lines changed

COLLABORATOR_GUIDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,14 @@ Finally, if you're unfamiliar with how to use Tailwind or how to use Tailwind wi
187187
#### Guidelines when writing CSS
188188

189189
- We use camelCase for defining CSS classes
190-
- We use Tailwind's `@apply` selector to apply Tailwind Tokens
190+
- We use Tailwind's `@apply` selector to apply Tailwind utility classes
191191
- We discourage the usage of any plain CSS styles and tokens, when in doubt ask for help
192-
- We require that you define one Tailwind Token per line, just as shown on the example above, since this improves readability
192+
- We require that you define one Tailwind utility class per line, just as shown on the example above, since this improves readability
193193
- Only write CSS within CSS Modules, avoid writing CSS within JavaScript files
194194

195195
> \[!NOTE]\
196196
> Tailwind is already configured for this repository. You don't need to import any Tailwind module within your CSS module.\
197-
> You can apply Tailwind Tokens with Tailwind's `@apply` CSS rule. [Read more about applying Tailwind classes with `@apply`](https://tailwindcss.com/docs/functions-and-directives#apply).
197+
> You can apply Tailwind utility classes with Tailwind's `@apply` CSS rule. [Read more about applying Tailwind utility classes with `@apply`](https://tailwindcss.com/docs/functions-and-directives#apply).
198198
199199
> \[!IMPORTANT]\
200200
> When using IDEs such as Visual Studio Code, we recommend installing the official [Stylelint](https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint)

apps/site/.stylelintrc.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ const ONLY_ALLOW_CAMEL_CASE_SELECTORS = [
2323

2424
export default {
2525
extends: ['stylelint-config-standard'],
26-
plugins: ['stylelint-order', 'stylelint-selector-bem-pattern'],
26+
plugins: [
27+
'stylelint-order',
28+
'stylelint-selector-bem-pattern',
29+
'@node-core/ui-components/stylelint/one-utility-class-per-line.mjs',
30+
],
2731
rules: {
2832
// Enforces Element Class Names to be camelCase
2933
'selector-class-pattern': ONLY_ALLOW_CAMEL_CASE_SELECTORS,
@@ -45,5 +49,6 @@ export default {
4549
'import-notation': 'string',
4650
// Allow the `@apply` at rule as its part of Tailwind
4751
'at-rule-no-deprecated': [true, { ignoreAtRules: CUSTOM_AT_RULES }],
52+
'nodejs/one-utility-class-per-line': true,
4853
},
4954
};

apps/site/layouts/layouts.module.css

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,14 @@
137137

138138
&:nth-of-type(2) {
139139
@apply flex
140-
min-w-0
141-
max-w-full
142-
flex-[1_1]
143-
flex-col
144-
items-center
145-
gap-4
146-
md:max-w-2xl
147-
lg:max-w-3xl;
140+
min-w-0
141+
max-w-full
142+
flex-[1_1]
143+
flex-col
144+
items-center
145+
gap-4
146+
md:max-w-2xl
147+
lg:max-w-3xl;
148148

149149
> div {
150150
@apply w-full
@@ -154,9 +154,9 @@
154154

155155
> p {
156156
@apply text-center
157-
text-sm
158-
text-neutral-800
159-
dark:text-neutral-200;
157+
text-sm
158+
text-neutral-800
159+
dark:text-neutral-200;
160160
}
161161
}
162162
}

apps/site/styles/effects.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
& img {
2323
@apply h-auto
24-
w-24
25-
md:w-48;
24+
w-24
25+
md:w-48;
2626
}
2727
}

packages/ui-components/.stylelintrc.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ const ONLY_ALLOW_CAMEL_CASE_SELECTORS = [
2323

2424
export default {
2525
extends: ['stylelint-config-standard'],
26-
plugins: ['stylelint-order', 'stylelint-selector-bem-pattern'],
26+
plugins: [
27+
'stylelint-order',
28+
'stylelint-selector-bem-pattern',
29+
'./stylelint/one-utility-class-per-line.mjs',
30+
],
2731
rules: {
2832
// Enforces Element Class Names to be camelCase
2933
'selector-class-pattern': ONLY_ALLOW_CAMEL_CASE_SELECTORS,
@@ -45,6 +49,7 @@ export default {
4549
'import-notation': 'string',
4650
// Allow the `@apply` at rule as its part of Tailwind
4751
'at-rule-no-deprecated': [true, { ignoreAtRules: CUSTOM_AT_RULES }],
52+
'nodejs/one-utility-class-per-line': true,
4853
// We need complex `:not()` for headings with anchor
4954
'selector-not-notation': null,
5055
},

packages/ui-components/Common/Blockquote/index.module.css

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
@reference "../../styles/index.css";
22

33
.wrapper {
4-
@apply flex max-w-2xl flex-col items-start gap-4 self-stretch border-l-2 border-green-600 py-2 pl-5 text-lg font-semibold text-neutral-900 dark:border-green-400 dark:text-white;
4+
@apply flex
5+
max-w-2xl
6+
flex-col
7+
items-start
8+
gap-4
9+
self-stretch
10+
border-l-2
11+
border-green-600
12+
py-2
13+
pl-5
14+
text-lg
15+
font-semibold
16+
text-neutral-900
17+
dark:border-green-400
18+
dark:text-white;
519

620
& cite {
7-
@apply font-regular text-base not-italic;
21+
@apply font-regular
22+
text-base
23+
not-italic;
824

925
&::before {
1026
@apply content-['—_'];
Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,41 @@
11
@reference "../../../styles/index.css";
22

33
.item {
4-
@apply flex max-w-fit items-center gap-5 truncate text-sm font-medium;
4+
@apply flex
5+
max-w-fit
6+
items-center
7+
gap-5
8+
truncate
9+
text-sm
10+
font-medium;
511

612
&:last-child {
713
@apply w-full;
814
}
915

1016
a {
11-
@apply shrink grow;
17+
@apply shrink
18+
grow;
1219
}
1320

1421
&,
1522
> a,
1623
> a:hover {
17-
@apply text-neutral-800 motion-safe:transition-colors dark:text-neutral-200;
24+
@apply text-neutral-800
25+
motion-safe:transition-colors
26+
dark:text-neutral-200;
1827
}
1928

2029
&.visuallyHidden {
2130
@apply hidden;
2231
}
2332

2433
.separator {
25-
@apply size-4 max-w-fit shrink-0 grow text-neutral-600 dark:text-neutral-400;
34+
@apply size-4
35+
max-w-fit
36+
shrink-0
37+
grow
38+
text-neutral-600
39+
dark:text-neutral-400;
2640
}
2741
}
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
@reference "../../../styles/index.css";
22

33
.link {
4-
@apply max-w-fit truncate;
4+
@apply max-w-fit
5+
truncate;
56

67
&.active {
7-
@apply rounded bg-green-600 px-2 py-1 font-semibold text-white motion-safe:transition-colors dark:text-white;
8+
@apply rounded
9+
bg-green-600
10+
px-2
11+
py-1
12+
font-semibold
13+
text-white
14+
motion-safe:transition-colors
15+
dark:text-white;
816

917
&:hover {
10-
@apply bg-green-700 text-white;
18+
@apply bg-green-700
19+
text-white;
1120
}
1221
}
1322
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
@reference "../../../styles/index.css";
22

33
.list {
4-
@apply xs:w-full flex w-screen gap-5 px-6;
4+
@apply xs:w-full
5+
flex
6+
w-screen
7+
gap-5
8+
px-6;
59
}

packages/ui-components/Common/LanguageDropDown/index.module.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929

3030
> div {
3131
@apply max-h-80
32-
w-48 overflow-y-auto;
32+
w-48
33+
overflow-y-auto;
3334
}
3435
}
3536

@@ -47,5 +48,6 @@
4748
}
4849

4950
.currentDropDown {
50-
@apply bg-green-600 text-white;
51+
@apply bg-green-600
52+
text-white;
5153
}

0 commit comments

Comments
 (0)