@atlaskit/eslint-plugin-design-system 10.10.0 → 10.10.2

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.
Files changed (76) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/rules/no-legacy-icons/checks.js +63 -67
  3. package/dist/cjs/rules/no-legacy-icons/helpers.js +29 -24
  4. package/dist/cjs/rules/no-legacy-icons/index.js +4 -5
  5. package/dist/cjs/rules/use-latest-xcss-syntax/transformers/style-property/supported.js +3 -2
  6. package/dist/cjs/rules/use-tokens-space/transformers/style-property/supported.js +3 -2
  7. package/dist/cjs/rules/use-visually-hidden/fix-jsx.js +4 -2
  8. package/dist/cjs/rules/use-visually-hidden/fix-vanilla.js +4 -2
  9. package/dist/es2019/rules/no-legacy-icons/checks.js +20 -33
  10. package/dist/es2019/rules/no-legacy-icons/helpers.js +24 -21
  11. package/dist/es2019/rules/no-legacy-icons/index.js +4 -5
  12. package/dist/es2019/rules/use-latest-xcss-syntax/transformers/style-property/supported.js +3 -2
  13. package/dist/es2019/rules/use-tokens-space/transformers/style-property/supported.js +3 -2
  14. package/dist/es2019/rules/use-visually-hidden/fix-jsx.js +3 -2
  15. package/dist/es2019/rules/use-visually-hidden/fix-vanilla.js +3 -2
  16. package/dist/esm/rules/no-legacy-icons/checks.js +64 -68
  17. package/dist/esm/rules/no-legacy-icons/helpers.js +28 -23
  18. package/dist/esm/rules/no-legacy-icons/index.js +4 -5
  19. package/dist/esm/rules/use-latest-xcss-syntax/transformers/style-property/supported.js +3 -2
  20. package/dist/esm/rules/use-tokens-space/transformers/style-property/supported.js +3 -2
  21. package/dist/esm/rules/use-visually-hidden/fix-jsx.js +3 -2
  22. package/dist/esm/rules/use-visually-hidden/fix-vanilla.js +3 -2
  23. package/dist/types/rules/no-legacy-icons/helpers.d.ts +3 -13
  24. package/dist/types/rules/use-latest-xcss-syntax/transformers/style-property/supported.d.ts +2 -2
  25. package/dist/types/rules/use-tokens-space/transformers/style-property/supported.d.ts +2 -2
  26. package/dist/types/rules/use-visually-hidden/fix-jsx.d.ts +2 -2
  27. package/dist/types/rules/use-visually-hidden/fix-vanilla.d.ts +2 -2
  28. package/dist/types-ts4.5/rules/no-legacy-icons/helpers.d.ts +3 -13
  29. package/dist/types-ts4.5/rules/use-latest-xcss-syntax/transformers/style-property/supported.d.ts +2 -2
  30. package/dist/types-ts4.5/rules/use-tokens-space/transformers/style-property/supported.d.ts +2 -2
  31. package/dist/types-ts4.5/rules/use-visually-hidden/fix-jsx.d.ts +2 -2
  32. package/dist/types-ts4.5/rules/use-visually-hidden/fix-vanilla.d.ts +2 -2
  33. package/package.json +2 -2
  34. package/constellation/consistent-css-prop-usage/usage.mdx +0 -210
  35. package/constellation/ensure-design-token-usage/usage.mdx +0 -77
  36. package/constellation/ensure-design-token-usage-preview/usage.mdx +0 -6
  37. package/constellation/icon-label/usage.mdx +0 -41
  38. package/constellation/index/props.mdx +0 -30
  39. package/constellation/index/usage.mdx +0 -57
  40. package/constellation/no-banned-imports/usage.mdx +0 -19
  41. package/constellation/no-css-tagged-template-expression/usage.mdx +0 -71
  42. package/constellation/no-custom-icons/usage.mdx +0 -36
  43. package/constellation/no-deprecated-apis/usage.mdx +0 -82
  44. package/constellation/no-deprecated-design-token-usage/usage.mdx +0 -30
  45. package/constellation/no-deprecated-imports/usage.mdx +0 -66
  46. package/constellation/no-direct-use-of-web-platform-drag-and-drop/usage.mdx +0 -149
  47. package/constellation/no-empty-styled-expression/usage.mdx +0 -82
  48. package/constellation/no-exported-css/usage.mdx +0 -55
  49. package/constellation/no-exported-keyframes/usage.mdx +0 -55
  50. package/constellation/no-html-anchor/usage.mdx +0 -46
  51. package/constellation/no-html-button/usage.mdx +0 -52
  52. package/constellation/no-invalid-css-map/usage.mdx +0 -210
  53. package/constellation/no-keyframes-tagged-template-expression/usage.mdx +0 -80
  54. package/constellation/no-legacy-icons/usage.mdx +0 -42
  55. package/constellation/no-margin/usage.mdx +0 -21
  56. package/constellation/no-nested-styles/usage.mdx +0 -47
  57. package/constellation/no-physical-properties/usage.mdx +0 -53
  58. package/constellation/no-styled-tagged-template-expression/usage.mdx +0 -135
  59. package/constellation/no-unsafe-design-token-usage/usage.mdx +0 -50
  60. package/constellation/no-unsafe-style-overrides/usage.mdx +0 -52
  61. package/constellation/no-unsupported-drag-and-drop-libraries/usage.mdx +0 -23
  62. package/constellation/prefer-primitives/usage.mdx +0 -32
  63. package/constellation/use-button-group-label/usage.mdx +0 -60
  64. package/constellation/use-drawer-label/usage.mdx +0 -55
  65. package/constellation/use-heading/usage.mdx +0 -31
  66. package/constellation/use-heading-level-in-spotlight-card/usage.mdx +0 -21
  67. package/constellation/use-href-in-link-item/usage.mdx +0 -19
  68. package/constellation/use-latest-xcss-syntax/usage.mdx +0 -33
  69. package/constellation/use-latest-xcss-syntax-typography/usage.mdx +0 -34
  70. package/constellation/use-menu-section-title/usage.mdx +0 -55
  71. package/constellation/use-popup-label/usage.mdx +0 -56
  72. package/constellation/use-primitives/usage.mdx +0 -78
  73. package/constellation/use-primitives-text/usage.mdx +0 -35
  74. package/constellation/use-tokens-space/usage.mdx +0 -34
  75. package/constellation/use-tokens-typography/usage.mdx +0 -55
  76. package/constellation/use-visually-hidden/usage.mdx +0 -35
