@navikt/aksel-stylelint 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +101 -0
- package/dist/index.css +4104 -0
- package/dist/index.js +8 -0
- package/dist/recommended.js +8 -0
- package/dist/rules/aksel-design-token-exists/index.js +103 -0
- package/dist/rules/aksel-design-token-exists/index.test.js +111 -0
- package/dist/rules/aksel-design-token-exists/utils.js +76 -0
- package/dist/rules/aksel-no-class-override/index.js +40 -0
- package/dist/rules/aksel-no-class-override/index.test.js +53 -0
- package/dist/rules/aksel-no-internal-tokens/index.js +54 -0
- package/dist/rules/aksel-no-internal-tokens/index.test.js +102 -0
- package/dist/rules/index.js +14 -0
- package/dist/tokens.json +363 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Aksel stylelint rules & plugins
|
|
2
|
+
|
|
3
|
+
## aksel-design-token-exists
|
|
4
|
+
|
|
5
|
+
This rule checks that if you use one of the reserved token prefixes `--a-` or `--ac-` then the token itself _must_ be provided by design system itself.
|
|
6
|
+
|
|
7
|
+
❌ Incorrect:
|
|
8
|
+
|
|
9
|
+
```css
|
|
10
|
+
html h1 {
|
|
11
|
+
--a-my-own-color-bg-hover: #f2f2f2;
|
|
12
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
13
|
+
background-color: var(--a-my-own-color-bg-hover, #ffffff);
|
|
14
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
✅ Correct:
|
|
19
|
+
|
|
20
|
+
```css
|
|
21
|
+
html h1 {
|
|
22
|
+
background-color: var(--ac-accordion-header-bg-hover, #ffffff);
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## aksel-no-internal-tokens
|
|
27
|
+
|
|
28
|
+
Disallows use or override of internal Aksel design tokens. Internal tokens are not supposed to be used outside the design system, and they may be changed or removed without warning. Be aware that the rule simply checks the prefix of the token, and not if it actually exists in the design system. Even if it doesn't exist, using design system prefixes should be avoided.
|
|
29
|
+
|
|
30
|
+
❌ Incorrect:
|
|
31
|
+
|
|
32
|
+
```css
|
|
33
|
+
a {
|
|
34
|
+
--__ac-some-property: pink;
|
|
35
|
+
} ^^^^^^^^^^^^^^^^^^^^
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```css
|
|
39
|
+
a {
|
|
40
|
+
color: var(--__ac-some-property);
|
|
41
|
+
} ^^^^^^^^^^^^^^^^^^^^
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
✅ Correct:
|
|
45
|
+
|
|
46
|
+
```css
|
|
47
|
+
a {
|
|
48
|
+
--some-property: pink;
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```css
|
|
53
|
+
a {
|
|
54
|
+
color: var(--some-property);
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## aksel-no-class-override
|
|
59
|
+
|
|
60
|
+
Warns when trying to override design system styling by using class selectors that starts with "navds-" or "navdsi-". Overriding styles in the design system is discouraged. We want to have consistent look and feel across applications. Even if it seems to work fine now, it might break on subsequent updates in the design system.
|
|
61
|
+
|
|
62
|
+
❌ Incorrect:
|
|
63
|
+
|
|
64
|
+
```css
|
|
65
|
+
.navds-button {
|
|
66
|
+
^^^^^^^^^^^^^
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```css
|
|
71
|
+
.some-class .navdsi-header {
|
|
72
|
+
} ^^^^^^^^^^^^^^
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
✅ Correct:
|
|
76
|
+
|
|
77
|
+
```css
|
|
78
|
+
.some-class {
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
# Install
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
yarn add -D @navikt/aksel-stylelint
|
|
86
|
+
npm install -D @navikt/aksel-stylelint
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### How to configure
|
|
90
|
+
|
|
91
|
+
It should be sufficient for most cases to extend the recommended defaults.
|
|
92
|
+
|
|
93
|
+
```js
|
|
94
|
+
"stylelint": {
|
|
95
|
+
"extends": [
|
|
96
|
+
...
|
|
97
|
+
"@navikt/aksel-stylelint/recommended"
|
|
98
|
+
],
|
|
99
|
+
...
|
|
100
|
+
}
|
|
101
|
+
```
|