@atlaskit/eslint-plugin-design-system 4.19.0 → 4.20.0
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/CHANGELOG.md +12 -0
- package/README.md +2 -2
- package/constellation/index/usage.mdx +291 -222
- package/dist/cjs/rules/ensure-design-token-usage-spacing/utils.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/rules/ensure-design-token-usage-spacing/utils.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/rules/ensure-design-token-usage-spacing/utils.js +1 -1
- package/dist/esm/version.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-design-system
|
|
2
2
|
|
|
3
|
+
## 4.20.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`fa50be73bfe`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fa50be73bfe) - [ux] Spacing rule now also looks at and attempts to parse additional properties.
|
|
8
|
+
|
|
9
|
+
## 4.19.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`0047d204889`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0047d204889) - Docs are now generated from source.
|
|
14
|
+
|
|
3
15
|
## 4.19.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ module.exports = {
|
|
|
44
44
|
|
|
45
45
|
## Rules
|
|
46
46
|
|
|
47
|
-
<!--
|
|
47
|
+
<!-- START_RULE_TABLE_CODEGEN -->
|
|
48
48
|
<!-- @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen -->
|
|
49
49
|
|
|
50
50
|
| Rule | Description | Recommended | Fixable | Suggestions |
|
|
@@ -61,4 +61,4 @@ module.exports = {
|
|
|
61
61
|
| <a href="./src/rules/use-primitives/README.md">use-primitives</a> | Encourage the usage of primitives components. | | Yes | |
|
|
62
62
|
| <a href="./src/rules/use-visually-hidden/README.md">use-visually-hidden</a> | Enforce usage of the visually hidden component. | Yes | Yes | |
|
|
63
63
|
|
|
64
|
-
<!--
|
|
64
|
+
<!-- END_RULE_TABLE_CODEGEN -->
|
|
@@ -8,7 +8,7 @@ This plugin contains rules that should be used when working with the [Atlassian
|
|
|
8
8
|
|
|
9
9
|
## Rules
|
|
10
10
|
|
|
11
|
-
<!--
|
|
11
|
+
<!-- START_RULE_TABLE_CODEGEN -->
|
|
12
12
|
<!-- @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen -->
|
|
13
13
|
|
|
14
14
|
| Rule | Description | Recommended | Fixable | Suggestions |
|
|
@@ -25,333 +25,415 @@ This plugin contains rules that should be used when working with the [Atlassian
|
|
|
25
25
|
| <a href="#use-primitives">use-primitives</a> | Encourage the usage of primitives components. | | Yes | |
|
|
26
26
|
| <a href="#use-visually-hidden">use-visually-hidden</a> | Enforce usage of the visually hidden component. | Yes | Yes | |
|
|
27
27
|
|
|
28
|
-
<!--
|
|
28
|
+
<!-- END_RULE_TABLE_CODEGEN -->
|
|
29
|
+
|
|
30
|
+
<!-- START_RULE_CONTENT_CODEGEN -->
|
|
31
|
+
<!-- @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen -->
|
|
29
32
|
|
|
30
33
|
## ensure-design-token-usage
|
|
31
34
|
|
|
32
|
-
|
|
35
|
+
Using color design tokens enables our experiences to be themed and harmonious.
|
|
36
|
+
All experiences must use these design tokens otherwise when switching between themes unexpected incidents can occur where not all of the UI is themed.
|
|
33
37
|
|
|
34
|
-
<h3
|
|
38
|
+
<h3>Examples</h3>
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
Using anything other than design tokens such as hardcoded values or legacy theme colors will be considered violations.
|
|
37
41
|
|
|
38
|
-
|
|
39
|
-
import { token } from '@atlaskit/tokens';
|
|
42
|
+
#### Incorrect
|
|
40
43
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
+
```js
|
|
45
|
+
import { e100 } from '@atlaskit/theme/elevation';
|
|
46
|
+
import { B100 } from '@atlaskit/theme/colors';
|
|
47
|
+
|
|
48
|
+
css({ color: 'red' });
|
|
49
|
+
^^^
|
|
50
|
+
css({ boxShadow: '0px 1px 1px #161A1D32' });
|
|
51
|
+
^^^^^^^^^
|
|
52
|
+
css`${e100};`;
|
|
53
|
+
^^^^
|
|
54
|
+
css({ color: B100 });
|
|
55
|
+
^^^^
|
|
44
56
|
```
|
|
45
57
|
|
|
46
|
-
|
|
58
|
+
#### Correct
|
|
59
|
+
|
|
60
|
+
```js
|
|
47
61
|
import { token } from '@atlaskit/tokens';
|
|
48
62
|
|
|
49
|
-
css
|
|
50
|
-
color: ${token('color.text.highemphasis')};
|
|
51
|
-
`;
|
|
63
|
+
css({ boxShadow: token('elevation.shadow.card') });
|
|
52
64
|
```
|
|
53
65
|
|
|
54
|
-
|
|
66
|
+
## ensure-design-token-usage-spacing
|
|
55
67
|
|
|
56
|
-
|
|
68
|
+
Using spacing,
|
|
69
|
+
typography,
|
|
70
|
+
and shape design tokens results in a harmonious experience for end users.
|
|
57
71
|
|
|
58
|
-
|
|
59
|
-
css({
|
|
60
|
-
color: 'red',
|
|
61
|
-
^^^
|
|
62
|
-
});
|
|
63
|
-
```
|
|
72
|
+
<h3>Examples</h3>
|
|
64
73
|
|
|
65
|
-
|
|
66
|
-
css({
|
|
67
|
-
boxShadow: '0px 1px 1px #161A1D32',
|
|
68
|
-
^^^^^^^^^
|
|
69
|
-
})
|
|
70
|
-
```
|
|
74
|
+
Using anything other than design tokens such as hardcoded values or legacy theme colors will be considered violations.
|
|
71
75
|
|
|
72
|
-
|
|
73
|
-
import { e100 } from '@atlaskit/theme/elevation';
|
|
76
|
+
#### Incorrect
|
|
74
77
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
```js
|
|
79
|
+
css({ padding: 'red' });
|
|
80
|
+
^^^
|
|
81
|
+
css({ margin: gridSize() });
|
|
82
|
+
^^^^^^^^^^
|
|
79
83
|
```
|
|
80
84
|
|
|
81
|
-
|
|
82
|
-
import { B100 } from '@atlaskit/theme/colors';
|
|
85
|
+
#### Correct
|
|
83
86
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
});
|
|
87
|
+
```js
|
|
88
|
+
import { token } from '@atlaskit/tokens';
|
|
89
|
+
|
|
90
|
+
css({ padding: token('space.100') });
|
|
88
91
|
```
|
|
89
92
|
|
|
90
|
-
|
|
93
|
+
<h3>Options</h3>
|
|
91
94
|
|
|
92
|
-
|
|
95
|
+
This rule comes with options to aid in migrating to design tokens.
|
|
93
96
|
|
|
94
|
-
|
|
97
|
+
#### shouldEnforceFallbacks
|
|
95
98
|
|
|
96
|
-
|
|
99
|
+
When `true` the rule will add in stub fallbacks when choosing a suggestion in your IDE.
|
|
97
100
|
|
|
98
|
-
|
|
99
|
-
import { token } from '@atlaskit/tokens';
|
|
101
|
+
## icon-label
|
|
100
102
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
});
|
|
104
|
-
```
|
|
103
|
+
Icon labels are used to describe what the icon is so the visually impaired can be described what the UI element is.
|
|
104
|
+
There are cases where icons should have labels as well as cases where they shouldn't be labelled.
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
import { token } from '@atlaskit/tokens';
|
|
106
|
+
<h3>Examples</h3>
|
|
108
107
|
|
|
109
|
-
|
|
110
|
-
gap: ${token('space.100')};
|
|
111
|
-
`;
|
|
112
|
-
```
|
|
108
|
+
This rule will find violations for when an icon label is or isn't needed when composed with other Design System components.
|
|
113
109
|
|
|
114
|
-
|
|
110
|
+
#### Incorrect
|
|
115
111
|
|
|
116
|
-
|
|
112
|
+
```js
|
|
113
|
+
import ActivityIcon from '@atlaskit/icon/glyph/activity'
|
|
117
114
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
padding: '8px',
|
|
121
|
-
^^^
|
|
122
|
-
});
|
|
123
|
-
```
|
|
115
|
+
<ActivityIcon>
|
|
116
|
+
^^^^^^^^^^^^^^ missing `label` prop
|
|
124
117
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
118
|
+
<Button iconLeft={<ActivityIcon label="">} />
|
|
119
|
+
^^^^^ label should be defined
|
|
120
|
+
|
|
121
|
+
<ButtonItem iconBefore={<ActivityIcon label="">}>
|
|
122
|
+
^^^^^ label should not be defined
|
|
123
|
+
My activity
|
|
124
|
+
</ButtonItem>
|
|
130
125
|
```
|
|
131
126
|
|
|
132
|
-
|
|
127
|
+
#### Correct
|
|
128
|
+
|
|
129
|
+
```js
|
|
130
|
+
import ActivityIcon from '@atlaskit/icon/glyph/activity'
|
|
131
|
+
|
|
132
|
+
<ActivityIcon label="Activity">
|
|
133
|
+
|
|
134
|
+
<Button iconLeft={<ActivityIcon label="Activity">} />
|
|
133
135
|
|
|
134
|
-
|
|
136
|
+
<ButtonItem iconBefore={<ActivityIcon label="">}>
|
|
137
|
+
My activity
|
|
138
|
+
</ButtonItem>
|
|
139
|
+
```
|
|
135
140
|
|
|
136
|
-
|
|
141
|
+
## no-banned-imports
|
|
137
142
|
|
|
138
|
-
|
|
143
|
+
Using private or experimental packages is dangerous as they are not supported across major versions meaning you will not be able to migrate easily causing friction for yourself and the Atlassian Design System team.
|
|
139
144
|
|
|
140
|
-
|
|
145
|
+
<h3>Examples</h3>
|
|
141
146
|
|
|
142
|
-
|
|
147
|
+
Anything that is considered private or experimental will be marked as violations.
|
|
143
148
|
|
|
144
|
-
|
|
149
|
+
#### Incorrect
|
|
145
150
|
|
|
146
|
-
```
|
|
147
|
-
import
|
|
151
|
+
```ts
|
|
152
|
+
import noop from '@atlaskit/ds-lib/noop';
|
|
153
|
+
^^^^^^^^^^^^^^^^^^^^^
|
|
148
154
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
});
|
|
155
|
+
import { Text } from '@atlaskit/ds-explorations';
|
|
156
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
152
157
|
```
|
|
153
158
|
|
|
154
|
-
## no-
|
|
159
|
+
## no-deprecated-apis
|
|
155
160
|
|
|
156
|
-
|
|
161
|
+
Props across the Atlassian Design System can be deprecated when they are deemed no-longer fit for purporse or dangerous and risk effective use at scale.
|
|
157
162
|
|
|
158
|
-
<h3
|
|
163
|
+
<h3>Examples</h3>
|
|
159
164
|
|
|
160
|
-
|
|
165
|
+
Anything that can be used as props from Atlassian Design System components can be violations when marked as deprecated.
|
|
161
166
|
|
|
162
|
-
|
|
163
|
-
import { token } from '@atlaskit/tokens';
|
|
167
|
+
#### Incorrect
|
|
164
168
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
169
|
+
```tsx
|
|
170
|
+
<ButtonItem cssFn={cssFn()} />
|
|
171
|
+
^^^^
|
|
172
|
+
|
|
173
|
+
<Drawer overrides={overrides} />
|
|
174
|
+
^^^^^^^^^
|
|
168
175
|
```
|
|
169
176
|
|
|
170
|
-
|
|
171
|
-
import { token } from '@atlaskit/tokens';
|
|
177
|
+
<h3>Options</h3>
|
|
172
178
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
```
|
|
179
|
+
The rule can take one option: `deprecatedConfig`,
|
|
180
|
+
if not provided the rule will use an internal config.
|
|
181
|
+
If provided the rule will use the passed in config instead.
|
|
177
182
|
|
|
178
|
-
|
|
183
|
+
#### deprecatedConfig
|
|
179
184
|
|
|
180
|
-
|
|
185
|
+
The following fields can be defined in the config:
|
|
181
186
|
|
|
182
|
-
|
|
183
|
-
|
|
187
|
+
- `deprecatedProp`, which is the deprecated props. Each prop has the following fields:
|
|
188
|
+
- `moduleSpecifier`, which is the module specifier of the package in which the prop was deprecated. For example: `@atlaskit/button`.
|
|
189
|
+
- `namedSpecifier` **(optional)**, which is an array of named specifiers of the package in which the prop was deprecated. For example: `Button`.
|
|
190
|
+
- `actionableVersion` **(optional)**, which is the version of the package in which the prop can be actioned on. For example: `1.0.0`.
|
|
184
191
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
192
|
+
```json
|
|
193
|
+
{
|
|
194
|
+
"cssFn": [
|
|
195
|
+
{
|
|
196
|
+
"moduleSpecifier": "@atlaskit/menu"
|
|
197
|
+
}
|
|
198
|
+
]
|
|
199
|
+
}
|
|
189
200
|
```
|
|
190
201
|
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
202
|
+
```js
|
|
203
|
+
import { configs } from '@atlaskit/eslint-plugin-design-system';
|
|
204
|
+
|
|
205
|
+
module.exports = {
|
|
206
|
+
rules: {
|
|
207
|
+
'@atlaskit/design-system/no-deprecated-api': [
|
|
208
|
+
'error',
|
|
209
|
+
{
|
|
210
|
+
deprecatedConfig: {
|
|
211
|
+
cssFn: [
|
|
212
|
+
{
|
|
213
|
+
moduleSpecifier: '@atlaskit/menu',
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
},
|
|
220
|
+
};
|
|
196
221
|
```
|
|
197
222
|
|
|
198
|
-
|
|
223
|
+
The plugin also provides a `filterActionableDeprecations` util function that accepts the `deprecated APIs config` and your root `package.json` as params and will filter the default deprecated APIs config based on the package versions installed.
|
|
199
224
|
|
|
200
|
-
|
|
225
|
+
```js
|
|
226
|
+
import { configs, filterActionableDeprecations } from '@atlaskit/eslint-plugin-design-system';
|
|
227
|
+
import packageJson from './package.json';
|
|
201
228
|
|
|
202
|
-
|
|
229
|
+
rules: {
|
|
230
|
+
'@atlaskit/design-system/no-deprecated-api': ['error', {
|
|
231
|
+
'deprecatedConfig': filterActionableDeprecations(configs.deprecatedConfig, packageJson),
|
|
232
|
+
}]
|
|
233
|
+
}
|
|
234
|
+
```
|
|
203
235
|
|
|
204
|
-
|
|
236
|
+
## no-deprecated-design-token-usage
|
|
205
237
|
|
|
206
|
-
|
|
207
|
-
|
|
238
|
+
Using deprecated design tokens is dangerous as they will eventually be deleted after the sunset period.
|
|
239
|
+
This rule helps you move to non-deprecated design tokens.
|
|
208
240
|
|
|
209
|
-
<
|
|
210
|
-
```
|
|
241
|
+
<h3>Examples</h3>
|
|
211
242
|
|
|
212
|
-
|
|
213
|
-
import ActivityIcon from '@atlaskit/icon/glyph/activity'
|
|
243
|
+
This rule will mark usage of deprecated design tokens as violations.
|
|
214
244
|
|
|
215
|
-
<
|
|
216
|
-
```
|
|
245
|
+
<h3>Incorrect</h3>
|
|
217
246
|
|
|
218
|
-
```
|
|
219
|
-
import
|
|
247
|
+
```js
|
|
248
|
+
import { token } from '@atlaskit/tokens';
|
|
220
249
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
250
|
+
css({ color: token('i.am.deprecated') });
|
|
251
|
+
^^^^^^^^^^^^^^^
|
|
252
|
+
css({ color: token('i.am.a.token') });
|
|
253
|
+
^^^^^^^^^^^^^
|
|
224
254
|
```
|
|
225
255
|
|
|
226
|
-
<h3
|
|
256
|
+
<h3>Options</h3>
|
|
227
257
|
|
|
228
|
-
|
|
258
|
+
It's recommended to set this rule to "warn" to allow for new and old tokens to exist side-by-side for the duration of the deprecation period and avoid big-bang migrations.
|
|
229
259
|
|
|
230
|
-
|
|
231
|
-
import ActivityIcon from '@atlaskit/icon/glyph/activity'
|
|
260
|
+
Once the deprecation period is over for a design token it will be moved into `deleted` state at which point the counterpart of this rule `no-unsafe-design-token-usage` will mark violations as errors.
|
|
232
261
|
|
|
233
|
-
|
|
234
|
-
^^^^^^^^^^^^^^ missing `label` prop
|
|
235
|
-
```
|
|
262
|
+
Running `eslint --fix` will automatically apply replacement tokens if present.
|
|
236
263
|
|
|
237
|
-
|
|
238
|
-
import ActivityIcon from '@atlaskit/icon/glyph/activity'
|
|
264
|
+
## no-deprecated-imports
|
|
239
265
|
|
|
240
|
-
|
|
241
|
-
^^^^^ label should be defined
|
|
242
|
-
```
|
|
266
|
+
Packages across the Atlassian Design System can be deprecated when they are deemed no-longer fit for purporse or dangerous and risk effective use at scale.
|
|
243
267
|
|
|
244
|
-
|
|
245
|
-
import ActivityIcon from '@atlaskit/icon/glyph/activity'
|
|
268
|
+
<h3>Examples</h3>
|
|
246
269
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
270
|
+
This rule will mark usage of deprecated modules as violations.
|
|
271
|
+
|
|
272
|
+
#### Incorrect
|
|
273
|
+
|
|
274
|
+
```ts
|
|
275
|
+
import Item from '@atlaskit/item';
|
|
276
|
+
^^^^^^^^^^^^^^
|
|
277
|
+
import GlobalNav from '@atlaskit/global-navigation';
|
|
278
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
251
279
|
```
|
|
252
280
|
|
|
253
|
-
|
|
281
|
+
<h3>Options</h3>
|
|
254
282
|
|
|
255
|
-
|
|
283
|
+
The rule can take one option: `deprecatedConfig`,
|
|
284
|
+
if not provided the rule will use an internal config.
|
|
285
|
+
If provided the rule will use the passed in config instead.
|
|
256
286
|
|
|
257
|
-
|
|
287
|
+
#### deprecatedConfig
|
|
258
288
|
|
|
259
|
-
|
|
289
|
+
The following fields can be defined in the config:
|
|
260
290
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
291
|
+
- `packagePath`, which is the name of the package. For example: `@atlaskit/navigation-next` and `@atlaskit/navigation`.
|
|
292
|
+
With the package path as the key, you can either provide the values as:
|
|
293
|
+
- `message` **(optional)**, the message to display when the deprecated packages path is used. For example: `multi-select is deprecated. Please use '@atlaskit/select' instead.`
|
|
294
|
+
Or as:
|
|
295
|
+
- `imports`, which is an array of named imports to be deprecated. Each named import has the following fields:
|
|
296
|
+
- `importName`, which is the name of the import to be deprecated. For example: `assistive` and `visuallyHidden`.
|
|
297
|
+
- `message` **(optional)**, which is the message to display when the deprecated import is used. For example: `The assistive mixin is deprecated. Please use `@atlaskit/visually-hidden` instead.`.
|
|
298
|
+
|
|
299
|
+
```json
|
|
300
|
+
{
|
|
301
|
+
"@atlaskit/navigation-next": {
|
|
302
|
+
"message": "navigation-next is deprecated. Please use '@atlaskit/atlassian-navigation' instead."
|
|
303
|
+
}
|
|
304
|
+
}
|
|
264
305
|
```
|
|
265
306
|
|
|
266
|
-
```
|
|
267
|
-
import
|
|
268
|
-
|
|
307
|
+
```js
|
|
308
|
+
import packageJson from './package.json';
|
|
309
|
+
|
|
310
|
+
module.exports = {
|
|
311
|
+
rules: {
|
|
312
|
+
'@atlaskit/design-system/no-deprecated-imports': [
|
|
313
|
+
'error',
|
|
314
|
+
{
|
|
315
|
+
deprecatedConfig: {
|
|
316
|
+
'@atlaskit/navigation-next': {
|
|
317
|
+
message:
|
|
318
|
+
"navigation-next is deprecated. Please use '@atlaskit/atlassian-navigation' instead.",
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
],
|
|
323
|
+
},
|
|
324
|
+
};
|
|
269
325
|
```
|
|
270
326
|
|
|
271
|
-
## no-
|
|
327
|
+
## no-margin
|
|
272
328
|
|
|
273
|
-
|
|
329
|
+
Using margins to define spacing results in components that can't be readily reused in other contexts breaking the composition model.
|
|
330
|
+
Instead defining spacing in parents with flex and grid using the `gap` property will result in more resilient experiences.
|
|
274
331
|
|
|
275
|
-
<h3
|
|
332
|
+
<h3>Examples</h3>
|
|
276
333
|
|
|
277
|
-
|
|
278
|
-
import { SomeElement } from 'some-other-library';
|
|
334
|
+
This rule will mark all margin use as violations.
|
|
279
335
|
|
|
280
|
-
|
|
336
|
+
#### Incorrect
|
|
337
|
+
|
|
338
|
+
```tsx
|
|
339
|
+
css({ margin: '10px' });
|
|
281
340
|
```
|
|
282
341
|
|
|
283
|
-
|
|
284
|
-
import { ButtonItem } from '@atlaskit/menu';
|
|
342
|
+
#### Correct
|
|
285
343
|
|
|
286
|
-
|
|
344
|
+
```tsx
|
|
345
|
+
css({ gap: token('spacing.100') });
|
|
287
346
|
```
|
|
288
347
|
|
|
289
|
-
|
|
290
|
-
|
|
348
|
+
## no-unsafe-design-token-usage
|
|
349
|
+
|
|
350
|
+
Using design tokens in an unsafe way risks the health of the system and will effect how fast your codebase can migrate between versions.
|
|
291
351
|
|
|
292
|
-
|
|
293
|
-
```
|
|
352
|
+
<h3>Examples</h3>
|
|
294
353
|
|
|
295
|
-
|
|
354
|
+
This rule will mark design token usage that is not statically and locally analyzable,
|
|
355
|
+
as well as design tokens that are considered deleted.
|
|
296
356
|
|
|
297
|
-
|
|
298
|
-
import { ButtonItem } from '@atlaskit/menu';
|
|
357
|
+
<h3>Incorrect</h3>
|
|
299
358
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
^^^^
|
|
303
|
-
);
|
|
304
|
-
```
|
|
359
|
+
```js
|
|
360
|
+
const textColor = 'red';
|
|
305
361
|
|
|
306
|
-
|
|
307
|
-
|
|
362
|
+
css({ color: textColor });
|
|
363
|
+
^^^^^^^^^ must be a string literal
|
|
364
|
+
```
|
|
308
365
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
);
|
|
366
|
+
```js
|
|
367
|
+
css({ boxShadow: '0px 1px 1px var(--ds-accent-subtleBlue)' });
|
|
368
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^ must use the token() function
|
|
313
369
|
```
|
|
314
370
|
|
|
315
|
-
|
|
371
|
+
<h3>Correct</h3>
|
|
316
372
|
|
|
317
|
-
|
|
373
|
+
```js
|
|
374
|
+
import { token } from '@atlaskit/tokens';
|
|
318
375
|
|
|
319
|
-
|
|
376
|
+
css({ boxShadow: token('elevation.shadow.card') });
|
|
320
377
|
|
|
321
|
-
|
|
322
|
-
|
|
378
|
+
css`
|
|
379
|
+
color: ${(token('color.text.highemphasis'), N20)};
|
|
380
|
+
`;
|
|
323
381
|
```
|
|
324
382
|
|
|
325
|
-
|
|
326
|
-
|
|
383
|
+
<h3>Options</h3>
|
|
384
|
+
|
|
385
|
+
This rule comes with options to aid in migrating to design tokens.
|
|
386
|
+
|
|
387
|
+
#### shouldEnforceFallbacks
|
|
388
|
+
|
|
389
|
+
When `true` the rule will mark token function usage as violations when fallbacks aren't defined.
|
|
390
|
+
When `false` the rule will mark token function usage as violations when fallbacks are defined.
|
|
391
|
+
|
|
392
|
+
## use-primitives
|
|
393
|
+
|
|
394
|
+
Using primitives allows you to delete bespoke component code and replace it with ready made solutions made by the Atlassian Design System Team.
|
|
395
|
+
|
|
396
|
+
<h3>Examples</h3>
|
|
397
|
+
|
|
398
|
+
This rule marks code as violations when it can be replaced 1:1 with a primitive component.
|
|
399
|
+
|
|
400
|
+
#### Incorrect
|
|
401
|
+
|
|
402
|
+
```js
|
|
403
|
+
<div />
|
|
404
|
+
^^^^^^^
|
|
405
|
+
|
|
406
|
+
<Component>
|
|
407
|
+
<div css={someStyles}></div>
|
|
408
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
409
|
+
</Component>
|
|
327
410
|
```
|
|
328
411
|
|
|
329
|
-
|
|
412
|
+
#### Correct
|
|
330
413
|
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
^^^^^^^^^^^^^^
|
|
414
|
+
```js
|
|
415
|
+
<Box />
|
|
334
416
|
```
|
|
335
417
|
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
|
|
418
|
+
```js
|
|
419
|
+
<Component>
|
|
420
|
+
<Box css={someStyles}></Box>
|
|
421
|
+
</Component>
|
|
339
422
|
```
|
|
340
423
|
|
|
341
424
|
## use-visually-hidden
|
|
342
425
|
|
|
343
|
-
|
|
426
|
+
Using the visually hidden component allows you to delete bespoke or legacy theme code and replace it with a ready made solution by the Atlassian Design System Team.
|
|
344
427
|
|
|
345
|
-
<h3
|
|
428
|
+
<h3>Examples</h3>
|
|
346
429
|
|
|
347
|
-
|
|
348
|
-
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
349
|
-
```
|
|
430
|
+
This rule marks code as violations when it can be replaced 1:1 with the visually hidden component.
|
|
350
431
|
|
|
351
|
-
|
|
432
|
+
#### Incorrect
|
|
352
433
|
|
|
353
|
-
```
|
|
434
|
+
```js
|
|
354
435
|
import { css } from '@emotion/core';
|
|
436
|
+
import { visuallyHidden } from '@atlaskit/theme/constants';
|
|
355
437
|
|
|
356
438
|
const visuallyHiddenStyles = css({
|
|
357
439
|
width: '1px',
|
|
@@ -363,28 +445,15 @@ const visuallyHiddenStyles = css({
|
|
|
363
445
|
overflow: 'hidden',
|
|
364
446
|
whiteSpace: 'nowrap',
|
|
365
447
|
});
|
|
366
|
-
^^^^
|
|
367
|
-
```
|
|
368
448
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
const VisuallyHidden = styled.span`
|
|
373
|
-
width: 1px;
|
|
374
|
-
height: 1px;
|
|
375
|
-
padding: 0;
|
|
376
|
-
position: absolute;
|
|
377
|
-
border: 0;
|
|
378
|
-
clip: rect(1px, 1px, 1px, 1px);
|
|
379
|
-
overflow: hidden;
|
|
380
|
-
whiteSpace: nowrap;
|
|
381
|
-
`;
|
|
382
|
-
^^^^
|
|
449
|
+
const VisuallyHidden = styled.span`${visuallyHidden()}`;
|
|
450
|
+
^^^^^^^^^^^^^^
|
|
383
451
|
```
|
|
384
452
|
|
|
385
|
-
|
|
386
|
-
import { visuallyHidden } from '@atlaskit/theme/constants';
|
|
453
|
+
#### Correct
|
|
387
454
|
|
|
388
|
-
|
|
389
|
-
|
|
455
|
+
```js
|
|
456
|
+
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
390
457
|
```
|
|
458
|
+
|
|
459
|
+
<!-- END_RULE_CONTENT_CODEGEN -->
|
|
@@ -28,7 +28,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
28
28
|
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
29
29
|
var _tokensRaw = require("@atlaskit/tokens/tokens-raw");
|
|
30
30
|
var typographyProperties = ['fontSize', 'fontWeight', 'fontFamily', 'lineHeight'];
|
|
31
|
-
var properties = ['padding', 'paddingBlock', 'paddingInline', 'paddingLeft', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'marginInline', 'marginInlineStart', 'marginInlineEnd', 'marginBlock', 'marginBlockStart', 'marginBlockEnd', 'margin', 'gap', 'rowGap', 'gridRowGap', 'columnGap', 'gridColumnGap'];
|
|
31
|
+
var properties = ['padding', 'paddingBlock', 'paddingInline', 'paddingLeft', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'marginInline', 'marginInlineStart', 'marginInlineEnd', 'marginBlock', 'marginBlockStart', 'marginBlockEnd', 'margin', 'gap', 'rowGap', 'gridRowGap', 'columnGap', 'gridColumnGap', 'top', 'left', 'right', 'bottom', 'inlineStart', 'inlineEnd', 'blockStart', 'blockEnd', 'outline-offset'];
|
|
32
32
|
/**
|
|
33
33
|
* Currently we have a wide range of experimental spacing tokens that we are testing.
|
|
34
34
|
* We only want transforms to apply to the stable scale values, not the rest.
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { callExpression, identifier, insertAtStartOfFile, insertImportDeclaration, isNodeOfType, literal } from 'eslint-codemod-utils';
|
|
2
2
|
import { spacing as spacingScale, typography as typographyTokens } from '@atlaskit/tokens/tokens-raw';
|
|
3
3
|
const typographyProperties = ['fontSize', 'fontWeight', 'fontFamily', 'lineHeight'];
|
|
4
|
-
const properties = ['padding', 'paddingBlock', 'paddingInline', 'paddingLeft', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'marginInline', 'marginInlineStart', 'marginInlineEnd', 'marginBlock', 'marginBlockStart', 'marginBlockEnd', 'margin', 'gap', 'rowGap', 'gridRowGap', 'columnGap', 'gridColumnGap'];
|
|
4
|
+
const properties = ['padding', 'paddingBlock', 'paddingInline', 'paddingLeft', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'marginInline', 'marginInlineStart', 'marginInlineEnd', 'marginBlock', 'marginBlockStart', 'marginBlockEnd', 'margin', 'gap', 'rowGap', 'gridRowGap', 'columnGap', 'gridColumnGap', 'top', 'left', 'right', 'bottom', 'inlineStart', 'inlineEnd', 'blockStart', 'blockEnd', 'outline-offset'];
|
|
5
5
|
/**
|
|
6
6
|
* Currently we have a wide range of experimental spacing tokens that we are testing.
|
|
7
7
|
* We only want transforms to apply to the stable scale values, not the rest.
|
package/dist/es2019/version.json
CHANGED
|
@@ -2,7 +2,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
2
2
|
import { callExpression, identifier, insertAtStartOfFile, insertImportDeclaration, isNodeOfType, literal } from 'eslint-codemod-utils';
|
|
3
3
|
import { spacing as spacingScale, typography as typographyTokens } from '@atlaskit/tokens/tokens-raw';
|
|
4
4
|
var typographyProperties = ['fontSize', 'fontWeight', 'fontFamily', 'lineHeight'];
|
|
5
|
-
var properties = ['padding', 'paddingBlock', 'paddingInline', 'paddingLeft', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'marginInline', 'marginInlineStart', 'marginInlineEnd', 'marginBlock', 'marginBlockStart', 'marginBlockEnd', 'margin', 'gap', 'rowGap', 'gridRowGap', 'columnGap', 'gridColumnGap'];
|
|
5
|
+
var properties = ['padding', 'paddingBlock', 'paddingInline', 'paddingLeft', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'marginInline', 'marginInlineStart', 'marginInlineEnd', 'marginBlock', 'marginBlockStart', 'marginBlockEnd', 'margin', 'gap', 'rowGap', 'gridRowGap', 'columnGap', 'gridColumnGap', 'top', 'left', 'right', 'bottom', 'inlineStart', 'inlineEnd', 'blockStart', 'blockEnd', 'outline-offset'];
|
|
6
6
|
/**
|
|
7
7
|
* Currently we have a wide range of experimental spacing tokens that we are testing.
|
|
8
8
|
* We only want transforms to apply to the stable scale values, not the rest.
|
package/dist/esm/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/eslint-plugin-design-system",
|
|
3
3
|
"description": "The essential plugin for use with the Atlassian Design System.",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.20.0",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"registry": "https://registry.npmjs.org/"
|