@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.
Files changed (112) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +31 -29
  3. package/constellation/consistent-css-prop-usage/usage.mdx +193 -0
  4. package/constellation/ensure-design-token-usage/usage.mdx +72 -0
  5. package/constellation/ensure-design-token-usage-preview/usage.mdx +5 -0
  6. package/constellation/icon-label/usage.mdx +39 -0
  7. package/constellation/index/usage.mdx +31 -1474
  8. package/constellation/local-cx-xcss/usage.mdx +37 -0
  9. package/constellation/no-banned-imports/usage.mdx +17 -0
  10. package/constellation/no-css-tagged-template-expression/usage.mdx +66 -0
  11. package/constellation/no-deprecated-apis/usage.mdx +76 -0
  12. package/constellation/no-deprecated-design-token-usage/usage.mdx +27 -0
  13. package/constellation/no-deprecated-imports/usage.mdx +62 -0
  14. package/constellation/no-empty-styled-expression/usage.mdx +77 -0
  15. package/constellation/no-exported-css/usage.mdx +50 -0
  16. package/constellation/no-exported-keyframes/usage.mdx +50 -0
  17. package/constellation/no-invalid-css-map/usage.mdx +199 -0
  18. package/constellation/no-keyframes-tagged-template-expression/usage.mdx +76 -0
  19. package/constellation/no-margin/usage.mdx +20 -0
  20. package/constellation/no-nested-styles/usage.mdx +47 -0
  21. package/constellation/no-physical-properties/usage.mdx +53 -0
  22. package/constellation/no-styled-tagged-template-expression/usage.mdx +90 -0
  23. package/constellation/no-unsafe-design-token-usage/usage.mdx +49 -0
  24. package/constellation/no-unsafe-style-overrides/usage.mdx +49 -0
  25. package/constellation/no-unsupported-drag-and-drop-libraries/usage.mdx +17 -0
  26. package/constellation/prefer-primitives/usage.mdx +31 -0
  27. package/constellation/use-button-group-label/usage.mdx +58 -0
  28. package/constellation/use-drawer-label/usage.mdx +53 -0
  29. package/constellation/use-heading-level-in-spotlight-card/usage.mdx +20 -0
  30. package/constellation/use-href-in-link-item/usage.mdx +18 -0
  31. package/constellation/use-primitives/usage.mdx +77 -0
  32. package/constellation/use-visually-hidden/usage.mdx +34 -0
  33. package/dist/cjs/presets/all.codegen.js +3 -1
  34. package/dist/cjs/rules/consistent-css-prop-usage/index.js +254 -32
  35. package/dist/cjs/rules/index.codegen.js +5 -1
  36. package/dist/cjs/rules/no-css-tagged-template-expression/index.js +3 -2
  37. package/dist/cjs/rules/no-keyframes-tagged-template-expression/index.js +27 -0
  38. package/dist/cjs/rules/no-styled-tagged-template-expression/index.js +27 -0
  39. package/dist/cjs/rules/no-styled-tagged-template-expression/is-styled.js +53 -0
  40. package/dist/cjs/rules/utils/create-no-exported-rule/is-styled-component.js +6 -10
  41. package/dist/cjs/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/index.js +26 -6
  42. package/dist/cjs/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/to-arguments.js +28 -2
  43. package/dist/cjs/rules/utils/create-rule.js +7 -5
  44. package/dist/cjs/rules/utils/get-first-supported-import.js +28 -0
  45. package/dist/cjs/rules/utils/is-supported-import.js +9 -11
  46. package/dist/es2019/presets/all.codegen.js +3 -1
  47. package/dist/es2019/rules/consistent-css-prop-usage/index.js +251 -33
  48. package/dist/es2019/rules/index.codegen.js +5 -1
  49. package/dist/es2019/rules/no-css-tagged-template-expression/index.js +3 -2
  50. package/dist/es2019/rules/no-keyframes-tagged-template-expression/index.js +21 -0
  51. package/dist/es2019/rules/no-styled-tagged-template-expression/index.js +21 -0
  52. package/dist/es2019/rules/no-styled-tagged-template-expression/is-styled.js +45 -0
  53. package/dist/es2019/rules/utils/create-no-exported-rule/is-styled-component.js +4 -8
  54. package/dist/es2019/rules/utils/create-no-tagged-template-expression-rule/index.js +84 -0
  55. package/dist/es2019/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/to-arguments.js +28 -2
  56. package/dist/es2019/rules/utils/create-rule.js +7 -5
  57. package/dist/es2019/rules/utils/get-first-supported-import.js +22 -0
  58. package/dist/es2019/rules/utils/is-supported-import.js +9 -9
  59. package/dist/esm/presets/all.codegen.js +3 -1
  60. package/dist/esm/rules/consistent-css-prop-usage/index.js +255 -33
  61. package/dist/esm/rules/index.codegen.js +5 -1
  62. package/dist/esm/rules/no-css-tagged-template-expression/index.js +3 -2
  63. package/dist/esm/rules/no-keyframes-tagged-template-expression/index.js +21 -0
  64. package/dist/esm/rules/no-styled-tagged-template-expression/index.js +21 -0
  65. package/dist/esm/rules/no-styled-tagged-template-expression/is-styled.js +47 -0
  66. package/dist/esm/rules/utils/create-no-exported-rule/is-styled-component.js +6 -10
  67. package/dist/esm/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/index.js +25 -5
  68. package/dist/esm/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/to-arguments.js +28 -2
  69. package/dist/esm/rules/utils/create-rule.js +7 -5
  70. package/dist/esm/rules/utils/get-first-supported-import.js +22 -0
  71. package/dist/esm/rules/utils/is-supported-import.js +9 -10
  72. package/dist/types/index.codegen.d.ts +2 -0
  73. package/dist/types/presets/all.codegen.d.ts +3 -1
  74. package/dist/types/rules/consistent-css-prop-usage/types.d.ts +7 -2
  75. package/dist/types/rules/index.codegen.d.ts +2 -0
  76. package/dist/types/rules/no-keyframes-tagged-template-expression/index.d.ts +2 -0
  77. package/dist/types/rules/no-styled-tagged-template-expression/index.d.ts +2 -0
  78. package/dist/types/rules/no-styled-tagged-template-expression/is-styled.d.ts +7 -0
  79. package/dist/types/rules/use-primitives/utils/update-jsx-attribute-by-name.d.ts +1 -1
  80. package/dist/types/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/index.d.ts +3 -1
  81. package/dist/types/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/types.d.ts +3 -0
  82. package/dist/types/rules/utils/get-first-supported-import.d.ts +17 -0
  83. package/dist/types/rules/utils/is-supported-import.d.ts +6 -5
  84. package/dist/types-ts4.5/index.codegen.d.ts +2 -0
  85. package/dist/types-ts4.5/presets/all.codegen.d.ts +3 -1
  86. package/dist/types-ts4.5/rules/consistent-css-prop-usage/types.d.ts +7 -2
  87. package/dist/types-ts4.5/rules/index.codegen.d.ts +2 -0
  88. package/dist/types-ts4.5/rules/no-keyframes-tagged-template-expression/index.d.ts +2 -0
  89. package/dist/types-ts4.5/rules/no-styled-tagged-template-expression/index.d.ts +2 -0
  90. package/dist/types-ts4.5/rules/no-styled-tagged-template-expression/is-styled.d.ts +7 -0
  91. package/dist/types-ts4.5/rules/use-primitives/utils/update-jsx-attribute-by-name.d.ts +1 -1
  92. package/dist/types-ts4.5/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/index.d.ts +3 -1
  93. package/dist/types-ts4.5/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/types.d.ts +3 -0
  94. package/dist/types-ts4.5/rules/utils/get-first-supported-import.d.ts +17 -0
  95. package/dist/types-ts4.5/rules/utils/is-supported-import.d.ts +6 -5
  96. package/package.json +3 -1
  97. package/dist/es2019/rules/no-css-tagged-template-expression/create-no-tagged-template-expression-rule/index.js +0 -62
  98. /package/dist/cjs/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/generate.js +0 -0
  99. /package/dist/cjs/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/get-tagged-template-expression-offset.js +0 -0
  100. /package/dist/cjs/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/types.js +0 -0
  101. /package/dist/es2019/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/generate.js +0 -0
  102. /package/dist/es2019/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/get-tagged-template-expression-offset.js +0 -0
  103. /package/dist/es2019/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/types.js +0 -0
  104. /package/dist/esm/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/generate.js +0 -0
  105. /package/dist/esm/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/get-tagged-template-expression-offset.js +0 -0
  106. /package/dist/esm/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/types.js +0 -0
  107. /package/dist/types/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/generate.d.ts +0 -0
  108. /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
  109. /package/dist/types/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/to-arguments.d.ts +0 -0
  110. /package/dist/types-ts4.5/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/generate.d.ts +0 -0
  111. /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
  112. /package/dist/types-ts4.5/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/to-arguments.d.ts +0 -0
