@atlaskit/eslint-plugin-design-system 8.26.0 → 8.28.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 +31 -0
- package/README.md +31 -29
- package/constellation/consistent-css-prop-usage/usage.mdx +193 -0
- package/constellation/ensure-design-token-usage/usage.mdx +72 -0
- package/constellation/ensure-design-token-usage-preview/usage.mdx +5 -0
- package/constellation/icon-label/usage.mdx +39 -0
- package/constellation/index/usage.mdx +31 -1474
- package/constellation/local-cx-xcss/usage.mdx +37 -0
- package/constellation/no-banned-imports/usage.mdx +17 -0
- package/constellation/no-css-tagged-template-expression/usage.mdx +66 -0
- package/constellation/no-deprecated-apis/usage.mdx +76 -0
- package/constellation/no-deprecated-design-token-usage/usage.mdx +27 -0
- package/constellation/no-deprecated-imports/usage.mdx +62 -0
- package/constellation/no-empty-styled-expression/usage.mdx +77 -0
- package/constellation/no-exported-css/usage.mdx +50 -0
- package/constellation/no-exported-keyframes/usage.mdx +50 -0
- package/constellation/no-invalid-css-map/usage.mdx +199 -0
- package/constellation/no-keyframes-tagged-template-expression/usage.mdx +76 -0
- package/constellation/no-margin/usage.mdx +20 -0
- package/constellation/no-nested-styles/usage.mdx +47 -0
- package/constellation/no-physical-properties/usage.mdx +53 -0
- package/constellation/no-styled-tagged-template-expression/usage.mdx +90 -0
- package/constellation/no-unsafe-design-token-usage/usage.mdx +49 -0
- package/constellation/no-unsafe-style-overrides/usage.mdx +49 -0
- package/constellation/no-unsupported-drag-and-drop-libraries/usage.mdx +17 -0
- package/constellation/prefer-primitives/usage.mdx +31 -0
- package/constellation/use-button-group-label/usage.mdx +58 -0
- package/constellation/use-drawer-label/usage.mdx +53 -0
- package/constellation/use-heading-level-in-spotlight-card/usage.mdx +20 -0
- package/constellation/use-href-in-link-item/usage.mdx +18 -0
- package/constellation/use-primitives/usage.mdx +77 -0
- package/constellation/use-visually-hidden/usage.mdx +34 -0
- package/dist/cjs/presets/all.codegen.js +3 -1
- package/dist/cjs/rules/consistent-css-prop-usage/index.js +254 -32
- package/dist/cjs/rules/index.codegen.js +5 -1
- package/dist/cjs/rules/no-css-tagged-template-expression/index.js +3 -2
- package/dist/cjs/rules/no-keyframes-tagged-template-expression/index.js +27 -0
- package/dist/cjs/rules/no-styled-tagged-template-expression/index.js +27 -0
- package/dist/cjs/rules/no-styled-tagged-template-expression/is-styled.js +53 -0
- package/dist/cjs/rules/utils/create-no-exported-rule/is-styled-component.js +6 -10
- package/dist/cjs/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/index.js +26 -6
- package/dist/cjs/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/to-arguments.js +28 -2
- package/dist/cjs/rules/utils/create-rule.js +7 -5
- package/dist/cjs/rules/utils/get-first-supported-import.js +28 -0
- package/dist/cjs/rules/utils/is-supported-import.js +9 -11
- package/dist/es2019/presets/all.codegen.js +3 -1
- package/dist/es2019/rules/consistent-css-prop-usage/index.js +251 -33
- package/dist/es2019/rules/index.codegen.js +5 -1
- package/dist/es2019/rules/no-css-tagged-template-expression/index.js +3 -2
- package/dist/es2019/rules/no-keyframes-tagged-template-expression/index.js +21 -0
- package/dist/es2019/rules/no-styled-tagged-template-expression/index.js +21 -0
- package/dist/es2019/rules/no-styled-tagged-template-expression/is-styled.js +45 -0
- package/dist/es2019/rules/utils/create-no-exported-rule/is-styled-component.js +4 -8
- package/dist/es2019/rules/utils/create-no-tagged-template-expression-rule/index.js +84 -0
- package/dist/es2019/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/to-arguments.js +28 -2
- package/dist/es2019/rules/utils/create-rule.js +7 -5
- package/dist/es2019/rules/utils/get-first-supported-import.js +22 -0
- package/dist/es2019/rules/utils/is-supported-import.js +9 -9
- package/dist/esm/presets/all.codegen.js +3 -1
- package/dist/esm/rules/consistent-css-prop-usage/index.js +255 -33
- package/dist/esm/rules/index.codegen.js +5 -1
- package/dist/esm/rules/no-css-tagged-template-expression/index.js +3 -2
- package/dist/esm/rules/no-keyframes-tagged-template-expression/index.js +21 -0
- package/dist/esm/rules/no-styled-tagged-template-expression/index.js +21 -0
- package/dist/esm/rules/no-styled-tagged-template-expression/is-styled.js +47 -0
- package/dist/esm/rules/utils/create-no-exported-rule/is-styled-component.js +6 -10
- package/dist/esm/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/index.js +25 -5
- package/dist/esm/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/to-arguments.js +28 -2
- package/dist/esm/rules/utils/create-rule.js +7 -5
- package/dist/esm/rules/utils/get-first-supported-import.js +22 -0
- package/dist/esm/rules/utils/is-supported-import.js +9 -10
- package/dist/types/index.codegen.d.ts +2 -0
- package/dist/types/presets/all.codegen.d.ts +3 -1
- package/dist/types/rules/consistent-css-prop-usage/types.d.ts +7 -2
- package/dist/types/rules/index.codegen.d.ts +2 -0
- package/dist/types/rules/no-keyframes-tagged-template-expression/index.d.ts +2 -0
- package/dist/types/rules/no-styled-tagged-template-expression/index.d.ts +2 -0
- package/dist/types/rules/no-styled-tagged-template-expression/is-styled.d.ts +7 -0
- package/dist/types/rules/use-primitives/utils/update-jsx-attribute-by-name.d.ts +1 -1
- package/dist/types/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/index.d.ts +3 -1
- package/dist/types/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/types.d.ts +3 -0
- package/dist/types/rules/utils/get-first-supported-import.d.ts +17 -0
- package/dist/types/rules/utils/is-supported-import.d.ts +6 -5
- package/dist/types-ts4.5/index.codegen.d.ts +2 -0
- package/dist/types-ts4.5/presets/all.codegen.d.ts +3 -1
- package/dist/types-ts4.5/rules/consistent-css-prop-usage/types.d.ts +7 -2
- package/dist/types-ts4.5/rules/index.codegen.d.ts +2 -0
- package/dist/types-ts4.5/rules/no-keyframes-tagged-template-expression/index.d.ts +2 -0
- package/dist/types-ts4.5/rules/no-styled-tagged-template-expression/index.d.ts +2 -0
- package/dist/types-ts4.5/rules/no-styled-tagged-template-expression/is-styled.d.ts +7 -0
- package/dist/types-ts4.5/rules/use-primitives/utils/update-jsx-attribute-by-name.d.ts +1 -1
- package/dist/types-ts4.5/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/index.d.ts +3 -1
- package/dist/types-ts4.5/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/types.d.ts +3 -0
- package/dist/types-ts4.5/rules/utils/get-first-supported-import.d.ts +17 -0
- package/dist/types-ts4.5/rules/utils/is-supported-import.d.ts +6 -5
- package/package.json +3 -1
- package/dist/es2019/rules/no-css-tagged-template-expression/create-no-tagged-template-expression-rule/index.js +0 -62
- /package/dist/cjs/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/generate.js +0 -0
- /package/dist/cjs/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/get-tagged-template-expression-offset.js +0 -0
- /package/dist/cjs/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/types.js +0 -0
- /package/dist/es2019/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/generate.js +0 -0
- /package/dist/es2019/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/get-tagged-template-expression-offset.js +0 -0
- /package/dist/es2019/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/types.js +0 -0
- /package/dist/esm/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/generate.js +0 -0
- /package/dist/esm/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/get-tagged-template-expression-offset.js +0 -0
- /package/dist/esm/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/types.js +0 -0
- /package/dist/types/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/generate.d.ts +0 -0
- /package/dist/types/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/get-tagged-template-expression-offset.d.ts +0 -0
- /package/dist/types/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/to-arguments.d.ts +0 -0
- /package/dist/types-ts4.5/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/generate.d.ts +0 -0
- /package/dist/types-ts4.5/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/get-tagged-template-expression-offset.d.ts +0 -0
- /package/dist/types-ts4.5/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/to-arguments.d.ts +0 -0
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
order: 0
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
import SectionMessage from '@atlaskit/section-message';
|
|
6
|
-
|
|
7
5
|
This plugin contains rules that should be used when working with the [Atlassian Design System](https://atlassian.design).
|
|
8
6
|
|
|
9
7
|
## Rules
|
|
@@ -11,1477 +9,36 @@ This plugin contains rules that should be used when working with the [Atlassian
|
|
|
11
9
|
<!-- START_RULE_TABLE_CODEGEN -->
|
|
12
10
|
<!-- @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen -->
|
|
13
11
|
|
|
14
|
-
| Rule
|
|
15
|
-
|
|
|
16
|
-
| <a href="
|
|
17
|
-
| <a href="
|
|
18
|
-
| <a href="
|
|
19
|
-
| <a href="
|
|
20
|
-
| <a href="
|
|
21
|
-
| <a href="
|
|
22
|
-
| <a href="
|
|
23
|
-
| <a href="
|
|
24
|
-
| <a href="
|
|
25
|
-
| <a href="
|
|
26
|
-
| <a href="
|
|
27
|
-
| <a href="
|
|
28
|
-
| <a href="
|
|
29
|
-
| <a href="
|
|
30
|
-
| <a href="
|
|
31
|
-
| <a href="
|
|
32
|
-
| <a href="
|
|
33
|
-
| <a href="
|
|
34
|
-
| <a href="
|
|
35
|
-
| <a href="
|
|
36
|
-
| <a href="
|
|
37
|
-
| <a href="
|
|
38
|
-
| <a href="
|
|
39
|
-
| <a href="
|
|
40
|
-
| <a href="
|
|
41
|
-
| <a href="
|
|
42
|
-
| <a href="
|
|
12
|
+
| Rule | Description | Recommended | Fixable | Suggestions |
|
|
13
|
+
| --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | ------- | ----------- |
|
|
14
|
+
| <a href="consistent-css-prop-usage/usage">consistent-css-prop-usage</a> | Ensures consistency with `css` and `xcss` prop usages | Yes | Yes | |
|
|
15
|
+
| <a href="ensure-design-token-usage/usage">ensure-design-token-usage</a> | Enforces usage of design tokens rather than hard-coded values. | Yes | Yes | Yes |
|
|
16
|
+
| <a href="ensure-design-token-usage-preview/usage">ensure-design-token-usage/preview</a> | Enforces usage of pre-release design tokens rather than hard-coded values. | | Yes | Yes |
|
|
17
|
+
| <a href="icon-label/usage">icon-label</a> | Enforces accessible usage of icon labels when composed with Atlassian Design System components. | Yes | Yes | |
|
|
18
|
+
| <a href="local-cx-xcss/usage">local-cx-xcss</a> | Ensures the cx() function, which is part of the XCSS API, is only used within the xcss prop. This aids tracking what styles are applied to a jsx element. | Yes | | |
|
|
19
|
+
| <a href="no-banned-imports/usage">no-banned-imports</a> | Disallow importing banned modules. | Yes | | |
|
|
20
|
+
| <a href="no-css-tagged-template-expression/usage">no-css-tagged-template-expression</a> | Disallows any `css` tagged template expressions that originate from Emotion, Styled Components or Compiled | | Yes | |
|
|
21
|
+
| <a href="no-deprecated-apis/usage">no-deprecated-apis</a> | Disallow using deprecated APIs. | Yes | | |
|
|
22
|
+
| <a href="no-deprecated-design-token-usage/usage">no-deprecated-design-token-usage</a> | Disallow using deprecated design tokens. | Yes | Yes | |
|
|
23
|
+
| <a href="no-deprecated-imports/usage">no-deprecated-imports</a> | Disallow importing deprecated modules. | Yes | | |
|
|
24
|
+
| <a href="no-empty-styled-expression/usage">no-empty-styled-expression</a> | Forbids any styled expression to be used when passing empty arguments to styled.div() (or other JSX elements). | Yes | | |
|
|
25
|
+
| <a href="no-exported-css/usage">no-exported-css</a> | Forbid exporting `css` function calls. Exporting `css` function calls can result in unexpected behaviour at runtime, and is not statically analysable. | Yes | | |
|
|
26
|
+
| <a href="no-exported-keyframes/usage">no-exported-keyframes</a> | Forbid exporting `keyframes` function calls. Exporting `css` function calls can result in unexpected behaviour at runtime, and is not statically analysable. | Yes | | |
|
|
27
|
+
| <a href="no-invalid-css-map/usage">no-invalid-css-map</a> | Checks the validity of a CSS map created through cssMap. This is intended to be used alongside TypeScript's type-checking. | Yes | | |
|
|
28
|
+
| <a href="no-keyframes-tagged-template-expression/usage">no-keyframes-tagged-template-expression</a> | Disallows any `keyframe` tagged template expressions that originate from Emotion, Styled Components or Compiled | | Yes | |
|
|
29
|
+
| <a href="no-margin/usage">no-margin</a> | Disallow using the margin CSS property. | | | |
|
|
30
|
+
| <a href="no-nested-styles/usage">no-nested-styles</a> | Disallows use of nested styles in `css` functions. | Yes | | |
|
|
31
|
+
| <a href="no-physical-properties/usage">no-physical-properties</a> | Disallow physical properties and values in `css` function calls. | | Yes | |
|
|
32
|
+
| <a href="no-styled-tagged-template-expression/usage">no-styled-tagged-template-expression</a> | Disallows any `styled` tagged template expressions that originate from Emotion, Styled Components or Compiled | | Yes | |
|
|
33
|
+
| <a href="no-unsafe-design-token-usage/usage">no-unsafe-design-token-usage</a> | Enforces design token usage is statically and locally analyzable. | Yes | Yes | |
|
|
34
|
+
| <a href="no-unsafe-style-overrides/usage">no-unsafe-style-overrides</a> | Discourage usage of unsafe style overrides used against the Atlassian Design System. | Yes | | |
|
|
35
|
+
| <a href="no-unsupported-drag-and-drop-libraries/usage">no-unsupported-drag-and-drop-libraries</a> | Disallow importing unsupported drag and drop modules. | Yes | | |
|
|
36
|
+
| <a href="prefer-primitives/usage">prefer-primitives</a> | Increase awareness of primitive components via code hints. Strictly used for education purposes and discoverability. To enforce usage please refer to the `use-primitives` rule. | | | |
|
|
37
|
+
| <a href="use-button-group-label/usage">use-button-group-label</a> | Ensures button groups are described to assistive technology by a direct label or by another element. | Yes | | Yes |
|
|
38
|
+
| <a href="use-drawer-label/usage">use-drawer-label</a> | Encourages to provide accessible name for Atlassian Design System Drawer component. | Yes | | Yes |
|
|
39
|
+
| <a href="use-heading-level-in-spotlight-card/usage">use-heading-level-in-spotlight-card</a> | Inform developers of eventual requirement of `headingLevel` prop in `SpotlightCard` component. The heading level should be the appropriate level according to the surrounding context. | Yes | Yes | |
|
|
40
|
+
| <a href="use-href-in-link-item/usage">use-href-in-link-item</a> | Inform developers of eventual requirement of `href` prop in `LinkItem` component. Elements with a `link` role require an `href` attribute for users to properly navigate, particularly those using assistive technologies. If no valid `href` is required for your use case, consider using a `ButtonItem` instead. | Yes | Yes | Yes |
|
|
41
|
+
| <a href="use-primitives/usage">use-primitives</a> | Encourage the usage of primitives components. | | Yes | Yes |
|
|
42
|
+
| <a href="use-visually-hidden/usage">use-visually-hidden</a> | Enforce usage of the visually hidden component. | Yes | Yes | |
|
|
43
43
|
|
|
44
44
|
<!-- END_RULE_TABLE_CODEGEN -->
|
|
45
|
-
|
|
46
|
-
<!-- START_RULE_CONTENT_CODEGEN -->
|
|
47
|
-
<!-- @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen -->
|
|
48
|
-
|
|
49
|
-
## consistent-css-prop-usage
|
|
50
|
-
|
|
51
|
-
> Ensures consistency with CSS prop usage.
|
|
52
|
-
|
|
53
|
-
<h3>Rationale</h3>
|
|
54
|
-
|
|
55
|
-
Every product should be defining styles in the same way, using the same tools, enforced by the same linting rules, which we can then all evolve and scale together.
|
|
56
|
-
|
|
57
|
-
<h3>How the rule works</h3>
|
|
58
|
-
|
|
59
|
-
This rule checks for the following cases:
|
|
60
|
-
|
|
61
|
-
- When styles are defined inline.
|
|
62
|
-
- When styles are not using `css` object api.
|
|
63
|
-
- When styles are coming from outside of the module i.e. using imports.
|
|
64
|
-
- When styles are spread inside another styles and not using array composition.
|
|
65
|
-
|
|
66
|
-
All the above can also work for custom `css` functions, such as `xcss` (https://atlassian.design/components/primitives/xcss/).
|
|
67
|
-
|
|
68
|
-
This rule has options - see below.
|
|
69
|
-
|
|
70
|
-
<h3>Examples</h3>
|
|
71
|
-
|
|
72
|
-
👎 Example of **incorrect** code for this rule:
|
|
73
|
-
|
|
74
|
-
**Calling a css/xcss function or direct objects inside the JSX attribute.**
|
|
75
|
-
|
|
76
|
-
```js
|
|
77
|
-
function Button({ children }) {
|
|
78
|
-
return <div css={css({...})}>{children}</div>;
|
|
79
|
-
^^^^^^^ css function call used inline (performance issue)
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
**Inserting a non css-function based object identifier into a css JSX attribute.**
|
|
84
|
-
|
|
85
|
-
```js
|
|
86
|
-
const container = {
|
|
87
|
-
^^^^^^^^^ should be a css function call
|
|
88
|
-
zIndex: 10,
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
function Button({ children }) {
|
|
92
|
-
return <button css={container}>{children}</button>;
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
**Importing styles from another file.**
|
|
97
|
-
|
|
98
|
-
```js
|
|
99
|
-
import { container } from './styles';
|
|
100
|
-
^^^^^^^^^ styles should be local, not shared
|
|
101
|
-
|
|
102
|
-
function Button({ children }) {
|
|
103
|
-
return <button css={container}>{children}</button>;
|
|
104
|
-
}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
**Nesting styles with objects instead of arrays.**
|
|
108
|
-
|
|
109
|
-
```js
|
|
110
|
-
const baseContainerStyles = css({
|
|
111
|
-
zIndex: 5,
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
const containerStyles = css({
|
|
115
|
-
...baseContainerStyles,
|
|
116
|
-
^^^^^^^^^^^^^^^^^^^^^^ compose styles by providing an array to the css call instead (see example below)
|
|
117
|
-
zIndex: 7,
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
function Button({ children }) {
|
|
121
|
-
return <button css={containerStyles}>{children}</button>;
|
|
122
|
-
}
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
👍 Example of **correct** code for this rule:
|
|
126
|
-
|
|
127
|
-
**Using the css() function to create a style object that follows the naming convention (ends in Styles) and passing it as a variable into the css={...} JSX attribute.**
|
|
128
|
-
|
|
129
|
-
With the following options turned on:
|
|
130
|
-
|
|
131
|
-
- cssFunctions = ['css']
|
|
132
|
-
- stylesPlacement = 'top'
|
|
133
|
-
|
|
134
|
-
```js
|
|
135
|
-
const containerStyles = css({
|
|
136
|
-
zIndex: 1,
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
function Button({ children }) {
|
|
140
|
-
return <button css={containerStyles}>{children}</button>;
|
|
141
|
-
}
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
**Technically correct usage of the cssMap function.**
|
|
145
|
-
|
|
146
|
-
With the following options turned on:
|
|
147
|
-
|
|
148
|
-
- cssFunctions = ['css']
|
|
149
|
-
- stylesPlacement = 'top'
|
|
150
|
-
|
|
151
|
-
```js
|
|
152
|
-
const borderStyles = cssMap({
|
|
153
|
-
'solid': '1px solid';
|
|
154
|
-
'none': '0px';
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
function Button({ children }) {
|
|
158
|
-
return <button css={borderStyles[solid]}>{children}</button>;
|
|
159
|
-
}
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
**Create composite styles with arrays, not objects.**
|
|
163
|
-
|
|
164
|
-
With the following options turned on:
|
|
165
|
-
|
|
166
|
-
- cssFunctions = ['css']
|
|
167
|
-
- stylesPlacement = 'bottom'
|
|
168
|
-
|
|
169
|
-
```js
|
|
170
|
-
function Button({ children }) {
|
|
171
|
-
return (
|
|
172
|
-
<button css={[baseContainerStyles, containerStyles]}>{children}</button>
|
|
173
|
-
);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const baseContainerStyles = css({
|
|
177
|
-
zIndex: 5,
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
const containerStyles = css({
|
|
181
|
-
zIndex: 7,
|
|
182
|
-
});
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
**Ternaries can be used inline**
|
|
186
|
-
|
|
187
|
-
```js
|
|
188
|
-
const baseStyles = css({ color: token('color.text.primary') });
|
|
189
|
-
const disabledStyles = css({ color: token('color.text.disabled') });
|
|
190
|
-
|
|
191
|
-
<div css={props.disabled ? disabledStyles : baseStyles}></div>;
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
<h3>Options</h3>
|
|
195
|
-
|
|
196
|
-
This rule comes with options to support different repository configurations.
|
|
197
|
-
|
|
198
|
-
#### cssFunctions
|
|
199
|
-
|
|
200
|
-
An array of function names the linting rule should target. Defaults to `['css', 'xcss']`. Functionality of cssMap will be linted regardless of the configuration of `cssFunctions` as it can be used with either attribute.
|
|
201
|
-
|
|
202
|
-
#### stylesPlacement
|
|
203
|
-
|
|
204
|
-
The rule prevents inline styles from being created. This option defines what the error message should say: "(...) styles at the top (...)" or "(...) styles at the bottom (...)".
|
|
205
|
-
Defaults to `top`.
|
|
206
|
-
|
|
207
|
-
## ensure-design-token-usage
|
|
208
|
-
|
|
209
|
-
Using design tokens results in a harmonious experience for end users whilst providing theming and consistency.
|
|
210
|
-
All experiences must use color tokens otherwise when switching between themes, unexpected incidents can occur where not all of the UI is themed.
|
|
211
|
-
Space, typography, and shape tokens are strongly recommended to further align our experiences and make future changes easier.
|
|
212
|
-
|
|
213
|
-
<h3>Examples</h3>
|
|
214
|
-
|
|
215
|
-
Using anything other than design tokens such as hardcoded values or legacy theme colors will be considered violations.
|
|
216
|
-
|
|
217
|
-
#### Incorrect
|
|
218
|
-
|
|
219
|
-
```js
|
|
220
|
-
import { e100 } from '@atlaskit/theme/elevation';
|
|
221
|
-
import { B100 } from '@atlaskit/theme/colors';
|
|
222
|
-
|
|
223
|
-
css({ color: 'red' });
|
|
224
|
-
^^^
|
|
225
|
-
css({ boxShadow: '0px 1px 1px #161A1D32' });
|
|
226
|
-
^^^^^^^^^
|
|
227
|
-
css`${e100};`;
|
|
228
|
-
^^^^
|
|
229
|
-
css({ color: B100 });
|
|
230
|
-
^^^^
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
#### Correct
|
|
234
|
-
|
|
235
|
-
```js
|
|
236
|
-
import { token } from '@atlaskit/tokens';
|
|
237
|
-
|
|
238
|
-
css({ color: token('color.text.danger') });
|
|
239
|
-
|
|
240
|
-
css({ boxShadow: token('elevation.shadow.card') });
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
#### Incorrect
|
|
244
|
-
|
|
245
|
-
```js
|
|
246
|
-
css({ padding: '16px' });
|
|
247
|
-
^^^
|
|
248
|
-
css({ margin: gridSize() });
|
|
249
|
-
^^^^^^^^^^
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
#### Correct
|
|
253
|
-
|
|
254
|
-
```js
|
|
255
|
-
import { token } from '@atlaskit/tokens';
|
|
256
|
-
|
|
257
|
-
css({ padding: token('space.100') });
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
<h3>Options</h3>
|
|
261
|
-
|
|
262
|
-
This rule comes with options to aid in migrating to design tokens.
|
|
263
|
-
|
|
264
|
-
#### domains
|
|
265
|
-
|
|
266
|
-
An array specifiying which token domains to lint against (`color`, `spacing`, `typography`, `shape`). Defaults to [`'color'`] if not provided.
|
|
267
|
-
|
|
268
|
-
#### applyImport
|
|
269
|
-
|
|
270
|
-
When `true`, the rule when automatically add imports to the `@atlaskit/tokens` package where tokens are auto-fixed. Defaults to `true` if not provided.
|
|
271
|
-
|
|
272
|
-
#### shouldEnforceFallbacks
|
|
273
|
-
|
|
274
|
-
When `true` the rule will add in stub fallbacks when choosing a suggestion in your IDE. Defaults to `false` if not provided.
|
|
275
|
-
|
|
276
|
-
#### exceptions
|
|
277
|
-
|
|
278
|
-
An array specifying strings to ingore when linting.
|
|
279
|
-
|
|
280
|
-
## ensure-design-token-usage/preview
|
|
281
|
-
|
|
282
|
-
This rule is a clone of `ensure-design-token-usage` and is intended to allow you to set some domains to `warn` before they are set to `error` in the main rule.
|
|
283
|
-
|
|
284
|
-
See `ensure-design-token-usage` for full usage documentation.
|
|
285
|
-
|
|
286
|
-
## icon-label
|
|
287
|
-
|
|
288
|
-
Icon labels are used to describe what the icon is so the visually impaired can be described what the UI element is.
|
|
289
|
-
There are cases where icons should have labels as well as cases where they shouldn't be labelled.
|
|
290
|
-
|
|
291
|
-
<h3>Examples</h3>
|
|
292
|
-
|
|
293
|
-
This rule will find violations for when an icon label is or isn't needed when composed with other Design System components.
|
|
294
|
-
|
|
295
|
-
#### Incorrect
|
|
296
|
-
|
|
297
|
-
```js
|
|
298
|
-
import ActivityIcon from '@atlaskit/icon/glyph/activity'
|
|
299
|
-
|
|
300
|
-
<ActivityIcon>
|
|
301
|
-
^^^^^^^^^^^^^^ missing `label` prop
|
|
302
|
-
|
|
303
|
-
<Button iconLeft={<ActivityIcon label="">} />
|
|
304
|
-
^^^^^ label should be defined
|
|
305
|
-
|
|
306
|
-
<ButtonItem iconBefore={<ActivityIcon label="">}>
|
|
307
|
-
^^^^^ label should not be defined
|
|
308
|
-
My activity
|
|
309
|
-
</ButtonItem>
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
#### Correct
|
|
313
|
-
|
|
314
|
-
```js
|
|
315
|
-
import ActivityIcon from '@atlaskit/icon/glyph/activity'
|
|
316
|
-
|
|
317
|
-
<ActivityIcon label="Activity">
|
|
318
|
-
|
|
319
|
-
<Button iconLeft={<ActivityIcon label="Activity">} />
|
|
320
|
-
|
|
321
|
-
<ButtonItem iconBefore={<ActivityIcon label="">}>
|
|
322
|
-
My activity
|
|
323
|
-
</ButtonItem>
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
## local-cx-xcss
|
|
327
|
-
|
|
328
|
-
This rule ensures the `cx()` function is only used within the `xcss` prop. This aids tracking what styles are applied to a jsx element.
|
|
329
|
-
|
|
330
|
-
The `cx` function is checked only if it is imported from `@compiled/react` or `@atlaskit/css`.
|
|
331
|
-
|
|
332
|
-
Passing arguments to the `cx()` function is how you compose styles (combine more than one set of styles together) with XCSS. This is a workaround for the more conventional array syntax (e.g. [in Emotion](https://emotion.sh/docs/composition)) `<div xcss={[style1, style2]} />` not giving robust enough type checking.
|
|
333
|
-
|
|
334
|
-
<h3>Examples</h3>
|
|
335
|
-
|
|
336
|
-
#### Incorrect
|
|
337
|
-
|
|
338
|
-
```js
|
|
339
|
-
import { cx, cssMap } from '@compiled/react';
|
|
340
|
-
|
|
341
|
-
const styles = cssMap({
|
|
342
|
-
text: { color: 'red' },
|
|
343
|
-
bg: { background: 'blue' },
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
const joinedStyles = cx(styles.text, styles.bg);
|
|
347
|
-
|
|
348
|
-
<Button xcss={joinedStyles} />;
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
#### Correct
|
|
352
|
-
|
|
353
|
-
```js
|
|
354
|
-
import { cx, cssMap } from '@compiled/react';
|
|
355
|
-
|
|
356
|
-
const styles = cssMap({
|
|
357
|
-
text: { color: 'red' },
|
|
358
|
-
bg: { background: 'blue' },
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
<Button xcss={cx(styles.text, styles.bg)} />;
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
## no-banned-imports
|
|
365
|
-
|
|
366
|
-
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.
|
|
367
|
-
|
|
368
|
-
<h3>Examples</h3>
|
|
369
|
-
|
|
370
|
-
Anything that is considered private or experimental will be marked as violations.
|
|
371
|
-
|
|
372
|
-
#### Incorrect
|
|
373
|
-
|
|
374
|
-
```ts
|
|
375
|
-
import noop from '@atlaskit/ds-lib/noop';
|
|
376
|
-
^^^^^^^^^^^^^^^^^^^^^
|
|
377
|
-
|
|
378
|
-
import { Text } from '@atlaskit/ds-explorations';
|
|
379
|
-
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
380
|
-
```
|
|
381
|
-
|
|
382
|
-
## no-css-tagged-template-expression
|
|
383
|
-
|
|
384
|
-
Disallows any `css` tagged template expressions that originate from `@emotion/react`, `@emotion/core`, `compiled/react` or `styled-components`.
|
|
385
|
-
|
|
386
|
-
Tagged template expressions cannot be type safe and are difficult to parse correctly. Will auto fix ` css`` ` to the preferred `css({})` call expression syntax.
|
|
387
|
-
|
|
388
|
-
Thank you to the [Compiled team for their rule](https://github.com/atlassian-labs/compiled/tree/master/packages/eslint-plugin/src/rules/no-css-tagged-template-expression) from which this was ported.
|
|
389
|
-
|
|
390
|
-
<h3>Incorrect</h3>
|
|
391
|
-
|
|
392
|
-
```js
|
|
393
|
-
import { css } from '@emotion/react';
|
|
394
|
-
|
|
395
|
-
css`
|
|
396
|
-
color: blue;
|
|
397
|
-
`;
|
|
398
|
-
|
|
399
|
-
const styles = css`
|
|
400
|
-
color: blue;
|
|
401
|
-
font-weight: 500;
|
|
402
|
-
`;
|
|
403
|
-
```
|
|
404
|
-
|
|
405
|
-
<h3>Correct</h3>
|
|
406
|
-
|
|
407
|
-
```js
|
|
408
|
-
import { css } from '@emotion/react';
|
|
409
|
-
|
|
410
|
-
css({ color: 'blue' });
|
|
411
|
-
|
|
412
|
-
const styles = css({
|
|
413
|
-
color: 'blue',
|
|
414
|
-
fontWeight: 500,
|
|
415
|
-
});
|
|
416
|
-
```
|
|
417
|
-
|
|
418
|
-
<h3>Limitations</h3>
|
|
419
|
-
|
|
420
|
-
- Comments are not auto-fixable. You will need to manually convert usages containing functions.
|
|
421
|
-
|
|
422
|
-
## no-deprecated-apis
|
|
423
|
-
|
|
424
|
-
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.
|
|
425
|
-
|
|
426
|
-
<h3>Examples</h3>
|
|
427
|
-
|
|
428
|
-
Anything that can be used as props from Atlassian Design System components can be violations when marked as deprecated.
|
|
429
|
-
|
|
430
|
-
#### Incorrect
|
|
431
|
-
|
|
432
|
-
```tsx
|
|
433
|
-
<ButtonItem cssFn={cssFn()} />
|
|
434
|
-
^^^^
|
|
435
|
-
|
|
436
|
-
<Drawer overrides={overrides} />
|
|
437
|
-
^^^^^^^^^
|
|
438
|
-
```
|
|
439
|
-
|
|
440
|
-
<h3>Options</h3>
|
|
441
|
-
|
|
442
|
-
The rule can take one option: `deprecatedConfig`,
|
|
443
|
-
if not provided the rule will use an internal config.
|
|
444
|
-
If provided the rule will use the passed in config instead.
|
|
445
|
-
|
|
446
|
-
#### deprecatedConfig
|
|
447
|
-
|
|
448
|
-
The following fields can be defined in the config:
|
|
449
|
-
|
|
450
|
-
- `deprecatedProp`, which is the deprecated props. Each prop has the following fields:
|
|
451
|
-
- `moduleSpecifier`, which is the module specifier of the package in which the prop was deprecated. For example: `@atlaskit/button`.
|
|
452
|
-
- `namedSpecifier` **(optional)**, which is an array of named specifiers of the package in which the prop was deprecated. For example: `Button`.
|
|
453
|
-
- `actionableVersion` **(optional)**, which is the version of the package in which the prop can be actioned on. For example: `1.0.0`.
|
|
454
|
-
|
|
455
|
-
```json
|
|
456
|
-
{
|
|
457
|
-
"cssFn": [
|
|
458
|
-
{
|
|
459
|
-
"moduleSpecifier": "@atlaskit/menu"
|
|
460
|
-
}
|
|
461
|
-
]
|
|
462
|
-
}
|
|
463
|
-
```
|
|
464
|
-
|
|
465
|
-
```js
|
|
466
|
-
import { configs } from '@atlaskit/eslint-plugin-design-system';
|
|
467
|
-
|
|
468
|
-
module.exports = {
|
|
469
|
-
rules: {
|
|
470
|
-
'@atlaskit/design-system/no-deprecated-api': [
|
|
471
|
-
'error',
|
|
472
|
-
{
|
|
473
|
-
deprecatedConfig: {
|
|
474
|
-
cssFn: [
|
|
475
|
-
{
|
|
476
|
-
moduleSpecifier: '@atlaskit/menu',
|
|
477
|
-
},
|
|
478
|
-
],
|
|
479
|
-
},
|
|
480
|
-
},
|
|
481
|
-
],
|
|
482
|
-
},
|
|
483
|
-
};
|
|
484
|
-
```
|
|
485
|
-
|
|
486
|
-
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.
|
|
487
|
-
|
|
488
|
-
```js
|
|
489
|
-
import { configs, filterActionableDeprecations } from '@atlaskit/eslint-plugin-design-system';
|
|
490
|
-
import packageJson from './package.json';
|
|
491
|
-
|
|
492
|
-
rules: {
|
|
493
|
-
'@atlaskit/design-system/no-deprecated-api': ['error', {
|
|
494
|
-
'deprecatedConfig': filterActionableDeprecations(configs.deprecatedConfig, packageJson),
|
|
495
|
-
}]
|
|
496
|
-
}
|
|
497
|
-
```
|
|
498
|
-
|
|
499
|
-
## no-deprecated-design-token-usage
|
|
500
|
-
|
|
501
|
-
Using deprecated design tokens is dangerous as they will eventually be deleted after the sunset period.
|
|
502
|
-
This rule helps you move to non-deprecated design tokens.
|
|
503
|
-
|
|
504
|
-
<h3>Examples</h3>
|
|
505
|
-
|
|
506
|
-
This rule will mark usage of deprecated design tokens as violations.
|
|
507
|
-
|
|
508
|
-
<h3>Incorrect</h3>
|
|
509
|
-
|
|
510
|
-
```js
|
|
511
|
-
import { token } from '@atlaskit/tokens';
|
|
512
|
-
|
|
513
|
-
css({ color: token('i.am.deprecated') });
|
|
514
|
-
^^^^^^^^^^^^^^^
|
|
515
|
-
css({ color: token('i.am.a.token') });
|
|
516
|
-
^^^^^^^^^^^^^
|
|
517
|
-
```
|
|
518
|
-
|
|
519
|
-
<h3>Options</h3>
|
|
520
|
-
|
|
521
|
-
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.
|
|
522
|
-
|
|
523
|
-
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.
|
|
524
|
-
|
|
525
|
-
Running `eslint --fix` will automatically apply replacement tokens if present.
|
|
526
|
-
|
|
527
|
-
## no-deprecated-imports
|
|
528
|
-
|
|
529
|
-
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.
|
|
530
|
-
|
|
531
|
-
<h3>Examples</h3>
|
|
532
|
-
|
|
533
|
-
This rule will mark usage of deprecated modules as violations.
|
|
534
|
-
|
|
535
|
-
#### Incorrect
|
|
536
|
-
|
|
537
|
-
```ts
|
|
538
|
-
import Item from '@atlaskit/item';
|
|
539
|
-
^^^^^^^^^^^^^^
|
|
540
|
-
import GlobalNav from '@atlaskit/global-navigation';
|
|
541
|
-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
542
|
-
```
|
|
543
|
-
|
|
544
|
-
<h3>Options</h3>
|
|
545
|
-
|
|
546
|
-
The rule can take one option: `deprecatedConfig`,
|
|
547
|
-
if not provided the rule will use an internal config.
|
|
548
|
-
If provided the rule will use the passed in config instead.
|
|
549
|
-
|
|
550
|
-
#### deprecatedConfig
|
|
551
|
-
|
|
552
|
-
The following fields can be defined in the config:
|
|
553
|
-
|
|
554
|
-
- `packagePath`, which is the name of the package. For example: `@atlaskit/navigation-next` and `@atlaskit/navigation`.
|
|
555
|
-
With the package path as the key, you can either provide the values as:
|
|
556
|
-
- `message` **(optional)**, the message to display when the deprecated packages path is used. For example: `multi-select is deprecated. Please use '@atlaskit/select' instead.`
|
|
557
|
-
Or as:
|
|
558
|
-
- `imports`, which is an array of named imports to be deprecated. Each named import has the following fields:
|
|
559
|
-
- `importName`, which is the name of the import to be deprecated. For example: `assistive` and `visuallyHidden`.
|
|
560
|
-
- `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.`.
|
|
561
|
-
|
|
562
|
-
```json
|
|
563
|
-
{
|
|
564
|
-
"@atlaskit/navigation-next": {
|
|
565
|
-
"message": "navigation-next is deprecated. Please use '@atlaskit/atlassian-navigation' instead."
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
```
|
|
569
|
-
|
|
570
|
-
```js
|
|
571
|
-
import packageJson from './package.json';
|
|
572
|
-
|
|
573
|
-
module.exports = {
|
|
574
|
-
rules: {
|
|
575
|
-
'@atlaskit/design-system/no-deprecated-imports': [
|
|
576
|
-
'error',
|
|
577
|
-
{
|
|
578
|
-
deprecatedConfig: {
|
|
579
|
-
'@atlaskit/navigation-next': {
|
|
580
|
-
message:
|
|
581
|
-
"navigation-next is deprecated. Please use '@atlaskit/atlassian-navigation' instead.",
|
|
582
|
-
},
|
|
583
|
-
},
|
|
584
|
-
},
|
|
585
|
-
],
|
|
586
|
-
},
|
|
587
|
-
};
|
|
588
|
-
```
|
|
589
|
-
|
|
590
|
-
## no-empty-styled-expression
|
|
591
|
-
|
|
592
|
-
Disallows/discourages passing empty arguments to any `styled` expression when using `@compiled/react`, as well as any other CSS-in-JS library defined through the `importSources` option.
|
|
593
|
-
|
|
594
|
-
If Compiled is used in the file, passing an empty object or no object at all causes Compiled to build extra `div/span` elements, as opposed to simply using a `div`. This leads to reduced performance and is greatly discouraged. If a wrapper is necessary, opt to use a `div` or wrap it in the empty React fragment `<> <YourComponentHere></YourComponentHere> </>`.
|
|
595
|
-
|
|
596
|
-
<h3>Examples</h3>
|
|
597
|
-
|
|
598
|
-
#### Incorrect
|
|
599
|
-
|
|
600
|
-
```tsx
|
|
601
|
-
const EmptyStyledExpression = styled.div();
|
|
602
|
-
|
|
603
|
-
const EmptyStyledExpressionArgument = styled.div({});
|
|
604
|
-
|
|
605
|
-
const EmptyStyledExpressionArgument = styled.div([]);
|
|
606
|
-
```
|
|
607
|
-
|
|
608
|
-
#### Correct
|
|
609
|
-
|
|
610
|
-
```tsx
|
|
611
|
-
const Wrapper = styled.div({
|
|
612
|
-
backgroundColor: 'red',
|
|
613
|
-
MyComponent: {
|
|
614
|
-
backgroundColor: 'green',
|
|
615
|
-
},
|
|
616
|
-
});
|
|
617
|
-
```
|
|
618
|
-
|
|
619
|
-
<h3>What to do instead?</h3>
|
|
620
|
-
|
|
621
|
-
#### Use elements directly
|
|
622
|
-
|
|
623
|
-
```diff
|
|
624
|
-
- const Wrapper = styled.div({});
|
|
625
|
-
|
|
626
|
-
function App() {
|
|
627
|
-
- return <Wrapper>hello world</Wrapper>;
|
|
628
|
-
+ return <div>hello world</div>;
|
|
629
|
-
}
|
|
630
|
-
```
|
|
631
|
-
|
|
632
|
-
#### Use a React fragment
|
|
633
|
-
|
|
634
|
-
```diff
|
|
635
|
-
- const Wrapper = styled.div({});
|
|
636
|
-
|
|
637
|
-
function App() {
|
|
638
|
-
- return <Wrapper>hello world</Wrapper>;
|
|
639
|
-
+ return <>hello world</>;
|
|
640
|
-
}
|
|
641
|
-
```
|
|
642
|
-
|
|
643
|
-
<h3>Options</h3>
|
|
644
|
-
|
|
645
|
-
#### importSources
|
|
646
|
-
|
|
647
|
-
By default, this rule will check `styled` usages from `@compiled/react`. To check `styled` usages from other CSS-in-JS libraries, you can add the library's package name to `importSources`.
|
|
648
|
-
|
|
649
|
-
`importSources` accepts an array of package names (strings). `styled` usages from `@compiled/react` will always be checked, regardless of the value of `importSources`.
|
|
650
|
-
|
|
651
|
-
```tsx
|
|
652
|
-
// [{ importSources: ['styled-components'] }]
|
|
653
|
-
|
|
654
|
-
import styled from 'styled-components';
|
|
655
|
-
|
|
656
|
-
// Invalid!
|
|
657
|
-
const styles = styled({});
|
|
658
|
-
```
|
|
659
|
-
|
|
660
|
-
## no-exported-css
|
|
661
|
-
|
|
662
|
-
Disallows `css` export declarations that originate from `@compiled/react` and `@atlaskit/css`, as well as any other CSS-in-JS library defined through the `importSources` option.
|
|
663
|
-
|
|
664
|
-
In Compiled, exporting css declarations may result in unexpected errors when imported, because its value will be `null` at runtime. Additionally, co-locating css definitions with their usage is considered best practice in order to improve code readability and build performance.
|
|
665
|
-
|
|
666
|
-
<h3>Examples</h3>
|
|
667
|
-
|
|
668
|
-
#### Incorrect
|
|
669
|
-
|
|
670
|
-
```tsx
|
|
671
|
-
import { css } from '@compiled/react';
|
|
672
|
-
|
|
673
|
-
export const styles = css({});
|
|
674
|
-
|
|
675
|
-
export default css({});
|
|
676
|
-
```
|
|
677
|
-
|
|
678
|
-
#### Correct
|
|
679
|
-
|
|
680
|
-
```tsx
|
|
681
|
-
import { css } from '@compiled/react';
|
|
682
|
-
|
|
683
|
-
const styles = css({});
|
|
684
|
-
```
|
|
685
|
-
|
|
686
|
-
<h3>Options</h3>
|
|
687
|
-
|
|
688
|
-
#### importSources
|
|
689
|
-
|
|
690
|
-
By default, this rule will check `css` usages from `@compiled/react` and `@atlaskit/css`. To check `css` usages from other CSS-in-JS libraries, you can add the library's package name to `importSources`.
|
|
691
|
-
|
|
692
|
-
`importSources` accepts an array of package names (strings). `css` usages from `@compiled/react` and `@atlaskit/css` will always be checked, regardless of the value of `importSources`.
|
|
693
|
-
|
|
694
|
-
```tsx
|
|
695
|
-
// [{ importSources: ['@emotion/css'] }]
|
|
696
|
-
|
|
697
|
-
import { css } from '@emotion/css';
|
|
698
|
-
|
|
699
|
-
// Invalid!
|
|
700
|
-
export const styles = css({});
|
|
701
|
-
```
|
|
702
|
-
|
|
703
|
-
## no-exported-keyframes
|
|
704
|
-
|
|
705
|
-
Disallows `keyframes` export declarations that originate from `@compiled/react`, as well as any other CSS-in-JS library defined through the `importSources` option.
|
|
706
|
-
|
|
707
|
-
In Compiled, exporting keyframes declarations may result in unexpected errors when imported, because its value will be `null` at runtime. Additionally, co-locating keyframes definitions with their usage is considered best practice in order to improve code readability and build performance.
|
|
708
|
-
|
|
709
|
-
<h3>Examples</h3>
|
|
710
|
-
|
|
711
|
-
<!-- To fill out -- tell us when this rule will mark violations. -->
|
|
712
|
-
|
|
713
|
-
#### Incorrect
|
|
714
|
-
|
|
715
|
-
```tsx
|
|
716
|
-
import { keyframes } from '@compiled/react';
|
|
717
|
-
|
|
718
|
-
export const animation = keyframes({});
|
|
719
|
-
|
|
720
|
-
export default keyframes({});
|
|
721
|
-
```
|
|
722
|
-
|
|
723
|
-
#### Correct
|
|
724
|
-
|
|
725
|
-
```tsx
|
|
726
|
-
import { keyframes } from '@compiled/react';
|
|
727
|
-
|
|
728
|
-
const animation = keyframes({});
|
|
729
|
-
```
|
|
730
|
-
|
|
731
|
-
<h3>Options</h3>
|
|
732
|
-
|
|
733
|
-
#### importSources
|
|
734
|
-
|
|
735
|
-
By default, this rule will check `keyframes` usages from `@compiled/react`. To check `keyframes` usages from other CSS-in-JS libraries, you can add the library's package name to `importSources`.
|
|
736
|
-
|
|
737
|
-
`importSources` accepts an array of package names (strings). `keyframes` usages from `@compiled/react` will always be checked, regardless of the value of `importSources`.
|
|
738
|
-
|
|
739
|
-
```tsx
|
|
740
|
-
// [{ importSources: ['@emotion/css'] }]
|
|
741
|
-
|
|
742
|
-
import { keyframes } from '@emotion/css';
|
|
743
|
-
|
|
744
|
-
// Invalid!
|
|
745
|
-
export const styles = keyframes({});
|
|
746
|
-
```
|
|
747
|
-
|
|
748
|
-
## no-invalid-css-map
|
|
749
|
-
|
|
750
|
-
Ensure that all usages of the `cssMap` API are valid, and enforces the format of the object that is passed to `cssMap`.
|
|
751
|
-
|
|
752
|
-
Please refer to the [Compiled documentation](https://compiledcssinjs.com/docs/api-cssmap) for more details and some examples.
|
|
753
|
-
|
|
754
|
-
Note that this version of the `no-invalid-css-map` rule differs from `@compiled/eslint-plugin/no-invalid-css-map` in that this will apply to both `@compiled/react` and `@atlaskit/css`.
|
|
755
|
-
|
|
756
|
-
This is intended to be used in conjunction with type checking (through TypeScript).
|
|
757
|
-
|
|
758
|
-
<h3>Examples</h3>
|
|
759
|
-
|
|
760
|
-
#### Incorrect
|
|
761
|
-
|
|
762
|
-
```tsx
|
|
763
|
-
import React from 'react';
|
|
764
|
-
import { cssMap } from '@compiled/react';
|
|
765
|
-
|
|
766
|
-
// cssMap needs to be declared in the top-most scope.
|
|
767
|
-
// (not within a function, class, etc.)
|
|
768
|
-
|
|
769
|
-
const Foo = () => {
|
|
770
|
-
const bar = cssMap({
|
|
771
|
-
danger: {
|
|
772
|
-
color: 'red',
|
|
773
|
-
},
|
|
774
|
-
});
|
|
775
|
-
};
|
|
776
|
-
```
|
|
777
|
-
|
|
778
|
-
```tsx
|
|
779
|
-
import React from 'react';
|
|
780
|
-
import { cssMap } from '@compiled/react';
|
|
781
|
-
import { importedVariable, importedFunction } from 'another-package';
|
|
782
|
-
|
|
783
|
-
// Cannot use imported functions as values in cssMap.
|
|
784
|
-
|
|
785
|
-
const myVariable = importedFunction();
|
|
786
|
-
|
|
787
|
-
const styles = cssMap({
|
|
788
|
-
danger: {
|
|
789
|
-
// Both invalid because they rely on an imported function.
|
|
790
|
-
color: myVariable,
|
|
791
|
-
padding: importedFunction(),
|
|
792
|
-
},
|
|
793
|
-
});
|
|
794
|
-
```
|
|
795
|
-
|
|
796
|
-
```tsx
|
|
797
|
-
import React from 'react';
|
|
798
|
-
import { cssMap } from '@compiled/react';
|
|
799
|
-
|
|
800
|
-
// Cannot export usages of cssMap.
|
|
801
|
-
// Any usages of cssMap must be in the same file.
|
|
802
|
-
|
|
803
|
-
export const foo = cssMap({
|
|
804
|
-
danger: {
|
|
805
|
-
color: 'red',
|
|
806
|
-
},
|
|
807
|
-
});
|
|
808
|
-
```
|
|
809
|
-
|
|
810
|
-
```tsx
|
|
811
|
-
import React from 'react';
|
|
812
|
-
import { cssMap } from '@compiled/react';
|
|
813
|
-
import { token } from '@atlaskit/tokens';
|
|
814
|
-
|
|
815
|
-
// Functions and object methods are not allowed as
|
|
816
|
-
// values in cssMap.
|
|
817
|
-
|
|
818
|
-
const styles = cssMap({
|
|
819
|
-
// Object method
|
|
820
|
-
get danger() {
|
|
821
|
-
return { color: '#123456' };
|
|
822
|
-
},
|
|
823
|
-
});
|
|
824
|
-
|
|
825
|
-
const styles2 = cssMap({
|
|
826
|
-
// Arrow function
|
|
827
|
-
danger: () => {
|
|
828
|
-
color: '#123456';
|
|
829
|
-
},
|
|
830
|
-
});
|
|
831
|
-
|
|
832
|
-
function customFunction(...args) {
|
|
833
|
-
return arguments.join('');
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
const styles3 = cssMap({
|
|
837
|
-
danger: {
|
|
838
|
-
// Locally defined function
|
|
839
|
-
color: customFunction('red', 'blue'),
|
|
840
|
-
backgroundColor: 'red',
|
|
841
|
-
},
|
|
842
|
-
});
|
|
843
|
-
```
|
|
844
|
-
|
|
845
|
-
```tsx
|
|
846
|
-
import React from 'react';
|
|
847
|
-
import { cssMap } from '@compiled/react';
|
|
848
|
-
|
|
849
|
-
// Spread elements ("...") cannot be used in cssMap.
|
|
850
|
-
|
|
851
|
-
const base = {
|
|
852
|
-
success: {
|
|
853
|
-
color: 'green',
|
|
854
|
-
},
|
|
855
|
-
};
|
|
856
|
-
|
|
857
|
-
const bar = cssMap({
|
|
858
|
-
...base,
|
|
859
|
-
danger: {
|
|
860
|
-
color: 'red',
|
|
861
|
-
},
|
|
862
|
-
});
|
|
863
|
-
```
|
|
864
|
-
|
|
865
|
-
#### Correct
|
|
866
|
-
|
|
867
|
-
```tsx
|
|
868
|
-
import React from 'react';
|
|
869
|
-
import { cssMap } from '@compiled/react';
|
|
870
|
-
|
|
871
|
-
// Literals (strings, numbers, etc.) are used as values
|
|
872
|
-
// in cssMap.
|
|
873
|
-
|
|
874
|
-
const styles = cssMap({
|
|
875
|
-
danger: {
|
|
876
|
-
color: 'red',
|
|
877
|
-
backgroundColor: 'red',
|
|
878
|
-
},
|
|
879
|
-
success: {
|
|
880
|
-
color: 'green',
|
|
881
|
-
backgroundColor: 'green',
|
|
882
|
-
},
|
|
883
|
-
});
|
|
884
|
-
```
|
|
885
|
-
|
|
886
|
-
```tsx
|
|
887
|
-
import React from 'react';
|
|
888
|
-
import { cssMap } from '@compiled/react';
|
|
889
|
-
|
|
890
|
-
// A statically evaluable variable (known at build time)
|
|
891
|
-
// is used here.
|
|
892
|
-
|
|
893
|
-
const bap = 'blue';
|
|
894
|
-
|
|
895
|
-
const styles = cssMap({
|
|
896
|
-
danger: {
|
|
897
|
-
color: bap,
|
|
898
|
-
},
|
|
899
|
-
});
|
|
900
|
-
```
|
|
901
|
-
|
|
902
|
-
#### Options
|
|
903
|
-
|
|
904
|
-
##### `allowedFunctionCalls`: [string, string][]
|
|
905
|
-
|
|
906
|
-
Normally, this ESLint rule forbids all function calls from being used inside the `cssMap(...)` function call. For example, this would be invalid using default settings:
|
|
907
|
-
|
|
908
|
-
```tsx
|
|
909
|
-
import React from 'react';
|
|
910
|
-
import { cssMap } from '@compiled/react';
|
|
911
|
-
import { token } from '@atlaskit/tokens';
|
|
912
|
-
|
|
913
|
-
const styles = cssMap({
|
|
914
|
-
danger: {
|
|
915
|
-
color: token('my-color'),
|
|
916
|
-
backgroundColor: 'red',
|
|
917
|
-
},
|
|
918
|
-
success: {
|
|
919
|
-
color: 'green',
|
|
920
|
-
},
|
|
921
|
-
});
|
|
922
|
-
```
|
|
923
|
-
|
|
924
|
-
If you would like to whitelist certain functions (e.g. `token` from `@atlaskit/tokens`), you can include the names of the functions as part of the `allowedFunctionCalls` argument. Each function should be represented as a two-element array, with the first element being the package the function is from, and the second element being the name of the function.
|
|
925
|
-
|
|
926
|
-
For example, with the below configuration, the above code example would be okay.
|
|
927
|
-
|
|
928
|
-
```tsx
|
|
929
|
-
// .eslintrc.js
|
|
930
|
-
|
|
931
|
-
// ...
|
|
932
|
-
rules: {
|
|
933
|
-
'@atlaskit/eslint-plugin-design-system/no-invalid-css-map': [
|
|
934
|
-
'error',
|
|
935
|
-
{
|
|
936
|
-
allowedFunctionCalls: [
|
|
937
|
-
['@atlaskit/tokens', 'token'],
|
|
938
|
-
]
|
|
939
|
-
},
|
|
940
|
-
],
|
|
941
|
-
// ...
|
|
942
|
-
},
|
|
943
|
-
// ...
|
|
944
|
-
```
|
|
945
|
-
|
|
946
|
-
Please note that this ESLint rule only supports whitelisting imports in the form `import { myFunctionOrVariable } from 'my-package'`; we do not currently support whitelisting default imports, so `import myFunctionOrVariable from 'my-package'` would always be invalid when used in `cssMap`.
|
|
947
|
-
|
|
948
|
-
## no-margin
|
|
949
|
-
|
|
950
|
-
Using margins to define spacing results in components that can't be readily reused in other contexts breaking the composition model.
|
|
951
|
-
Instead defining spacing in parents with flex and grid using the `gap` property will result in more resilient experiences.
|
|
952
|
-
|
|
953
|
-
<h3>Examples</h3>
|
|
954
|
-
|
|
955
|
-
This rule will mark all margin use as violations.
|
|
956
|
-
|
|
957
|
-
#### Incorrect
|
|
958
|
-
|
|
959
|
-
```tsx
|
|
960
|
-
css({ margin: '10px' });
|
|
961
|
-
```
|
|
962
|
-
|
|
963
|
-
#### Correct
|
|
964
|
-
|
|
965
|
-
```tsx
|
|
966
|
-
css({ gap: token('spacing.100') });
|
|
967
|
-
```
|
|
968
|
-
|
|
969
|
-
## no-nested-styles
|
|
970
|
-
|
|
971
|
-
Disallows using nested styles. Nested styles can change unexpectedly when child markup changes and result in duplicates when extracting to CSS.
|
|
972
|
-
|
|
973
|
-
<h3>Examples</h3>
|
|
974
|
-
|
|
975
|
-
This rule checks for nested styles inside `css` objects.
|
|
976
|
-
This rule has no options.
|
|
977
|
-
|
|
978
|
-
#### Incorrect
|
|
979
|
-
|
|
980
|
-
```js
|
|
981
|
-
css({
|
|
982
|
-
div: {
|
|
983
|
-
color: 'red',
|
|
984
|
-
},
|
|
985
|
-
});
|
|
986
|
-
```
|
|
987
|
-
|
|
988
|
-
```js
|
|
989
|
-
css({
|
|
990
|
-
'@media (min-width: 480px)': {
|
|
991
|
-
color: 'red',
|
|
992
|
-
},
|
|
993
|
-
});
|
|
994
|
-
```
|
|
995
|
-
|
|
996
|
-
#### Correct
|
|
997
|
-
|
|
998
|
-
```js
|
|
999
|
-
css({
|
|
1000
|
-
color: 'red',
|
|
1001
|
-
':hover': {
|
|
1002
|
-
color: 'black',
|
|
1003
|
-
},
|
|
1004
|
-
});
|
|
1005
|
-
```
|
|
1006
|
-
|
|
1007
|
-
```js
|
|
1008
|
-
import { media } from '@atlaskit/primitives';
|
|
1009
|
-
|
|
1010
|
-
css({
|
|
1011
|
-
[media.above.xs]: {
|
|
1012
|
-
color: 'red',
|
|
1013
|
-
},
|
|
1014
|
-
});
|
|
1015
|
-
```
|
|
1016
|
-
|
|
1017
|
-
## no-physical-properties
|
|
1018
|
-
|
|
1019
|
-
Disallows using physical properties. Physical properties
|
|
1020
|
-
prevent correct support for different reading modes and languages and
|
|
1021
|
-
should be avoided. Rule will autofix applicable physical properties
|
|
1022
|
-
to instead use [logical properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_logical_properties_and_values/Basic_concepts_of_logical_properties_and_values).
|
|
1023
|
-
|
|
1024
|
-
<h3>Examples</h3>
|
|
1025
|
-
|
|
1026
|
-
This rule checks for physical property usage inside of `css` function calls.
|
|
1027
|
-
|
|
1028
|
-
#### Incorrect
|
|
1029
|
-
|
|
1030
|
-
```js
|
|
1031
|
-
css({
|
|
1032
|
-
left: 0,
|
|
1033
|
-
right: 0,
|
|
1034
|
-
top: 0,
|
|
1035
|
-
bottom: 0,
|
|
1036
|
-
});
|
|
1037
|
-
```
|
|
1038
|
-
|
|
1039
|
-
```js
|
|
1040
|
-
css({
|
|
1041
|
-
marginLeft: 0,
|
|
1042
|
-
});
|
|
1043
|
-
```
|
|
1044
|
-
|
|
1045
|
-
```js
|
|
1046
|
-
css({
|
|
1047
|
-
textAlign: 'left',
|
|
1048
|
-
});
|
|
1049
|
-
```
|
|
1050
|
-
|
|
1051
|
-
#### Correct
|
|
1052
|
-
|
|
1053
|
-
```js
|
|
1054
|
-
css({
|
|
1055
|
-
inset: 0,
|
|
1056
|
-
});
|
|
1057
|
-
```
|
|
1058
|
-
|
|
1059
|
-
```js
|
|
1060
|
-
css({
|
|
1061
|
-
marginInlineStart: 0,
|
|
1062
|
-
});
|
|
1063
|
-
```
|
|
1064
|
-
|
|
1065
|
-
```js
|
|
1066
|
-
css({
|
|
1067
|
-
textAlign: 'start',
|
|
1068
|
-
});
|
|
1069
|
-
```
|
|
1070
|
-
|
|
1071
|
-
## no-unsafe-design-token-usage
|
|
1072
|
-
|
|
1073
|
-
Using design tokens in an unsafe way risks the health of the system and will effect how fast your codebase can migrate between versions.
|
|
1074
|
-
|
|
1075
|
-
<h3>Examples</h3>
|
|
1076
|
-
|
|
1077
|
-
This rule will mark design token usage that is not statically and locally analyzable,
|
|
1078
|
-
as well as design tokens that are considered deleted.
|
|
1079
|
-
|
|
1080
|
-
<h3>Incorrect</h3>
|
|
1081
|
-
|
|
1082
|
-
```js
|
|
1083
|
-
const textColor = 'red';
|
|
1084
|
-
|
|
1085
|
-
css({ color: textColor });
|
|
1086
|
-
^^^^^^^^^ must be a string literal
|
|
1087
|
-
```
|
|
1088
|
-
|
|
1089
|
-
```js
|
|
1090
|
-
css({ boxShadow: '0px 1px 1px var(--ds-accent-subtleBlue)' });
|
|
1091
|
-
^^^^^^^^^^^^^^^^^^^^^^^^^^ must use the token() function
|
|
1092
|
-
```
|
|
1093
|
-
|
|
1094
|
-
<h3>Correct</h3>
|
|
1095
|
-
|
|
1096
|
-
```js
|
|
1097
|
-
import { token } from '@atlaskit/tokens';
|
|
1098
|
-
|
|
1099
|
-
css({ boxShadow: token('elevation.shadow.card') });
|
|
1100
|
-
|
|
1101
|
-
css`
|
|
1102
|
-
color: ${(token('color.text.highemphasis'), N20)};
|
|
1103
|
-
`;
|
|
1104
|
-
```
|
|
1105
|
-
|
|
1106
|
-
<h3>Options</h3>
|
|
1107
|
-
|
|
1108
|
-
This rule comes with options to aid in migrating to design tokens.
|
|
1109
|
-
|
|
1110
|
-
#### fallbackUsage
|
|
1111
|
-
|
|
1112
|
-
- `forced`: Fallback values must always be provided
|
|
1113
|
-
- `none`: Fallback values must never be provided. (Fixer will remove is provided)
|
|
1114
|
-
- `optional`: Fallbacks are optional
|
|
1115
|
-
|
|
1116
|
-
#### shouldEnforceFallbacks (deprecated)
|
|
1117
|
-
|
|
1118
|
-
When `true` the rule will mark token function usage as violations when fallbacks aren't defined.
|
|
1119
|
-
When `false` the rule will mark token function usage as violations when fallbacks are defined.
|
|
1120
|
-
|
|
1121
|
-
## no-unsafe-style-overrides
|
|
1122
|
-
|
|
1123
|
-
Unsafe style overrides cause friction and incidents when internals of the component you're overriding change. They're inherently unbounded and everything is API that can change at a moments notice.
|
|
1124
|
-
|
|
1125
|
-
Instead, lean on composition, primitive components, and safe style overrides via the `xcss` prop where component authors declare what styles they want to support.
|
|
1126
|
-
|
|
1127
|
-
<h3>Examples</h3>
|
|
1128
|
-
|
|
1129
|
-
#### Incorrect
|
|
1130
|
-
|
|
1131
|
-
```tsx
|
|
1132
|
-
import Button from '@atlaskit/button';
|
|
1133
|
-
|
|
1134
|
-
<Button css={{ fontWeight: 500 }}>foo</Button>;
|
|
1135
|
-
^^^
|
|
1136
|
-
```
|
|
1137
|
-
|
|
1138
|
-
```tsx
|
|
1139
|
-
import { LinkItem } from '@atlaskit/menu';
|
|
1140
|
-
|
|
1141
|
-
<LinkItem cssFn={() => ({ '> div > div': { padding: 2 } })} />;
|
|
1142
|
-
^^^^^
|
|
1143
|
-
```
|
|
1144
|
-
|
|
1145
|
-
```tsx
|
|
1146
|
-
import { ButtonItem } from '@atlaskit/side-navigation';
|
|
1147
|
-
|
|
1148
|
-
<ButtonItem className="text-neutral-400" />;
|
|
1149
|
-
^^^^^^^^^
|
|
1150
|
-
```
|
|
1151
|
-
|
|
1152
|
-
#### Correct
|
|
1153
|
-
|
|
1154
|
-
```tsx
|
|
1155
|
-
<Button>
|
|
1156
|
-
<strong>foo</strong>
|
|
1157
|
-
</Button>
|
|
1158
|
-
```
|
|
1159
|
-
|
|
1160
|
-
```tsx
|
|
1161
|
-
const styles = css({ padding: 'var(--ds-space-100)' });
|
|
1162
|
-
|
|
1163
|
-
<Box as="a" xcss={styles}>
|
|
1164
|
-
<Stack>
|
|
1165
|
-
<Inline />
|
|
1166
|
-
<Inline />
|
|
1167
|
-
</Stack>
|
|
1168
|
-
</Box>;
|
|
1169
|
-
```
|
|
1170
|
-
|
|
1171
|
-
## no-unsupported-drag-and-drop-libraries
|
|
1172
|
-
|
|
1173
|
-
We encourage the use of Pragmatic drag and drop to power all drag and drop experiences - from table to external files. Pragmatic drag and drop is a performance optimised drag and drop framework that has been designed to power any drag and drop experience on any tech stack. Please avoid using alternative drag and drop libraries as it will lead to poorer performance, increased maintenance costs, (likely) worse accessibility and fragmented user experiences. See https://staging.atlassian.design/components/pragmatic-drag-and-drop/
|
|
1174
|
-
|
|
1175
|
-
<h3>Examples</h3>
|
|
1176
|
-
|
|
1177
|
-
Libraries such as `react-beautiful-dnd` and `@atlassian/jira-dnd` that are no longer supported, as well as external libraries such as `react-dnd` and `react-sortable-hoc`.
|
|
1178
|
-
|
|
1179
|
-
#### Incorrect
|
|
1180
|
-
|
|
1181
|
-
```ts
|
|
1182
|
-
import { DraggableLocation } from 'react-beautiful-dnd';
|
|
1183
|
-
^^^^^^^^^^^^^^^^^^^
|
|
1184
|
-
|
|
1185
|
-
import { useDrag } from 'react-dnd'
|
|
1186
|
-
^^^^^^^^^
|
|
1187
|
-
```
|
|
1188
|
-
|
|
1189
|
-
## prefer-primitives
|
|
1190
|
-
|
|
1191
|
-
Using primitives allows you to delete bespoke component code and replace it with ready made solutions made by the Atlassian Design System Team.
|
|
1192
|
-
|
|
1193
|
-
<h3>Examples</h3>
|
|
1194
|
-
|
|
1195
|
-
This rule marks code as violations when it may be able to be replaced with a primitive component.
|
|
1196
|
-
|
|
1197
|
-
#### Incorrect
|
|
1198
|
-
|
|
1199
|
-
```js
|
|
1200
|
-
<div />
|
|
1201
|
-
^^^^^^^
|
|
1202
|
-
|
|
1203
|
-
<Component>
|
|
1204
|
-
<div css={someStyles}></div>
|
|
1205
|
-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
1206
|
-
</Component>
|
|
1207
|
-
```
|
|
1208
|
-
|
|
1209
|
-
#### Correct
|
|
1210
|
-
|
|
1211
|
-
```js
|
|
1212
|
-
<Box />
|
|
1213
|
-
```
|
|
1214
|
-
|
|
1215
|
-
```js
|
|
1216
|
-
<Component>
|
|
1217
|
-
<Box xcss={someStyles}></Box>
|
|
1218
|
-
</Component>
|
|
1219
|
-
```
|
|
1220
|
-
|
|
1221
|
-
## use-button-group-label
|
|
1222
|
-
|
|
1223
|
-
ButtonGroup should have an accessible name or a reference to it, so that upon opening, users of assistive technologies could have contextual information of interaction with current element.
|
|
1224
|
-
|
|
1225
|
-
<h3>Examples</h3>
|
|
1226
|
-
|
|
1227
|
-
This rule will indicate user with warning to strongly recommend usage of either `label` or `titleId` prop.
|
|
1228
|
-
|
|
1229
|
-
#### Incorrect
|
|
1230
|
-
|
|
1231
|
-
```tsx
|
|
1232
|
-
<ButtonGroup>
|
|
1233
|
-
^^^^^^^^^^^ Missing either `label` or `titleId` prop.
|
|
1234
|
-
<Button>Save</Button>
|
|
1235
|
-
<Button>Edit</Button>
|
|
1236
|
-
<Button>Delete</Button>
|
|
1237
|
-
</ButtonGroup>
|
|
1238
|
-
|
|
1239
|
-
<ButtonGroup label="">
|
|
1240
|
-
^^^^^ `label` prop is missing accessible name value.
|
|
1241
|
-
<Button>Save</Button>
|
|
1242
|
-
<Button>Edit</Button>
|
|
1243
|
-
<Button>Delete</Button>
|
|
1244
|
-
</ButtonGroup>
|
|
1245
|
-
|
|
1246
|
-
<h2 id="button-group-title">ButtonGroup content title</hi>
|
|
1247
|
-
<ButtonGroup titleId="">
|
|
1248
|
-
^^^^^^^ `titleId` prop is missing reference value.
|
|
1249
|
-
<Button>Save</Button>
|
|
1250
|
-
<Button>Edit</Button>
|
|
1251
|
-
<Button>Delete</Button>
|
|
1252
|
-
</ButtonGroup>
|
|
1253
|
-
|
|
1254
|
-
<h2 id="button-group-title">ButtonGroup content title</h2>
|
|
1255
|
-
<ButtonGroup titleId="button-group-title" label="">
|
|
1256
|
-
^^^^^^^ ^^^^^ Do not include both `titleId` and `label` properties. Use `titleId` if the label text is available in the DOM to reference it, otherwise use `label` to provide accessible name explicitly.
|
|
1257
|
-
<Button>Save</Button>
|
|
1258
|
-
<Button>Edit</Button>
|
|
1259
|
-
<Button>Delete</Button>
|
|
1260
|
-
</ButtonGroup>
|
|
1261
|
-
```
|
|
1262
|
-
|
|
1263
|
-
#### Correct
|
|
1264
|
-
|
|
1265
|
-
```tsx
|
|
1266
|
-
<ButtonGroup label="ButtonGroup content title">
|
|
1267
|
-
<Button>Save</Button>
|
|
1268
|
-
<Button>Edit</Button>
|
|
1269
|
-
<Button>Delete</Button>
|
|
1270
|
-
</ButtonGroup>
|
|
1271
|
-
|
|
1272
|
-
<h2 id="button-group-title">ButtonGroup content title</h2>
|
|
1273
|
-
<ButtonGroup titleId="button-group-title">
|
|
1274
|
-
<Button>Save</Button>
|
|
1275
|
-
<Button>Edit</Button>
|
|
1276
|
-
<Button>Delete</Button>
|
|
1277
|
-
</ButtonGroup>
|
|
1278
|
-
```
|
|
1279
|
-
|
|
1280
|
-
## use-drawer-label
|
|
1281
|
-
|
|
1282
|
-
Drawer should have an accessible name or a reference to it, so that upon opening, users of assistive technologies could have contextual information of interaction with current element.
|
|
1283
|
-
|
|
1284
|
-
<h3>Examples</h3>
|
|
1285
|
-
|
|
1286
|
-
This rule will indicate user with warning to strongly recommend usage of either `label` or `titleId` prop.
|
|
1287
|
-
|
|
1288
|
-
#### Incorrect
|
|
1289
|
-
|
|
1290
|
-
```tsx
|
|
1291
|
-
<Drawer>
|
|
1292
|
-
^^^^^^ Missing either `label` or `titleId` prop.
|
|
1293
|
-
Drawer content
|
|
1294
|
-
</Drawer>
|
|
1295
|
-
|
|
1296
|
-
<Drawer label>
|
|
1297
|
-
^^^^^ `label` prop is missing value.
|
|
1298
|
-
Drawer content
|
|
1299
|
-
</Drawer>
|
|
1300
|
-
|
|
1301
|
-
<Drawer label="">
|
|
1302
|
-
^^^^^ `label` prop is missing accessible name value.
|
|
1303
|
-
Drawer content
|
|
1304
|
-
</Drawer>
|
|
1305
|
-
|
|
1306
|
-
<Drawer titleId>
|
|
1307
|
-
^^^^^^^ `titleId` prop is missing reference value.
|
|
1308
|
-
<h1 id="drawer-title">Drawer content title</hi>
|
|
1309
|
-
</Drawer>
|
|
1310
|
-
|
|
1311
|
-
<Drawer titleId="">
|
|
1312
|
-
^^^^^^^ `titleId` prop is missing reference value.
|
|
1313
|
-
<h1 id="drawer-title">Drawer content title</hi>
|
|
1314
|
-
</Drawer>
|
|
1315
|
-
|
|
1316
|
-
<Drawer titleId="drawer-title" label="">
|
|
1317
|
-
^^^^^^^ ^^^^^ Do not include both `titleId` and `label` properties. Use `titleId` if the label text is available in the DOM to reference it, otherwise use `label` to provide accessible name explicitly.
|
|
1318
|
-
<h1 id="drawer-title">Drawer content title</hi>
|
|
1319
|
-
</Drawer>
|
|
1320
|
-
```
|
|
1321
|
-
|
|
1322
|
-
#### Correct
|
|
1323
|
-
|
|
1324
|
-
```tsx
|
|
1325
|
-
<Drawer label="Drawer content title">
|
|
1326
|
-
Drawer content
|
|
1327
|
-
</Drawer>
|
|
1328
|
-
|
|
1329
|
-
<Drawer titleId="drawer-title">
|
|
1330
|
-
<h1 id="drawer-title">Drawer content title</hi>
|
|
1331
|
-
</Drawer>
|
|
1332
|
-
```
|
|
1333
|
-
|
|
1334
|
-
## use-heading-level-in-spotlight-card
|
|
1335
|
-
|
|
1336
|
-
The `SpotlightCard` component in `@atlaskit/onboarding` will be requiring the `headingLevel` prop in future releases.
|
|
1337
|
-
|
|
1338
|
-
<h3>Examples</h3>
|
|
1339
|
-
|
|
1340
|
-
#### Incorrect
|
|
1341
|
-
|
|
1342
|
-
```tsx
|
|
1343
|
-
<SpotlightCard heading="Heading">Spotlight card contents</SpotlightCard>
|
|
1344
|
-
^^^^^^^^^^^^^
|
|
1345
|
-
```
|
|
1346
|
-
|
|
1347
|
-
#### Correct
|
|
1348
|
-
|
|
1349
|
-
```tsx
|
|
1350
|
-
<SpotlightCard heading="Heading" headingLevel={2}>
|
|
1351
|
-
Spotlight card contents
|
|
1352
|
-
</SpotlightCard>
|
|
1353
|
-
```
|
|
1354
|
-
|
|
1355
|
-
## use-href-in-link-item
|
|
1356
|
-
|
|
1357
|
-
The `LinkItem` component in `@atlaskit/menu` will be requiring the `href` prop in future releases. If no valid `href` prop is required, consider using the `ButtonItem` component.
|
|
1358
|
-
|
|
1359
|
-
<h3>Examples</h3>
|
|
1360
|
-
|
|
1361
|
-
#### Incorrect
|
|
1362
|
-
|
|
1363
|
-
```tsx
|
|
1364
|
-
<LinkItem>Button</LinkItem>
|
|
1365
|
-
^^^^^^^^
|
|
1366
|
-
```
|
|
1367
|
-
|
|
1368
|
-
#### Correct
|
|
1369
|
-
|
|
1370
|
-
```tsx
|
|
1371
|
-
<LinkItem href="http://example.com">Link</LinkItem>
|
|
1372
|
-
```
|
|
1373
|
-
|
|
1374
|
-
## use-primitives
|
|
1375
|
-
|
|
1376
|
-
Using primitives allows you to delete bespoke component code and replace it with ready made solutions made by the Atlassian Design System Team.
|
|
1377
|
-
|
|
1378
|
-
<h3>Examples</h3>
|
|
1379
|
-
|
|
1380
|
-
This rule marks code as violations when it can be replaced 1:1 with a primitive component.
|
|
1381
|
-
|
|
1382
|
-
#### Incorrect
|
|
1383
|
-
|
|
1384
|
-
```jsx
|
|
1385
|
-
const someStyles = css({
|
|
1386
|
-
padding: '8px';
|
|
1387
|
-
})
|
|
1388
|
-
|
|
1389
|
-
<div css={someStyles}>
|
|
1390
|
-
^^^^^^^^^^^^^^^^^^^^^^
|
|
1391
|
-
// ...
|
|
1392
|
-
</div>
|
|
1393
|
-
```
|
|
1394
|
-
|
|
1395
|
-
#### Correct
|
|
1396
|
-
|
|
1397
|
-
```jsx
|
|
1398
|
-
const someStyles = xcss({
|
|
1399
|
-
padding: 'space.100';
|
|
1400
|
-
})
|
|
1401
|
-
|
|
1402
|
-
<Box xcss={someStyles}>
|
|
1403
|
-
// ...
|
|
1404
|
-
</Box>
|
|
1405
|
-
```
|
|
1406
|
-
|
|
1407
|
-
Currently, the rule is extremely defensive, only reporting on `css` styles that contain:
|
|
1408
|
-
|
|
1409
|
-
- one, and only one, style property from this list:
|
|
1410
|
-
|
|
1411
|
-
- padding
|
|
1412
|
-
- paddingBlock
|
|
1413
|
-
- paddingBlockEnd
|
|
1414
|
-
- paddingBlockStart
|
|
1415
|
-
- paddingBottom
|
|
1416
|
-
- paddingInline
|
|
1417
|
-
- paddingInlineEnd
|
|
1418
|
-
- paddingInlineStart
|
|
1419
|
-
- paddingLeft
|
|
1420
|
-
- paddingRight
|
|
1421
|
-
- paddingTop
|
|
1422
|
-
- margin
|
|
1423
|
-
- marginBlock
|
|
1424
|
-
- marginBlockEnd
|
|
1425
|
-
- marginBlockStart
|
|
1426
|
-
- marginBottom
|
|
1427
|
-
- marginInline
|
|
1428
|
-
- marginInlineEnd
|
|
1429
|
-
- marginInlineStart
|
|
1430
|
-
- marginLeft
|
|
1431
|
-
- marginRight
|
|
1432
|
-
- marginTop
|
|
1433
|
-
|
|
1434
|
-
- and where the style value is one of:
|
|
1435
|
-
- 0px
|
|
1436
|
-
- 2px
|
|
1437
|
-
- 4px
|
|
1438
|
-
- 6px
|
|
1439
|
-
- 8px
|
|
1440
|
-
- 12px
|
|
1441
|
-
- 16px
|
|
1442
|
-
- 20px
|
|
1443
|
-
- 24px
|
|
1444
|
-
- 32px
|
|
1445
|
-
- 40px
|
|
1446
|
-
- 48px
|
|
1447
|
-
- 64px
|
|
1448
|
-
- 80px
|
|
1449
|
-
|
|
1450
|
-
If these conditions are not met, then no violation will be reported.
|
|
1451
|
-
|
|
1452
|
-
## use-visually-hidden
|
|
1453
|
-
|
|
1454
|
-
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.
|
|
1455
|
-
|
|
1456
|
-
<h3>Examples</h3>
|
|
1457
|
-
|
|
1458
|
-
This rule marks code as violations when it can be replaced 1:1 with the visually hidden component.
|
|
1459
|
-
|
|
1460
|
-
#### Incorrect
|
|
1461
|
-
|
|
1462
|
-
```js
|
|
1463
|
-
import { css } from '@emotion/core';
|
|
1464
|
-
import { visuallyHidden } from '@atlaskit/theme/constants';
|
|
1465
|
-
|
|
1466
|
-
const visuallyHiddenStyles = css({
|
|
1467
|
-
width: '1px',
|
|
1468
|
-
height: '1px',
|
|
1469
|
-
padding: '0',
|
|
1470
|
-
position: 'absolute',
|
|
1471
|
-
border: '0',
|
|
1472
|
-
clip: 'rect(1px, 1px, 1px, 1px)',
|
|
1473
|
-
overflow: 'hidden',
|
|
1474
|
-
whiteSpace: 'nowrap',
|
|
1475
|
-
});
|
|
1476
|
-
|
|
1477
|
-
const VisuallyHidden = styled.span`${visuallyHidden()}`;
|
|
1478
|
-
^^^^^^^^^^^^^^
|
|
1479
|
-
```
|
|
1480
|
-
|
|
1481
|
-
#### Correct
|
|
1482
|
-
|
|
1483
|
-
```js
|
|
1484
|
-
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
1485
|
-
```
|
|
1486
|
-
|
|
1487
|
-
<!-- END_RULE_CONTENT_CODEGEN -->
|