@navikt/aksel-stylelint 3.0.0-beta.1 → 3.0.0-beta.10
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 +56 -19
- package/dist/deprecations.js +9 -0
- package/dist/index.css +604 -93
- package/dist/internal-tokens.json +48 -0
- package/dist/recommended.js +3 -0
- package/dist/rules/aksel-design-token-exists/index.js +38 -70
- package/dist/rules/aksel-design-token-exists/index.test.js +25 -21
- package/dist/rules/aksel-design-token-no-component-reference/index.js +49 -0
- package/dist/rules/aksel-design-token-no-component-reference/index.test.js +53 -0
- package/dist/rules/aksel-design-token-no-global-override/index.js +47 -0
- package/dist/rules/aksel-design-token-no-global-override/index.test.js +66 -0
- package/dist/rules/aksel-no-class-override/index.js +1 -1
- package/dist/rules/aksel-no-class-override copy/index.js +40 -0
- package/dist/rules/aksel-no-class-override copy/index.test.js +53 -0
- package/dist/rules/aksel-no-deprecated-classes/index.js +40 -0
- package/dist/rules/aksel-no-deprecated-classes/index.test.js +60 -0
- package/dist/rules/aksel-no-internal-tokens/index.js +1 -1
- package/dist/rules/index.js +6 -0
- package/dist/tokens.json +19 -3
- package/dist/utils.js +115 -0
- package/package.json +10 -4
package/README.md
CHANGED
|
@@ -1,8 +1,42 @@
|
|
|
1
1
|
# Aksel stylelint rules & plugins
|
|
2
2
|
|
|
3
|
+
This stylelint plugin is useful when working with the [Aksel design system](https://aksel.nav.no/).
|
|
4
|
+
|
|
5
|
+
It is designed to be useful for both _internal_ and _external_ developers, so _everyone_ should install this 🙌.
|
|
6
|
+
|
|
7
|
+
> **Warning**
|
|
8
|
+
> The version of this plugin **_MUST MATCH_** the version of the other design system packages used in your project for the linting to make sense!
|
|
9
|
+
> Otherwise you are very likely to get _incorrect_ errors that tell you to use the wrong token names.
|
|
10
|
+
|
|
11
|
+
# Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
yarn add -D @navikt/aksel-stylelint
|
|
15
|
+
npm install -D @navikt/aksel-stylelint
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### How to configure
|
|
19
|
+
|
|
20
|
+
It should be sufficient for most cases to extend the recommended defaults.
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
"stylelint": {
|
|
24
|
+
"extends": [
|
|
25
|
+
...
|
|
26
|
+
"@navikt/aksel-stylelint/recommended"
|
|
27
|
+
],
|
|
28
|
+
...
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
3
32
|
## aksel-design-token-exists
|
|
4
33
|
|
|
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
|
|
34
|
+
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.
|
|
35
|
+
|
|
36
|
+
In addition it checks that you:
|
|
37
|
+
|
|
38
|
+
- don't **_reference_** a component level token. As they are only supposed to be overridden.
|
|
39
|
+
- don't **_override_** a global level token. As they are only supposed to be referenced.
|
|
6
40
|
|
|
7
41
|
❌ Incorrect:
|
|
8
42
|
|
|
@@ -12,6 +46,8 @@ html h1 {
|
|
|
12
46
|
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
13
47
|
background-color: var(--a-my-own-color-bg-hover, #ffffff);
|
|
14
48
|
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
49
|
+
stroke: var(--ac-button-loader-stroke));
|
|
50
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
15
51
|
}
|
|
16
52
|
```
|
|
17
53
|
|
|
@@ -19,7 +55,8 @@ html h1 {
|
|
|
19
55
|
|
|
20
56
|
```css
|
|
21
57
|
html h1 {
|
|
22
|
-
background-color: var(--
|
|
58
|
+
background-color: var(--a-surface-default, #ffffff);
|
|
59
|
+
--ac-button-loader-stroke: lawngreen;
|
|
23
60
|
}
|
|
24
61
|
```
|
|
25
62
|
|
|
@@ -30,13 +67,13 @@ Disallows use or override of internal Aksel design tokens. Internal tokens are n
|
|
|
30
67
|
❌ Incorrect:
|
|
31
68
|
|
|
32
69
|
```css
|
|
33
|
-
a {
|
|
70
|
+
a {
|
|
34
71
|
--__ac-some-property: pink;
|
|
35
72
|
} ^^^^^^^^^^^^^^^^^^^^
|
|
36
73
|
```
|
|
37
74
|
|
|
38
75
|
```css
|
|
39
|
-
a {
|
|
76
|
+
a {
|
|
40
77
|
color: var(--__ac-some-property);
|
|
41
78
|
} ^^^^^^^^^^^^^^^^^^^^
|
|
42
79
|
```
|
|
@@ -79,23 +116,23 @@ Warns when trying to override design system styling by using class selectors tha
|
|
|
79
116
|
}
|
|
80
117
|
```
|
|
81
118
|
|
|
82
|
-
|
|
119
|
+
## aksel-no-deprecated-classes
|
|
83
120
|
|
|
84
|
-
|
|
85
|
-
yarn add -D @navikt/aksel-stylelint
|
|
86
|
-
npm install -D @navikt/aksel-stylelint
|
|
87
|
-
```
|
|
121
|
+
Warns when you try to use deprecated class names.
|
|
88
122
|
|
|
89
|
-
|
|
123
|
+
❌ Incorrect:
|
|
90
124
|
|
|
91
|
-
|
|
125
|
+
```css
|
|
126
|
+
.navdsi-deprecated-example {
|
|
127
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
128
|
+
}
|
|
129
|
+
```
|
|
92
130
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
],
|
|
99
|
-
...
|
|
100
|
-
}
|
|
131
|
+
✅ Correct:
|
|
132
|
+
|
|
133
|
+
```css
|
|
134
|
+
.guaranteed-not-deprecated {
|
|
135
|
+
}
|
|
101
136
|
```
|
|
137
|
+
|
|
138
|
+
🐛 Found a bug? https://github.com/navikt/aksel/issues
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deprecations = void 0;
|
|
4
|
+
exports.deprecations = [
|
|
5
|
+
{
|
|
6
|
+
classes: ["navdsi-deprecated-example", "navdsi-other-deprecated-example"],
|
|
7
|
+
message: "Removed in vX.X.X, see documentation [link] for more information",
|
|
8
|
+
},
|
|
9
|
+
];
|