@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 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
- <!-- START_RULE_CODEGEN -->
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
- <!-- END_CODEGEN -->
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
- <!-- START_RULE_CODEGEN -->
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
- <!-- END_CODEGEN -->
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
- Ensures that the codebase uses the global `token` function for colors, rather than hard-coded values. This ruleset is great for codebases that are starting to adopt color tokens and those that have already adopted color tokens. This ruleset also prevents new contributors from accidentally adding hard-coded color values.
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 id="ensure-design-token-usage-do">Do</h3>
38
+ <h3>Examples</h3>
35
39
 
36
- Use the global `token` function, and design tokens.
40
+ Using anything other than design tokens such as hardcoded values or legacy theme colors will be considered violations.
37
41
 
38
- ```jsx
39
- import { token } from '@atlaskit/tokens';
42
+ #### Incorrect
40
43
 
41
- css({
42
- boxShadow: token('elevation.shadow.card'),
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
- ```jsx
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
- <h3 id="ensure-design-token-usage-dont">Don't</h3>
66
+ ## ensure-design-token-usage-spacing
55
67
 
56
- Don't use hard-coded values, such as hexadecimal, CSS colors, or base color values.
68
+ Using spacing,
69
+ typography,
70
+ and shape design tokens results in a harmonious experience for end users.
57
71
 
58
- ```jsx
59
- css({
60
- color: 'red',
61
- ^^^
62
- });
63
- ```
72
+ <h3>Examples</h3>
64
73
 
65
- ```jsx
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
- ```jsx
73
- import { e100 } from '@atlaskit/theme/elevation';
76
+ #### Incorrect
74
77
 
75
- css`
76
- ${e100};
77
- ^^^^
78
- `;
78
+ ```js
79
+ css({ padding: 'red' });
80
+ ^^^
81
+ css({ margin: gridSize() });
82
+ ^^^^^^^^^^
79
83
  ```
80
84
 
81
- ```jsx
82
- import { B100 } from '@atlaskit/theme/colors';
85
+ #### Correct
83
86
 
84
- css({
85
- color: B100,
86
- ^^^^
87
- });
87
+ ```js
88
+ import { token } from '@atlaskit/tokens';
89
+
90
+ css({ padding: token('space.100') });
88
91
  ```
89
92
 
90
- ## ensure-design-token-usage-spacing
93
+ <h3>Options</h3>
91
94
 
92
- Ensures that the codebase uses the global `token` function for spacing, rather than hard-coded values. This ruleset is great for codebases that are starting to adopt space tokens and those that have already adopted space tokens. This ruleset also prevents new contributors from accidentally adding hard-coded space values.
95
+ This rule comes with options to aid in migrating to design tokens.
93
96
 
94
- <h3 id="ensure-design-token-usage-spacing-do">Do</h3>
97
+ #### shouldEnforceFallbacks
95
98
 
96
- Use the global `token` function, and design tokens.
99
+ When `true` the rule will add in stub fallbacks when choosing a suggestion in your IDE.
97
100
 
98
- ```jsx
99
- import { token } from '@atlaskit/tokens';
101
+ ## icon-label
100
102
 