@@ -0,0 +1,76 @@
1
+ # no-keyframes-tagged-template-expression
2
+
3
+ Disallows any `keyframes` tagged template expressions that originate from `@emotion/react`, `@emotion/core`, `compiled/react` or `styled-components`.
4
+
5
+ Tagged template expressions are difficult to parse correctly (which can lead to more frequent build failures or invalid CSS generation), have limited type safety, and lack syntax highlighting. These problems can be avoided by using the preferred call expression syntax instead.
6
+
7
+ Thank you to the [Compiled team for their rule](https://github.com/atlassian-labs/compiled/tree/master/packages/eslint-plugin/src/rules/no-keyframes-tagged-template-expression) from which this was ported.
8
+
9
+ ---
10
+
11
+ The `--fix` option on the command line automatically fixes problems reported by this rule.
12
+
13
+ ## Examples
14
+
15
+ ### Incorrect
16
+
17
+ ```js
18
+ import { keyframes } from '@compiled/react';
19
+
20
+ keyframes`to { opacity: 0 }`;
21
+
22
+ const fadeOut = keyframes`
23
+ from {
24
+ opacity: 1;
25
+ }
26
+ to {
27
+ opacity: 0;
28
+ }
29
+ `;
30
+ ```
31
+
32
+ ### Correct
33
+
34
+ ```js
35
+ import { keyframes } from '@compiled/react';
36
+
37
+ keyframes({ to: { opacity: 0 } });
38
+
39
+ const fadeOut = keyframes({
40
+ from: {
41
+ opacity: 1,
42
+ },
43
+ to: {
44
+ opacity: 0,
45
+ },
46
+ });
47
+ ```
48
+
49
+ ## Options
50
+
51
+ ### importSources
52
+
53
+ By default, this rule will check `keyframes` usages from:
54
+
55
+ - `@atlaskit/css`
56
+ - `@atlaskit/primitives`
57
+ - `@compiled/react`
58
+ - `@emotion/react`
59
+ - `@emotion/core`
60
+ - `@emotion/styled`
61
+ - `styled-components`
62
+
63
+ To change this list of libraries, you can define a custom set of `importSources`, which accepts an array of package names (strings).
64
+
65
+ ```tsx
66
+ // [{ importSources: ['other-lib'] }]
67
+
68
+ import { keyframes } from 'other-lib';
69
+
70
+ // Invalid!
71
+ export const animation = keyframes``;
72
+ ```
73
+
74
+ ## Limitations
75
+
76
+ - Comments are not fixable
@@ -0,0 +1,20 @@
1
+ # no-margin
2
+
3
+ Using margins to define spacing results in components that can't be readily reused in other contexts breaking the composition model.
4
+ Instead defining spacing in parents with flex and grid using the `gap` property will result in more resilient experiences.
5
+
6
+ ## Examples
7
+
8
+ This rule will mark all margin use as violations.
9
+
10
+ ### Incorrect
11
+
12
+ ```tsx
13
+ css({ margin: '10px' });
14
+ ```
15
+
16
+ ### Correct
17
+
18
+ ```tsx
19
+ css({ gap: token('spacing.100') });
20
+ ```
@@ -0,0 +1,47 @@
1
+ # no-nested-styles
2
+
3
+ Disallows using nested styles. Nested styles can change unexpectedly when child markup changes and result in duplicates when extracting to CSS.
4
+
5
+ ## Examples
6
+
7
+ This rule checks for nested styles inside `css` objects.
8
+ 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
+ ```
@@ -0,0 +1,53 @@
1
+ # no-physical-properties
2
+
3
+ Disallows using physical properties. Physical properties
4
+ prevent correct support for different reading modes and languages and
5
+ should be avoided. Rule will autofix applicable physical properties
6
+ 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).
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
+ ```
@@ -0,0 +1,90 @@
1
+ # no-styled-tagged-template-expression
2
+
3
+ Disallows any `styled` tagged template expressions that originate from `@emotion/react`, `@emotion/core`, `compiled/react` or `styled-components`.
4
+
5
+ Tagged template expressions are difficult to parse correctly (which can lead to more frequent build failures or invalid CSS generation), have limited type safety, and lack syntax highlighting. These problems can be avoided by using the preferred call expression syntax instead.
6
+
7
+ ---
8
+
9
+ The `--fix` option on the command line automatically fixes problems reported by this rule.
10
+
11
+ ## Examples
12
+
13
+ ### Incorrect
14
+
15
+ ```js
16
+ import { styled } from '@compiled/react';
17
+
18
+ const InlinedStyles = styled.div`
19
+ color: blue;
20
+ `;
21
+
22
+ const MultilineStyles = styled.div`
23
+ color: blue;
24
+ font-weight: 500;
25
+ `;
26
+
27
+ const ComposedStyles = styled(InlinedStyles)`
28
+ font-weight: 500;
29
+ `;
30
+
31
+ const DynamicStyles = styled.div`
32
+ color: ${(props) => props.color};
33
+ ${(props) => (props.disabled ? 'opacity: 0.8' : 'opacity: 1')}
34
+ `;
35
+ ```
36
+
37
+ ### Correct
38
+
39
+ ```js
40
+ import { styled } from '@compiled/react';
41
+
42
+ const InlinedStyles = styled.div({
43
+ color: 'blue',
44
+ });
45
+
46
+ const MultilineStyles = styled.div({
47
+ color: 'blue',
48
+ fontWeight: 500,
49
+ });
50
+
51
+ const ComposedStyles = styled(InlinedStyles)({
52
+ fontWeight: 500,
53
+ });
54
+
55
+ const DynamicStyles = styled.div(
56
+ {
57
+ color: (props) => props.color,
58
+ },
59
+ (props) => (props.disabled ? 'opacity: 0.8' : 'opacity: 1'),
60
+ );
61
+ ```
62
+
63
+ ## Options
64
+
65
+ ### importSources
66
+
67
+ By default, this rule will check `styled` usages from:
68
+
69
+ - `@atlaskit/css`
70
+ - `@atlaskit/primitives`
71
+ - `@compiled/react`
72
+ - `@emotion/react`
73
+ - `@emotion/core`
74
+ - `@emotion/styled`
75
+ - `styled-components`
76
+
77
+ To change this list of libraries, you can define a custom set of `importSources`, which accepts an array of package names (strings).
78
+
79
+ ```tsx
80
+ // [{ importSources: ['other-lib'] }]
81
+
82
+ import { styled } from 'other-lib';
83
+
84
+ // Invalid!
85
+ export const Component = styled.div``;
86
+ ```
87
+
88
+ ## Limitations
89
+
90
+ - Comments are not fixable
@@ -0,0 +1,49 @@
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 codebase can migrate between versions.
4
+
5
+ ## Examples
6
+
7
+ This rule will mark design token usage that is not statically and locally analyzable,
8
+ as well as design tokens that are considered deleted.
9
+
10
+ ## Incorrect
11
+
12
+ ```js
13
+ const textColor = 'red';
14
+
15
+ css({ color: textColor });
16
+ ^^^^^^^^^ must be a string literal
17
+ ```
18
+
19
+ ```js
20
+ css({ boxShadow: '0px 1px 1px var(--ds-accent-subtleBlue)' });
21
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^ must use the token() function
22
+ ```
23
+
24
+ ## Correct
25
+
26
+ ```js
27
+ import { token } from '@atlaskit/tokens';
28
+
29
+ css({ boxShadow: token('elevation.shadow.card') });
30
+
31
+ css`
32
+ color: ${(token('color.text.highemphasis'), N20)};
33
+ `;
34
+ ```
35
+
36
+ ## Options
37
+
38
+ This rule comes with options to aid in migrating to design tokens.
39
+
40
+ ### fallbackUsage
41
+
42
+ - `forced`: Fallback values must always be provided
43
+ - `none`: Fallback values must never be provided. (Fixer will remove is provided)
44
+ - `optional`: Fallbacks are optional
45
+
46
+ ### shouldEnforceFallbacks (deprecated)
47
+
48
+ When `true` the rule will mark token function usage as violations when fallbacks aren't defined.
49
+ When `false` the rule will mark token function usage as violations when fallbacks are defined.
@@ -0,0 +1,49 @@
1
+ # no-unsafe-style-overrides
2
+
3
+ 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.
4
+
5
+ Instead, lean on composition, primitive components, and safe style overrides via the `xcss` prop where component authors declare what styles they want to support.
6
+
7
+ ## Examples
8
+
9
+ ### Incorrect
10
+
11
+ ```tsx
12
+ import Button from '@atlaskit/button';
13
+
14
+ <Button css={{ fontWeight: 500 }}>foo</Button>;
15
+ ^^^
16
+ ```
17
+
18
+ ```tsx
19
+ import { LinkItem } from '@atlaskit/menu';
20
+
21
+ <LinkItem cssFn={() => ({ '> div > div': { padding: 2 } })} />;
22
+ ^^^^^
23
+ ```
24
+
25
+ ```tsx
26
+ import { ButtonItem } from '@atlaskit/side-navigation';
27
+
28
+ <ButtonItem className="text-neutral-400" />;
29
+ ^^^^^^^^^
30
+ ```
31
+
32
+ ### Correct
33
+
34
+ ```tsx
35
+ <Button>
36
+ <strong>foo</strong>
37
+ </Button>
38
+ ```
39
+
40
+ ```tsx
41
+ const styles = css({ padding: 'var(--ds-space-100)' });
42
+
43
+ <Box as="a" xcss={styles}>
44
+ <Stack>
45
+ <Inline />
46
+ <Inline />
47
+ </Stack>
48
+ </Box>;
49
+ ```
@@ -0,0 +1,17 @@
1
+ # no-unsupported-drag-and-drop-libraries
2
+
3
+ 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/
4
+
5
+ ## Examples
6
+
7
+ 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`.
8
+
9
+ ### Incorrect
10
+
11
+ ```ts
12
+ import { DraggableLocation } from 'react-beautiful-dnd';
13
+ ^^^^^^^^^^^^^^^^^^^
14
+
15
+ import { useDrag } from 'react-dnd'
16
+ ^^^^^^^^^
17
+ ```
@@ -0,0 +1,31 @@
1
+ # prefer-primitives
2
+
3
+ Using primitives allows you to delete bespoke component code and replace it with ready made solutions made by the Atlassian Design System Team.
4
+
5
+ ## Examples
6
+
7
+ This rule marks code as violations when it may be able to be replaced with a primitive component.
8
+
9
+ ### Incorrect
10
+
11
+ ```js
12
+ <div />
13
+ ^^^^^^^
14
+
15
+ <Component>
16
+ <div css={someStyles}></div>
17
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18
+ </Component>
19
+ ```
20
+
21
+ ### Correct
22
+
23
+ ```js
24
+ <Box />
25
+ ```
26
+
27
+ ```js
28
+ <Component>
29
+ <Box xcss={someStyles}></Box>
30
+ </Component>
31
+ ```
@@ -0,0 +1,58 @@
1
+ # use-button-group-label
2
+
3
+ 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.
4
+
5
+ ## Examples
6
+
7
+ This rule will indicate user with warning to strongly recommend usage of either `label` or `titleId` prop.
8
+
9
+ ### Incorrect
10
+
11
+ ```tsx
12
+ <ButtonGroup>
13
+ ^^^^^^^^^^^ Missing either `label` or `titleId` prop.
14
+ <Button>Save</Button>
15
+ <Button>Edit</Button>
16
+ <Button>Delete</Button>
17
+ </ButtonGroup>
18
+
19
+ <ButtonGroup label="">
20
+ ^^^^^ `label` prop is missing accessible name value.
21
+ <Button>Save</Button>
22
+ <Button>Edit</Button>
23
+ <Button>Delete</Button>
24
+ </ButtonGroup>
25
+
26
+ <h2 id="button-group-title">ButtonGroup content title</hi>
27
+ <ButtonGroup titleId="">
28
+ ^^^^^^^ `titleId` prop is missing reference value.
29
+ <Button>Save</Button>
30
+ <Button>Edit</Button>
31
+ <Button>Delete</Button>
32
+ </ButtonGroup>
33
+
34
+ <h2 id="button-group-title">ButtonGroup content title</h2>
35
+ <ButtonGroup titleId="button-group-title" label="">
36
+ ^^^^^^^ ^^^^^ 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.
37
+ <Button>Save</Button>
38
+ <Button>Edit</Button>
39
+ <Button>Delete</Button>
40
+ </ButtonGroup>
41
+ ```
42
+
43
+ ### Correct
44
+
45
+ ```tsx
46
+ <ButtonGroup label="ButtonGroup content title">
47
+ <Button>Save</Button>
48
+ <Button>Edit</Button>
49
+ <Button>Delete</Button>
50
+ </ButtonGroup>
51
+
52
+ <h2 id="button-group-title">ButtonGroup content title</h2>
53
+ <ButtonGroup titleId="button-group-title">
54
+ <Button>Save</Button>
55
+ <Button>Edit</Button>
56
+ <Button>Delete</Button>
57
+ </ButtonGroup>
58
+ ```
@@ -0,0 +1,53 @@
1
+ # use-drawer-label
2
+
3
+ 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.
4
+
5
+ ## Examples
6
+
7
+ This rule will indicate user with warning to strongly recommend usage of either `label` or `titleId` prop.
8
+
9
+ ### Incorrect
10
+
11
+ ```tsx
12
+ <Drawer>
13
+ ^^^^^^ Missing either `label` or `titleId` prop.
14
+ Drawer content
15
+ </Drawer>
16
+
17
+ <Drawer label>
18
+ ^^^^^ `label` prop is missing value.
19
+ Drawer content
20
+ </Drawer>
21
+
22
+ <Drawer label="">
23
+ ^^^^^ `label` prop is missing accessible name value.
24
+ Drawer content
25
+ </Drawer>
26
+
27
+ <Drawer titleId>
28
+ ^^^^^^^ `titleId` prop is missing reference value.
29
+ <h1 id="drawer-title">Drawer content title</hi>
30
+ </Drawer>
31
+
32
+ <Drawer titleId="">
33
+ ^^^^^^^ `titleId` prop is missing reference value.
34
+ <h1 id="drawer-title">Drawer content title</hi>
35
+ </Drawer>
36
+
37
+ <Drawer titleId="drawer-title" label="">
38
+ ^^^^^^^ ^^^^^ 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.
39
+ <h1 id="drawer-title">Drawer content title</hi>
40
+ </Drawer>
41
+ ```
42
+
43
+ ### Correct
44
+
45
+ ```tsx
46
+ <Drawer label="Drawer content title">
47
+ Drawer content
48
+ </Drawer>
49
+
50
+ <Drawer titleId="drawer-title">
51
+ <h1 id="drawer-title">Drawer content title</hi>
52
+ </Drawer>
53
+ ```
@@ -0,0 +1,20 @@
1
+ # use-heading-level-in-spotlight-card
2
+
3
+ The `SpotlightCard` component in `@atlaskit/onboarding` will be requiring the `headingLevel` prop in future releases.
4
+
5
+ ## Examples
6
+
7
+ ### Incorrect
8
+
9
+ ```tsx
10
+ <SpotlightCard heading="Heading">Spotlight card contents</SpotlightCard>
11
+ ^^^^^^^^^^^^^
12
+ ```
13
+
14
+ ### Correct
15
+
16
+ ```tsx
17
+ <SpotlightCard heading="Heading" headingLevel={2}>
18
+ Spotlight card contents
19
+ </SpotlightCard>
20
+ ```
@@ -0,0 +1,18 @@
1
+ # use-href-in-link-item
2
+
3
+ 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.
4
+
5
+ ## Examples
6
+
7
+ ### Incorrect
8
+
9
+ ```tsx
10
+ <LinkItem>Button</LinkItem>
11
+ ^^^^^^^^
12
+ ```
13
+
14
+ ### Correct
15
+
16
+ ```tsx
17
+ <LinkItem href="http://example.com">Link</LinkItem>
18
+ ```
@@ -0,0 +1,77 @@
1
+ # use-primitives
2
+
3
+ Using primitives allows you to delete bespoke component code and replace it with ready made solutions made by the Atlassian Design System Team.
4
+
5
+ ## Examples
6
+
7
+ This rule marks code as violations when it can be replaced 1:1 with a primitive component.
8
+
9
+ ### Incorrect
10
+
11
+ ```jsx
12
+ const someStyles = css({
13
+ padding: '8px';
14
+ })
15
+
16
+ <div css={someStyles}>
17
+ ^^^^^^^^^^^^^^^^^^^^^^
18
+ // ...
19
+ </div>
20
+ ```
21
+
22
+ ### Correct
23
+
24
+ ```jsx
25
+ const someStyles = xcss({
26
+ padding: 'space.100';
27
+ })
28
+
29
+ <Box xcss={someStyles}>
30
+ // ...
31
+ </Box>
32
+ ```
33
+
34
+ Currently, the rule is extremely defensive, only reporting on `css` styles that contain:
35
+
36
+ - one, and only one, style property from this list:
37
+
38
+ - padding
39
+ - paddingBlock
40
+ - paddingBlockEnd
41
+ - paddingBlockStart
42
+ - paddingBottom
43
+ - paddingInline
44
+ - paddingInlineEnd
45
+ - paddingInlineStart
46
+ - paddingLeft
47
+ - paddingRight
48
+ - paddingTop
49
+ - margin
50
+ - marginBlock
51
+ - marginBlockEnd
52
+ - marginBlockStart
53
+ - marginBottom
54
+ - marginInline
55
+ - marginInlineEnd
56
+ - marginInlineStart
57
+ - marginLeft
58
+ - marginRight
59
+ - marginTop
60
+
61
+ - and where the style value is one of:
62
+ - 0px
63
+ - 2px
64
+ - 4px
65
+ - 6px
66
+ - 8px
67
+ - 12px
68
+ - 16px
69
+ - 20px
70
+ - 24px
71
+ - 32px
72
+ - 40px
73
+ - 48px
74
+ - 64px
75
+ - 80px
76
+
77
+ If these conditions are not met, then no violation will be reported.
@@ -0,0 +1,34 @@
1
+ # use-visually-hidden
2
+
3
+ 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.
4
+
5
+ ## Examples
6
+
7
+ This rule marks code as violations when it can be replaced 1:1 with the visually hidden component.
8
+
9
+ ### Incorrect
10
+
11
+ ```js
12
+ import { css } from '@emotion/core';
13
+ import { visuallyHidden } from '@atlaskit/theme/constants';
14
+
15
+ const visuallyHiddenStyles = css({
16
+ width: '1px',
17
+ height: '1px',
18
+ padding: '0',
19
+ position: 'absolute',
20
+ border: '0',
21
+ clip: 'rect(1px, 1px, 1px, 1px)',
22
+ overflow: 'hidden',
23
+ whiteSpace: 'nowrap',
24
+ });
25
+
26
+ const VisuallyHidden = styled.span`${visuallyHidden()}`;
27
+ ^^^^^^^^^^^^^^
28
+ ```
29
+
30
+ ### Correct
31
+
32
+ ```js
33
+ import VisuallyHidden from '@atlaskit/visually-hidden';
34
+ ```