@@ -1,52 +0,0 @@
1
- # no-html-button
2
-
3
- Don't use native HTML buttons. The Atlassian Design System provides ready-made button components
4
- that include event tracking, ensure accessible implementations, and provide access to ADS styling
5
- features like design tokens.
6
-
7
- Use Atlassian Design System components such as the [Button component](/components/button/) when
8
- suitable. There may also be other components better-suited depending on the use case. If these
9
- components aren't suitable, use the [Pressable primitive](/components/primitives/pressable/) which
10
- helps you build custom buttons with Atlassian Design System styling.
11
-
12
- ## Examples
13
-
14
- This rule marks code as violations when it finds native HTML button elements.
15
-
16
- ### Incorrect
17
-
18
- ```jsx
19
- <button>
20
- ^^^^^^ Using a native HTML `<button>`
21
- Hello, World!
22
- </button>
23
-
24
- <div role="button" tabIndex="0">
25
- ^^^^^^^^^^^^^ Using `role="button"` to create buttons
26
- Hello, World!
27
- </div>
28
-
29
- <input type="button" value="Button" />
30
- ^^^^^^^^^^^^^ Using a `<input>` as a button
31
-
32
- <input type="submit" value="Submit" />
33
- ^^^^^^^^^^^^^ Using a `<input>` as a button
34
-
35
- <input type="reset" value="Reset" />
36
- ^^^^^^^^^^^^ Using a `<input>` as a button
37
-
38
- <input type="image" alt="Submit" src="/submit-button.png" />
39
- ^^^^^^^^^^^^ Using a `<input>` as a button
40
- ```
41
-
42
- ### Correct
43
-
44
- ```jsx
45
- import Pressable from '@atlaskit/primitives/pressable';
46
-
47
- <Pressable>Hello, World!</Pressable>;
48
-
49
- import Button from '@atlaskit/button/new';
50
-
51
- <Button>Hello, World!</Button>;
52
- ```
@@ -1,210 +0,0 @@
1
- # no-invalid-css-map
2
-
3
- Ensure that all usages of the `cssMap` API are valid, and enforces the format of the object that is
4
- passed to `cssMap`.
5
-
6
- Please refer to the [Compiled documentation](https://compiledcssinjs.com/docs/api-cssmap) for more
7
- details and some examples.
8
-
9
- Note that this version of the `no-invalid-css-map` rule differs from
10
- `@compiled/eslint-plugin/no-invalid-css-map` in that this will apply to both `@compiled/react` and
11
- `@atlaskit/css`.
12
-
13
- This is intended to be used in conjunction with type checking (through TypeScript).
14
-
15
- ## Examples
16
-
17
- ### Incorrect
18
-
19
- ```tsx
20
- import React from 'react';
21
- import { cssMap } from '@compiled/react';
22
-
23
- // cssMap needs to be declared in the top-most scope.
24
- // (not within a function, class, etc.)
25
-
26
- const Foo = () => {
27
- const bar = cssMap({
28
- danger: {
29
- color: 'red',
30
- },
31
- });
32
- };
33
- ```
34
-
35
- ```tsx
36
- import React from 'react';
37
- import { cssMap } from '@compiled/react';
38
- import { importedVariable, importedFunction } from 'another-package';
39
-
40
- // Cannot use imported functions as values in cssMap.
41
-
42
- const myVariable = importedFunction();
43
-
44
- const styles = cssMap({
45
- danger: {
46
- // Both invalid because they rely on an imported function.
47
- color: myVariable,
48
- padding: importedFunction(),
49
- },
50
- });
51
- ```
52
-
53
- ```tsx
54
- import React from 'react';
55
- import { cssMap } from '@compiled/react';
56
-
57
- // Cannot export usages of cssMap.
58
- // Any usages of cssMap must be in the same file.
59
-
60
- export const foo = cssMap({
61
- danger: {
62
- color: 'red',
63
- },
64
- });
65
- ```
66
-
67
- ```tsx
68
- import React from 'react';
69
- import { cssMap } from '@compiled/react';
70
- import { token } from '@atlaskit/tokens';
71
-
72
- // Functions and object methods are not allowed as
73
- // values in cssMap.
74
-
75
- const styles = cssMap({
76
- // Object method
77
- get danger() {
78
- return { color: '#123456' };
79
- },
80
- });
81
-
82
- const styles2 = cssMap({
83
- // Arrow function
84
- danger: () => {
85
- color: '#123456';
86
- },
87
- });
88
-
89
- function customFunction(...args) {
90
- return arguments.join('');
91
- }
92
-
93
- const styles3 = cssMap({
94
- danger: {
95
- // Locally defined function
96
- color: customFunction('red', 'blue'),
97
- backgroundColor: 'red',
98
- },
99
- });
100
- ```
101
-
102
- ```tsx
103
- import React from 'react';
104
- import { cssMap } from '@compiled/react';
105
-
106
- // Spread elements ("...") cannot be used in cssMap.
107
-
108
- const base = {
109
- success: {
110
- color: 'green',
111
- },
112
- };
113
-
114
- const bar = cssMap({
115
- ...base,
116
- danger: {
117
- color: 'red',
118
- },
119
- });
120
- ```
121
-
122
- ### Correct
123
-
124
- ```tsx
125
- import React from 'react';
126
- import { cssMap } from '@compiled/react';
127
-
128
- // Literals (strings, numbers, etc.) are used as values
129
- // in cssMap.
130
-
131
- const styles = cssMap({
132
- danger: {
133
- color: 'red',
134
- backgroundColor: 'red',
135
- },
136
- success: {
137
- color: 'green',
138
- backgroundColor: 'green',
139
- },
140
- });
141
- ```
142
-
143
- ```tsx
144
- import React from 'react';
145
- import { cssMap } from '@compiled/react';
146
-
147
- // A statically evaluable variable (known at build time)
148
- // is used here.
149
-
150
- const bap = 'blue';
151
-
152
- const styles = cssMap({
153
- danger: {
154
- color: bap,
155
- },
156
- });
157
- ```
158
-
159
- ### Options
160
-
161
- #### `allowedFunctionCalls`: [string, string][]
162
-
163
- Normally, this ESLint rule forbids all function calls from being used inside the `cssMap(...)`
164
- function call. For example, this would be invalid using default settings:
165
-
166
- ```tsx
167
- import React from 'react';
168
- import { cssMap } from '@compiled/react';
169
- import { token } from '@atlaskit/tokens';
170
-
171
- const styles = cssMap({
172
- danger: {
173
- color: token('my-color'),
174
- backgroundColor: 'red',
175
- },
176
- success: {
177
- color: 'green',
178
- },
179
- });
180
- ```
181
-
182
- If you would like to whitelist certain functions (e.g. `token` from `@atlaskit/tokens`), you can
183
- include the names of the functions as part of the `allowedFunctionCalls` argument. Each function
184
- should be represented as a two-element array, with the first element being the package the function
185
- is from, and the second element being the name of the function.
186
-
187
- For example, with the below configuration, the above code example would be okay.
188
-
189
- ```tsx
190
- // .eslintrc.js
191
-
192
- // ...
193
- rules: {
194
- '@atlaskit/eslint-plugin-design-system/no-invalid-css-map': [
195
- 'error',
196
- {
197
- allowedFunctionCalls: [
198
- ['@atlaskit/tokens', 'token'],
199
- ]
200
- },
201
- ],
202
- // ...
203
- },
204
- // ...
205
- ```
206
-
207
- Please note that this ESLint rule only supports whitelisting imports in the form
208
- `import { myFunctionOrVariable } from 'my-package'`; we do not currently support whitelisting
209
- default imports, so `import myFunctionOrVariable from 'my-package'` would always be invalid when
210
- used in `cssMap`.
@@ -1,80 +0,0 @@
1
- # no-keyframes-tagged-template-expression
2
-
3
- Disallows any `keyframes` tagged template expressions that originate from a CSS-in-JS library,
4
- including `@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
5
-
6
- Tagged template expressions are difficult to parse correctly (which can lead to more frequent build
7
- failures or invalid CSS generation), have limited type safety, and lack syntax highlighting. These
8
- problems can be avoided by using the preferred call expression syntax instead.
9
-
10
- Thank you to the
11
- [Compiled team for their rule](https://github.com/atlassian-labs/compiled/tree/master/packages/eslint-plugin/src/rules/no-keyframes-tagged-template-expression)
12
- from which this was ported.
13
-
14
- The `--fix` option on the command line automatically fixes problems reported by this rule.
15
-
16
- ## Examples
17
-
18
- ### Incorrect
19
-
20
- ```js
21
- import { keyframes } from '@compiled/react';
22
-
23
- keyframes`to { opacity: 0 }`;
24
-
25
- const fadeOut = keyframes`
26
- from {
27
- opacity: 1;
28
- }
29
- to {
30
- opacity: 0;
31
- }
32
- `;
33
- ```
34
-
35
- ### Correct
36
-
37
- ```js
38
- import { keyframes } from '@compiled/react';
39
-
40
- keyframes({ to: { opacity: 0 } });
41
-
42
- const fadeOut = keyframes({
43
- from: {
44
- opacity: 1,
45
- },
46
- to: {
47
- opacity: 0,
48
- },
49
- });
50
- ```
51
-
52
- ## Options
53
-
54
- ### importSources
55
-
56
- By default, this rule will check `keyframes` usages from:
57
-
58
- - `@atlaskit/css`
59
- - `@atlaskit/primitives`
60
- - `@compiled/react`
61
- - `@emotion/react`
62
- - `@emotion/core`
63
- - `@emotion/styled`
64
- - `styled-components`
65
-
66
- To change this list of libraries, you can define a custom set of `importSources`, which accepts an
67
- array of package names (strings).
68
-
69
- ```tsx
70
- // [{ importSources: ['other-lib'] }]
71
-
72
- import { keyframes } from 'other-lib';
73
-
74
- // Invalid!
75
- export const animation = keyframes``;
76
- ```
77
-
78
- ## Limitations
79
-
80
- - Comments are not fixable
@@ -1,42 +0,0 @@
1
- # no-legacy-icons
2
-
3
- Icons are being updated with new designs, a simplified set of available icons and sizes, as well as
4
- more consistent padding and spacing.
5
-
6
- The new icon components allows your components to align with the new visual language - either by
7
- default, or when enabled via a feature flag.
8
-
9
- ## Examples
10
-
11
- This rule identifies usages of legacy icons from `@atlaskit/icon/glyph` and `@atlaskit/icon-object`,
12
- that aren't yet migrated to the new icon API. Legacy icons are only permitted when passed into a new
13
- "core" or "utility" icon from `@atlaskit/icon` or `@atlassian/icon-lab`, via the
14
- `LEGACY_fallbackIcon` prop.
15
-
16
- ### Incorrect
17
-
18
- ```js
19
- import ActivityIcon from '@atlaskit/icon/glyph/activity'
20
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ legacy icon import
21
-
22
- import { IconButton } from '@atlaskit/button/new'
23
-
24
- <ActivityIcon label="Activity">
25
- ^^^^^^^^^^^^^^^^^^^^^^^ legacy icon
26
-
27
- <IconButton icon={ActivityIcon} label="Activity"/>
28
- ^^^^^^^^^^^^^ legacy icon
29
- ```
30
-
31
- ### Correct
32
-
33
- ```js
34
- import AddIcon from '@atlaskit/icon/core/add';
35
- import { IconButton } from '@atlaskit/button/new';
36
-
37
- <AddIcon label="" />;
38
- <IconButton
39
- icon={(iconProps) => <AddIcon LEGACY_fallbackIcon={AddIconLegacy} {...iconProps} />}
40
- label="Add to Cart"
41
- />;
42
- ```
@@ -1,21 +0,0 @@
1
- # no-margin
2
-
3
- Using margins to define spacing results in components that can't be readily reused in other contexts
4
- breaking the composition model. Instead defining spacing in parents with flex and grid using the
5
- `gap` property will result in more resilient experiences.
6
-
7
- ## Examples
8
-
9
- This rule will mark all margin use as violations.
10
-
11
- ### Incorrect
12
-
13
- ```tsx
14
- css({ margin: '10px' });
15
- ```
16
-
17
- ### Correct
18
-
19
- ```tsx
20
- css({ gap: token('spacing.100') });
21
- ```
@@ -1,47 +0,0 @@
1
- # no-nested-styles
2
-
3
- Disallows using nested styles. Nested styles can change unexpectedly when child markup changes and
4
- result in duplicates when extracting to CSS.
5
-
6
- ## Examples
7
-
8
- This rule checks for nested styles inside `css` objects. This rule has no options.
9
-
10
- ### Incorrect
11
-
12
- ```js
13
- css({
14
- div: {
15
- color: 'red',
16
- },
17
- });
18
- ```
19
-
20
- ```js
21
- css({
22
- '@media (min-width: 480px)': {
23
- color: 'red',
24
- },
25
- });
26
- ```
27
-
28
- ### Correct
29
-
30
- ```js
31
- css({
32
- color: 'red',
33
- ':hover': {
34
- color: 'black',
35
- },
36
- });
37
- ```
38
-
39
- ```js
40
- import { media } from '@atlaskit/primitives';
41
-
42
- css({
43
- [media.above.xs]: {
44
- color: 'red',
45
- },
46
- });
47
- ```
@@ -1,53 +0,0 @@
1
- # no-physical-properties
2
-
3
- Disallows using physical properties. Physical properties prevent correct support for different
4
- reading modes and languages and should be avoided. Rule will autofix applicable physical properties
5
- to instead use
6
- [logical properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_logical_properties_and_values/Basic_concepts_of_logical_properties_and_values).
7
-
8
- ## Examples
9
-
10
- This rule checks for physical property usage inside of `css` function calls.
11
-
12
- ### Incorrect
13
-
14
- ```js
15
- css({
16
- left: 0,
17
- right: 0,
18
- top: 0,
19
- bottom: 0,
20
- });
21
- ```
22
-
23
- ```js
24
- css({
25
- marginLeft: 0,
26
- });
27
- ```
28
-
29
- ```js
30
- css({
31
- textAlign: 'left',
32
- });
33
- ```
34
-
35
- ### Correct
36
-
37
- ```js
38
- css({
39
- inset: 0,
40
- });
41
- ```
42
-
43
- ```js
44
- css({
45
- marginInlineStart: 0,
46
- });
47
- ```
48
-
49
- ```js
50
- css({
51
- textAlign: 'start',
52
- });
53
- ```
@@ -1,135 +0,0 @@
1
- # no-styled-tagged-template-expression
2
-
3
- Disallows any `styled` tagged template expressions that originate from a CSS-in-JS library,
4
- including `@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
5
-
6
- Tagged template expressions are difficult to parse correctly (which can lead to more frequent build
7
- failures or invalid CSS generation), have limited type safety, and lack syntax highlighting. These
8
- problems can be avoided by using the preferred call expression syntax instead.
9
-
10
- The `--fix` option on the command line automatically fixes problems reported by this rule.
11
-
12
- ## Examples
13
-
14
- ### Incorrect
15
-
16
- ```js
17
- import { styled } from '@compiled/react';
18
-
19
- const InlinedStyles = styled.div`
20
- color: blue;
21
- `;
22
-
23
- const MultilineStyles = styled.div`
24
- color: blue;
25
- font-weight: 500;
26
- `;
27
-
28
- const ComposedStyles = styled(InlinedStyles)`
29
- font-weight: 500;
30
- `;
31
-
32
- const DynamicStyles = styled.div`
33
- color: ${(props) => props.color};
34
- ${(props) => (props.disabled ? 'opacity: 0.8' : 'opacity: 1')}
35
- `;
36
- ```
37
-
38
- ### Correct
39
-
40
- ```js
41
- import { styled } from '@compiled/react';
42
-
43
- const InlinedStyles = styled.div({
44
- color: 'blue',
45
- });
46
-
47
- const MultilineStyles = styled.div({
48
- color: 'blue',
49
- fontWeight: 500,
50
- });
51
-
52
- const ComposedStyles = styled(InlinedStyles)({
53
- fontWeight: 500,
54
- });
55
-
56
- const DynamicStyles = styled.div(
57
- {
58
- color: (props) => props.color,
59
- },
60
- (props) => (props.disabled ? 'opacity: 0.8' : 'opacity: 1'),
61
- );
62
- ```
63
-
64
- ## Options
65
-
66
- ### importSources
67
-
68
- By default, this rule will check `styled` usages from:
69
-
70
- - `@atlaskit/css`
71
- - `@atlaskit/primitives`
72
- - `@compiled/react`
73
- - `@emotion/react`
74
- - `@emotion/core`
75
- - `@emotion/styled`
76
- - `styled-components`
77
-
78
- To change this list of libraries, you can define a custom set of `importSources`, which accepts an
79
- array of package names (strings).
80
-
81
- ```tsx
82
- // [{ importSources: ['other-lib'] }]
83
-
84
- import { styled } from 'other-lib';
85
-
86
- // Invalid!
87
- export const Component = styled.div``;
88
- ```
89
-
90
- ## Limitations
91
-
92
- - Comments are not fixable.
93
- - Component selectors are not fixable for `styled-components`.
94
-
95
- Do not migrate to this object syntax manually, it is invalid `styled-components`.
96
-
97
- ```tsx
98
- const Button = styled.button``;
99
- const Wrapper = styled.div({
100
- color: 'red',
101
- [`${Button}`]: {
102
- color: 'blue',
103
- },
104
- });
105
- <Wrapper><Button /><Wrapper>
106
- ```
107
-
108
- Instead, style the button directly—make it clear that you're styling that button.
109
-
110
- ```tsx
111
- const buttonStyles = css({ color: 'blue' });
112
- const Wrapper = styled.div({
113
- color: 'red',
114
- });
115
-
116
- <Wrapper>
117
- <button css={buttonStyles} />
118
- </Wrapper>;
119
- ```
120
-
121
- If that's not feasible, you can use data attributes, but these will result in failing the UI Styling
122
- Standard around nested styles, pushing the error down the road.
123
-
124
- ```tsx
125
- const Wrapper = styled.div({
126
- color: 'red',
127
- '[data-component-selector="my.button"]': {
128
- color: 'blue',
129
- },
130
- });
131
-
132
- <Wrapper>
133
- <button data-component-selector="my.button" />
134
- </Wrapper>;
135
- ```
@@ -1,50 +0,0 @@
1
- # no-unsafe-design-token-usage
2
-
3
- Using design tokens in an unsafe way risks the health of the system and will effect how fast your
4
- codebase can migrate between versions.
5
-
6
- ## Examples
7
-
8
- This rule will mark design token usage that is not statically and locally analyzable, as well as
9
- design tokens that are considered deleted.
10
-
11
- ## Incorrect
12
-
13
- ```js
14
- const textColor = 'red';
15
-
16
- css({ color: textColor });
17
- ^^^^^^^^^ must be a string literal
18
- ```
19
-
20
- ```js
21
- css({ boxShadow: '0px 1px 1px var(--ds-accent-subtleBlue)' });
22
- ^^^^^^^^^^^^^^^^^^^^^^^^^^ must use the token() function
23
- ```
24
-
25
- ## Correct
26
-
27
- ```js
28
- import { token } from '@atlaskit/tokens';
29
-
30
- css({ boxShadow: token('elevation.shadow.card') });
31
-
32
- css`
33
- color: ${(token('color.text.highemphasis'), N20)};
34
- `;
35
- ```
36
-
37
- ## Options
38
-
39
- This rule comes with options to aid in migrating to design tokens.
40
-
41
- ### fallbackUsage
42
-
43
- - `forced`: Fallback values must always be provided
44
- - `none`: Fallback values must never be provided. (Fixer will remove if provided)
45
- - `optional`: Fallbacks are optional
46
-
47
- ### shouldEnforceFallbacks (deprecated)
48
-
49
- When `true` the rule will mark token function usage as violations when fallbacks aren't defined.
50
- When `false` the rule will mark token function usage as violations when fallbacks are defined.