101
- css({
102
- padding: token('space.200'),
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
- ```jsx
107
- import { token } from '@atlaskit/tokens';
106
+ <h3>Examples</h3>
108
107
 
109
- css`
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
- <h3 id="ensure-design-token-usage-spacing-dont">Don't</h3>
110
+ #### Incorrect
115
111
 
116
- Don't use hard-coded values, such as pixel values, relative units, or legacy `gridSize` functions.
112
+ ```js
113
+ import ActivityIcon from '@atlaskit/icon/glyph/activity'
117
114
 
118
- ```jsx
119
- css({
120
- padding: '8px',
121
- ^^^
122
- });
123
- ```
115
+ <ActivityIcon>
116
+ ^^^^^^^^^^^^^^ missing `label` prop
124
117
 
125
- ```jsx
126
- css({
127
- paddingLeft: gridSize(),
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
- ## no-deprecated-design-token-usage
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
- Will catch deprecated token usage and autofix a replacement.
136
+ <ButtonItem iconBefore={<ActivityIcon label="">}>
137
+ My activity
138
+ </ButtonItem>
139
+ ```
135
140
 
136
- It's recommended to set this rule to "warn" on error to allow for new and old tokens to exist side-by-side for the duration of the deprecation period and avoid big-bang migrations.
141
+ ## no-banned-imports
137
142
 
138
- Once the deprecation period is over for a token, it will be moved into a `deleted` state, at which point the counterpart of this rule `eslint-plugin-design-system/no-unsafe-design-token-usage` will begin to throw errors.
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
- Run `eslint --fix` to automatically apply replacement tokens.
145
+ <h3>Examples</h3>
141
146
 
142
- <h3 id="no-deprecated-design-token-usage-dont">Don't</h3>
147
+ Anything that is considered private or experimental will be marked as violations.
143
148
 
144
- Don't use deprecated tokens.
149
+ #### Incorrect
145
150
 
146
- ```jsx
147
- import { token } from '@atlaskit/tokens';
151
+ ```ts
152
+ import noop from '@atlaskit/ds-lib/noop';
153
+ ^^^^^^^^^^^^^^^^^^^^^
148
154
 
149
- css({
150
- color: token('i.am.deprecated'), // will warn on deprecated tokens
151
- });
155
+ import { Text } from '@atlaskit/ds-explorations';
156
+ ^^^^^^^^^^^^^^^^^^^^^^^^^
152
157
  ```
153
158
 
154
- ## no-unsafe-design-token-usage
159
+ ## no-deprecated-apis
155
160
 
156
- Ensures usages of the `token` function are done correctly, so that current token names are being used, and the resulting `var(--some-token)` statements aren't being used. This ruleset is great for codebases that have already adopted tokens.
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 id="no-unsafe-design-token-usage-do">Do</h3>
163
+ <h3>Examples</h3>
159
164
 
160
- Use the `token` function and token naming functions correctly.
165
+ Anything that can be used as props from Atlassian Design System components can be violations when marked as deprecated.
161
166
 
162
- ```jsx
163
- import { token } from '@atlaskit/tokens';
167
+ #### Incorrect
164
168
 
165
- css({
166
- boxShadow: token('elevation.shadow.card'),
167
- });
169
+ ```tsx
170
+ <ButtonItem cssFn={cssFn()} />
171
+ ^^^^
172
+
173
+ <Drawer overrides={overrides} />
174
+ ^^^^^^^^^
168
175
  ```
169
176
 
170
- ```jsx
171
- import { token } from '@atlaskit/tokens';
177
+ <h3>Options</h3>
172
178
 
173
- css`
174
- color: ${(token('color.text.highemphasis'), N20)};
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
- <h3 id="no-unsafe-design-token-usage-dont">Don't</h3>
183
+ #### deprecatedConfig
179
184
 
180
- Don’t use outdated token names, or use tokens without the `token` function.
185
+ The following fields can be defined in the config:
181
186
 
182
- ```jsx
183
- const textColor = 'red';
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
- css({
186
- color: textColor,
187
- ^^^^^^^^^
188
- });
192
+ ```json
193
+ {
194
+ "cssFn": [
195
+ {
196
+ "moduleSpecifier": "@atlaskit/menu"
197
+ }
198
+ ]
199
+ }
189
200
  ```
190
201
 
191
- ```jsx
192
- css({
193
- boxShadow: '0px 1px 1px var(--ds-accent-subtleBlue)',
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
- ## icon-label
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
- Enforces accessible usage of icon labels when composed with other Design System components.
225
+ ```js
226
+ import { configs, filterActionableDeprecations } from '@atlaskit/eslint-plugin-design-system';
227
+ import packageJson from './package.json';
201
228
 
202
- <h3 id="icon-label-do">Do</h3>
229
+ rules: {
230
+ '@atlaskit/design-system/no-deprecated-api': ['error', {
231
+ 'deprecatedConfig': filterActionableDeprecations(configs.deprecatedConfig, packageJson),
232
+ }]
233
+ }
234
+ ```
203
235
 
204
- Use the icon label prop to ensure accessibility of Design System icons.
236
+ ## no-deprecated-design-token-usage
205
237
 
206
- ```jsx
207
- import ActivityIcon from '@atlaskit/icon/glyph/activity'
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
- <ActivityIcon label="Activity">
210
- ```
241
+ <h3>Examples</h3>
211
242
 
212
- ```jsx
213
- import ActivityIcon from '@atlaskit/icon/glyph/activity'
243
+ This rule will mark usage of deprecated design tokens as violations.
214
244
 
215
- <Button iconLeft={<ActivityIcon label="Activity">} />
216
- ```
245
+ <h3>Incorrect</h3>
217
246
 
218
- ```jsx
219
- import ActivityIcon from '@atlaskit/icon/glyph/activity'
247
+ ```js
248
+ import { token } from '@atlaskit/tokens';
220
249
 
221
- <ButtonItem iconBefore={<ActivityIcon label="">}>
222
- My activity
223
- </ButtonItem>
250
+ css({ color: token('i.am.deprecated') });
251
+ ^^^^^^^^^^^^^^^
252
+ css({ color: token('i.am.a.token') });
253
+ ^^^^^^^^^^^^^
224
254
  ```
225
255
 
226
- <h3 id="icon-label-dont">Don't</h3>
256
+ <h3>Options</h3>
227
257
 
228
- Don't ignore labels for icons.
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
- ```jsx
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
- <ActivityIcon>
234
- ^^^^^^^^^^^^^^ missing `label` prop
235
- ```
262
+ Running `eslint --fix` will automatically apply replacement tokens if present.
236
263
 
237
- ```jsx
238
- import ActivityIcon from '@atlaskit/icon/glyph/activity'
264
+ ## no-deprecated-imports
239
265
 
240
- <Button iconLeft={<ActivityIcon label="">} />
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
- ```jsx
245
- import ActivityIcon from '@atlaskit/icon/glyph/activity'
268
+ <h3>Examples</h3>
246
269
 
247
- <ButtonItem iconBefore={<ActivityIcon label="">}>
248
- ^^^^^ label should not be defined
249
- My activity
250
- </ButtonItem>
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
- ## no-banned-imports
281
+ <h3>Options</h3>
254
282
 
255
- Prevents usage of private or experimental Atlassian Design System packages.
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
- <h3 id="no-banned-imports-dont">Don't</h3>
287
+ #### deprecatedConfig
258
288
 
259
- Don't import or use private or experimental ADS packages.
289
+ The following fields can be defined in the config:
260
290
 
261
- ```ts
262
- import noop from '@atlaskit/ds-lib/noop';
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
- ```ts
267
- import { Text } from '@atlaskit/ds-explorations';
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-deprecated-api-usage
327
+ ## no-margin
272
328
 
273
- Ensures usage of current Atlassian Design System APIs.
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 id="no-deprecated-api-usage-do">Do</h3>
332
+ <h3>Examples</h3>
276
333
 
277
- ```jsx
278
- import { SomeElement } from 'some-other-library';
334
+ This rule will mark all margin use as violations.
279
335
 
280
- const Element = () => <SomeElement cssFn={cssFn()} />;
336
+ #### Incorrect
337
+
338
+ ```tsx
339
+ css({ margin: '10px' });
281
340
  ```
282
341
 
283
- ```jsx
284
- import { ButtonItem } from '@atlaskit/menu';
342
+ #### Correct
285
343
 
286
- const Element = () => <ButtonItem />;
344
+ ```tsx
345
+ css({ gap: token('spacing.100') });
287
346
  ```
288
347
 
289
- ```jsx
290
- import Drawer from '@atlaskit/drawer';
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
- const Element = () => <Drawer />;
293
- ```
352
+ <h3>Examples</h3>
294
353
 
295
- <h3 id="no-deprecated-api-usage-dont">Don't</h3>
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
- ```jsx
298
- import { ButtonItem } from '@atlaskit/menu';
357
+ <h3>Incorrect</h3>
299
358
 
300
- const Element = () => (
301
- <ButtonItem cssFn={cssFn()} />
302
- ^^^^
303
- );
304
- ```
359
+ ```js
360
+ const textColor = 'red';
305
361
 
306
- ```jsx
307
- import Drawer from '@atlaskit/drawer';
362
+ css({ color: textColor });
363
+ ^^^^^^^^^ must be a string literal
364
+ ```
308
365
 
309
- const Element = () => (
310
- <Drawer overrides={overrides} />
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
- ## no-deprecated-imports
371
+ <h3>Correct</h3>
316
372
 
317
- Ensures usage of current Atlassian Design System dependencies.
373
+ ```js
374
+ import { token } from '@atlaskit/tokens';
318
375
 
319
- <h3 id="no-deprecated-imports-do">Do</h3>
376
+ css({ boxShadow: token('elevation.shadow.card') });
320
377
 
321
- ```ts
322
- import Modal from '@atlaskit/modal-dialog';
378
+ css`
379
+ color: ${(token('color.text.highemphasis'), N20)};
380
+ `;
323
381
  ```
324
382
 
325
- ```ts
326
- import { ButtonItem } from '@atlaskit/menu';
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
- <h3 id="no-deprecated-imports-dont">Don't</h3>
412
+ #### Correct
330
413
 
331
- ```ts
332
- import Item from '@atlaskit/item';
333
- ^^^^^^^^^^^^^^
414
+ ```js
415
+ <Box />
334
416
  ```
335
417
 
336
- ```ts
337
- import GlobalNav from '@atlaskit/global-navigation';
338
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
418
+ ```js
419
+ <Component>
420
+ <Box css={someStyles}></Box>
421
+ </Component>
339
422
  ```
340
423
 
341
424
  ## use-visually-hidden
342
425
 
343
- This rule makes Design System consumers aware of existing solutions.
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 id="use-visually-hidden-do">Do</h3>
428
+ <h3>Examples</h3>
346
429
 
347
- ```jsx
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
- <h3 id="use-visually-hidden-dont">Don't</h3>
432
+ #### Incorrect
352
433
 
353
- ```jsx
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
- ```jsx
370
- import styled from '@emotion/styled';
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
- ```jsx
386
- import { visuallyHidden } from '@atlaskit/theme/constants';
453
+ #### Correct
387
454
 
388
- const VisuallyHidden = styled.span`${visuallyHidden()}`;
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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-design-system",
3
- "version": "4.19.0",
3
+ "version": "4.20.0",
4
4
  "sideEffects": false
5
5
  }
@@ -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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-design-system",
3
- "version": "4.19.0",
3
+ "version": "4.20.0",
4
4
  "sideEffects": false
5
5
  }
@@ -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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-design-system",
3
- "version": "4.19.0",
3
+ "version": "4.20.0",
4
4
  "sideEffects": false
5
5
  }
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.19.0",
4
+ "version": "4.20.0",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "publishConfig": {
7
7
  "registry": "https://registry.npmjs.org/"