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

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 (56) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/cjs/rules/no-legacy-icons/checks.js +63 -67
  3. package/dist/cjs/rules/no-legacy-icons/helpers.js +29 -24
  4. package/dist/cjs/rules/no-legacy-icons/index.js +4 -5
  5. package/dist/es2019/rules/no-legacy-icons/checks.js +20 -33
  6. package/dist/es2019/rules/no-legacy-icons/helpers.js +24 -21
  7. package/dist/es2019/rules/no-legacy-icons/index.js +4 -5
  8. package/dist/esm/rules/no-legacy-icons/checks.js +64 -68
  9. package/dist/esm/rules/no-legacy-icons/helpers.js +28 -23
  10. package/dist/esm/rules/no-legacy-icons/index.js +4 -5
  11. package/dist/types/rules/no-legacy-icons/helpers.d.ts +3 -13
  12. package/dist/types-ts4.5/rules/no-legacy-icons/helpers.d.ts +3 -13
  13. package/package.json +2 -2
  14. package/constellation/consistent-css-prop-usage/usage.mdx +0 -210
  15. package/constellation/ensure-design-token-usage/usage.mdx +0 -77
  16. package/constellation/ensure-design-token-usage-preview/usage.mdx +0 -6
  17. package/constellation/icon-label/usage.mdx +0 -41
  18. package/constellation/index/props.mdx +0 -30
  19. package/constellation/index/usage.mdx +0 -57
  20. package/constellation/no-banned-imports/usage.mdx +0 -19
  21. package/constellation/no-css-tagged-template-expression/usage.mdx +0 -71
  22. package/constellation/no-custom-icons/usage.mdx +0 -36
  23. package/constellation/no-deprecated-apis/usage.mdx +0 -82
  24. package/constellation/no-deprecated-design-token-usage/usage.mdx +0 -30
  25. package/constellation/no-deprecated-imports/usage.mdx +0 -66
  26. package/constellation/no-direct-use-of-web-platform-drag-and-drop/usage.mdx +0 -149
  27. package/constellation/no-empty-styled-expression/usage.mdx +0 -82
  28. package/constellation/no-exported-css/usage.mdx +0 -55
  29. package/constellation/no-exported-keyframes/usage.mdx +0 -55
  30. package/constellation/no-html-anchor/usage.mdx +0 -46
  31. package/constellation/no-html-button/usage.mdx +0 -52
  32. package/constellation/no-invalid-css-map/usage.mdx +0 -210
  33. package/constellation/no-keyframes-tagged-template-expression/usage.mdx +0 -80
  34. package/constellation/no-legacy-icons/usage.mdx +0 -42
  35. package/constellation/no-margin/usage.mdx +0 -21
  36. package/constellation/no-nested-styles/usage.mdx +0 -47
  37. package/constellation/no-physical-properties/usage.mdx +0 -53
  38. package/constellation/no-styled-tagged-template-expression/usage.mdx +0 -135
  39. package/constellation/no-unsafe-design-token-usage/usage.mdx +0 -50
  40. package/constellation/no-unsafe-style-overrides/usage.mdx +0 -52
  41. package/constellation/no-unsupported-drag-and-drop-libraries/usage.mdx +0 -23
  42. package/constellation/prefer-primitives/usage.mdx +0 -32
  43. package/constellation/use-button-group-label/usage.mdx +0 -60
  44. package/constellation/use-drawer-label/usage.mdx +0 -55
  45. package/constellation/use-heading/usage.mdx +0 -31
  46. package/constellation/use-heading-level-in-spotlight-card/usage.mdx +0 -21
  47. package/constellation/use-href-in-link-item/usage.mdx +0 -19
  48. package/constellation/use-latest-xcss-syntax/usage.mdx +0 -33
  49. package/constellation/use-latest-xcss-syntax-typography/usage.mdx +0 -34
  50. package/constellation/use-menu-section-title/usage.mdx +0 -55
  51. package/constellation/use-popup-label/usage.mdx +0 -56
  52. package/constellation/use-primitives/usage.mdx +0 -78
  53. package/constellation/use-primitives-text/usage.mdx +0 -35
  54. package/constellation/use-tokens-space/usage.mdx +0 -34
  55. package/constellation/use-tokens-typography/usage.mdx +0 -55
  56. package/constellation/use-visually-hidden/usage.mdx +0 -35
@@ -1,30 +0,0 @@
1
- # no-deprecated-design-token-usage
2
-
3
- Using deprecated design tokens is dangerous as they will eventually be deleted after the sunset
4
- period. This rule helps you move to non-deprecated design tokens.
5
-
6
- ## Examples
7
-
8
- This rule will mark usage of deprecated design tokens as violations.
9
-
10
- ## Incorrect
11
-
12
- ```js
13
- import { token } from '@atlaskit/tokens';
14
-
15
- css({ color: token('i.am.deprecated') });
16
- ^^^^^^^^^^^^^^^
17
- css({ color: token('i.am.a.token') });
18
- ^^^^^^^^^^^^^
19
- ```
20
-
21
- ## Options
22
-
23
- It's recommended to set this rule to "warn" to allow for new and old tokens to exist side-by-side
24
- for the duration of the deprecation period and avoid big-bang migrations.
25
-
26
- Once the deprecation period is over for a design token it will be moved into `deleted` state at
27
- which point the counterpart of this rule `no-unsafe-design-token-usage` will mark violations as
28
- errors.
29
-
30
- Running `eslint --fix` will automatically apply replacement tokens if present.
@@ -1,66 +0,0 @@
1
- # no-deprecated-imports
2
-
3
- Packages across the Atlassian Design System can be deprecated when they are deemed no-longer fit for
4
- purporse or dangerous and risk effective use at scale.
5
-
6
- ## Examples
7
-
8
- This rule will mark usage of deprecated modules as violations.
9
-
10
- ### Incorrect
11
-
12
- ```ts
13
- import Item from '@atlaskit/item';
14
- ^^^^^^^^^^^^^^
15
- import GlobalNav from '@atlaskit/global-navigation';
16
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17
- ```
18
-
19
- ## Options
20
-
21
- The rule can take one option: `deprecatedConfig`, if not provided the rule will use an internal
22
- config. If provided the rule will use the passed in config instead.
23
-
24
- ### deprecatedConfig
25
-
26
- The following fields can be defined in the config:
27
-
28
- - `packagePath`, which is the name of the package. For example: `@atlaskit/navigation-next` and
29
- `@atlaskit/navigation`. With the package path as the key, you can either provide the values as:
30
- - `message` **(optional)**, the message to display when the deprecated packages path is used. For
31
- example: `multi-select is deprecated. Please use '@atlaskit/select' instead.` Or as:
32
- - `imports`, which is an array of named imports to be deprecated. Each named import has the
33
- following fields:
34
- - `importName`, which is the name of the import to be deprecated. For example: `assistive` and
35
- `visuallyHidden`.
36
- - `message` **(optional)**, which is the message to display when the deprecated import is used.
37
- For example:
38
- `The assistive mixin is deprecated. Please use `@atlaskit/visually-hidden` instead.`.
39
-
40
- ```json
41
- {
42
- "@atlaskit/navigation-next": {
43
- "message": "navigation-next is deprecated. Please use '@atlaskit/atlassian-navigation' instead."
44
- }
45
- }
46
- ```
47
-
48
- ```js
49
- import packageJson from './package.json';
50
-
51
- module.exports = {
52
- rules: {
53
- '@atlaskit/design-system/no-deprecated-imports': [
54
- 'error',
55
- {
56
- deprecatedConfig: {
57
- '@atlaskit/navigation-next': {
58
- message:
59
- "navigation-next is deprecated. Please use '@atlaskit/atlassian-navigation' instead.",
60
- },
61
- },
62
- },
63
- ],
64
- },
65
- };
66
- ```
@@ -1,149 +0,0 @@
1
- # no-direct-use-of-web-platform-drag-and-drop
2
-
3
- Block the usage of web platform drag and drop functionality directly. Use Pragmatic drag and drop.
4
-
5
- ## Rationale
6
-
7
- The web platform has powerful drag and drop functionality built in. However, it is hard to be
8
- successful with web platform drag and drop due to bugs, inconsistencies and usage friction. Rather
9
- than leveraging the web platform API directly, the rule enforces the usage of
10
- [Pragmatic drag and drop](https://atlassian.design/components/pragmatic-drag-and-drop), which allows
11
- people to easily and successfully leverage web platform drag and drop.
12
-
13
- ## Examples
14
-
15
- This rule marks direct usage of web platform drag events as violations.
16
-
17
- ### Incorrect
18
-
19
- Adding drag related event listeners on intrinsic `react` elements (eg `div`, `span`, `strong` and so
20
- on).
21
-
22
- ```tsx
23
- <div onDragStart={fn}>{children}</div>
24
- ^^^^^^^^^^^
25
- <div onDragEnter={fn}>{children}</div>
26
- ^^^^^^^^^^^
27
- <div onDragLeave={fn}>{children}</div>
28
- ^^^^^^^^^^^
29
- <div onDragOver={fn}>{children}</div>
30
- ^^^^^^^^^^^
31
- <div onDrag={fn}>{children}</div>
32
- ^^^^^^
33
- <div onDrop={fn}>{children}</div>
34
- ^^^^^^
35
- <div onDragEnd={fn}>{children}</div>
36
- ^^^^^^^^^
37
- ```
38
-
39
- Adding drag related event listeners on our `<Box>` primitive.
40
-
41
- ```tsx
42
- import { Box } from '@atlaskit/primitives';
43
-
44
- <Box onDragStart={fn}>{children}</Box>
45
- ^^^^^^^^^^^
46
- <Box onDragEnter={fn}>{children}</Box>
47
- ^^^^^^^^^^^
48
- <Box onDragLeave={fn}>{children}</Box>
49
- ^^^^^^^^^^^
50
- <Box onDragOver={fn}>{children}</Box>
51
- ^^^^^^^^^^^
52
- <Box onDrag={fn}>{children}</Box>
53
- ^^^^^^
54
- <Box onDrop={fn}>{children}</Box>
55
- ^^^^^^
56
- <Box onDragEnd={fn}>{children}</Box>
57
- ^^^^^^^^^
58
- ```
59
-
60
- Binding drag related events using `eventTarget.addEventListener()`
61
-
62
- ```ts
63
- window.addEventListener('dragstart', fn);
64
- ^^^^^^^^^^^
65
- window.addEventListener('dragenter', fn);
66
- ^^^^^^^^^^^
67
- window.addEventListener('dragleave', fn);
68
- ^^^^^^^^^^^
69
- window.addEventListener('dragover', fn);
70
- ^^^^^^^^^^
71
- window.addEventListener('drag', fn);
72
- ^^^^^^
73
- window.addEventListener('drop', fn);
74
- ^^^^^^
75
- window.addEventListener('dragend', fn);
76
- ^^^^^^^^^
77
- ```
78
-
79
- Binding drag related events using `bind()` from
80
- [bind-event-listener](https://github.com/alexreardon/bind-event-listener)
81
-
82
- ```ts
83
- import {bind} from 'bind-event-listener';
84
-
85
- bind(element, { type: 'dragstart', listener: fn });
86
- ^^^^^^^^^^^
87
- bind(element, { type: 'dragenter', listener: fn });
88
- ^^^^^^^^^^^
89
- bind(element, { type: 'dragleave', listener: fn });
90
- ^^^^^^^^^^^
91
- bind(element, { type: 'dragover', listener: fn });
92
- ^^^^^^^^^^
93
- bind(element, { type: 'drag', listener: fn });
94
- ^^^^^^
95
- bind(element, { type: 'drop', listener: fn });
96
- ^^^^^^
97
- bind(element, { type: 'dragend', listener: fn });
98
- ^^^^^^^^^
99
- ```
100
-
101
- Binding drag related events using `bindAll()` from
102
- [bind-event-listener](https://github.com/alexreardon/bind-event-listener)
103
-
104
- ```ts
105
- import {bindAll} from 'bind-event-listener';
106
-
107
- bindAll(window, [
108
- { type: 'dragstart', listener: fn },
109
- ^^^^^^^^^^
110
- { type: 'dragenter', listener: fn },
111
- ^^^^^^^^^^
112
- { type: 'dragleave', listener: fn },
113
- ^^^^^^^^^^
114
- { type: 'dragover', listener: fn },
115
- ^^^^^^^^^^
116
- { type: 'drag', listener: fn },
117
- ^^^^^^
118
- { type: 'drop', listener: fn },
119
- ^^^^^^
120
- { type: 'dragend', listener: fn },
121
- ^^^^^^^^^
122
- ]);
123
- ```
124
-
125
- ### Correct
126
-
127
- Leveraging Pragmatic drag and drop for web platform drag and drop.
128
-
129
- ```ts
130
- import { monitor } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
131
-
132
- monitor({
133
- onGenerateDragPreview: fn,
134
- onDragStart: fn,
135
- onDropTargetChange: fn,
136
- onDrag: fn,
137
- onDrop: fn,
138
- });
139
- ```
140
-
141
- > See the
142
- > [Pragmatic drag and drop documentation](https://atlassian.design/components/pragmatic-drag-and-drop)
143
- > for more information about it's usage.
144
-
145
- Using blocked JSX attributes on custom `react` components
146
-
147
- ```tsx
148
- <MyComponent onDragStart={fn}>
149
- ```
@@ -1,82 +0,0 @@
1
- # no-empty-styled-expression
2
-
3
- Disallows/discourages passing empty arguments to any `styled` expression when using a CSS-in-JS
4
- library, including `@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
5
-
6
- If Compiled is used in the file, passing an empty object or no object at all causes Compiled to
7
- build extra `div/span` elements, as opposed to simply using a `div`. This leads to reduced
8
- performance and is greatly discouraged. If a wrapper is necessary, opt to use a `div` or wrap it in
9
- the empty React fragment `<> <YourComponentHere></YourComponentHere> </>`.
10
-
11
- ## Examples
12
-
13
- ### Incorrect
14
-
15
- ```tsx
16
- const EmptyStyledExpression = styled.div();
17
-
18
- const EmptyStyledExpressionArgument = styled.div({});
19
-
20
- const EmptyStyledExpressionArgument = styled.div([]);
21
- ```
22
-
23
- ### Correct
24
-
25
- ```tsx
26
- const Wrapper = styled.div({
27
- backgroundColor: 'red',
28
- MyComponent: {
29
- backgroundColor: 'green',
30
- },
31
- });
32
- ```
33
-
34
- ## What to do instead?
35
-
36
- ### Use elements directly
37
-
38
- ```diff
39
- - const Wrapper = styled.div({});
40
-
41
- function App() {
42
- - return <Wrapper>hello world</Wrapper>;
43
- + return <div>hello world</div>;
44
- }
45
- ```
46
-
47
- ### Use a React fragment
48
-
49
- ```diff
50
- - const Wrapper = styled.div({});
51
-
52
- function App() {
53
- - return <Wrapper>hello world</Wrapper>;
54
- + return <>hello world</>;
55
- }
56
- ```
57
-
58
- ## Options
59
-
60
- ### importSources
61
-
62
- By default, this rule will check `styled` usages from:
63
-
64
- - `@atlaskit/css`
65
- - `@atlaskit/primitives`
66
- - `@compiled/react`
67
- - `@emotion/react`
68
- - `@emotion/core`
69
- - `@emotion/styled`
70
- - `styled-components`
71
-
72
- To change this list of libraries, you can define a custom set of `importSources`, which accepts an
73
- array of package names (strings).
74
-
75
- ```tsx
76
- // [{ importSources: ['other-lib'] }]
77
-
78
- import { styled } from 'other-lib';
79
-
80
- // Invalid!
81
- export const Component = styled.div({});
82
- ```
@@ -1,55 +0,0 @@
1
- # no-exported-css
2
-
3
- Disallows `css` export declarations that originate from a CSS-in-JS library, including
4
- `@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
5
-
6
- In Compiled (`@atlaskit/css` and `@compiled/react`), exporting `css` declarations may result in
7
- unexpected errors when imported, because its value will be `null` at runtime. Additionally,
8
- co-locating `css` definitions with their usage is considered best practice in order to improve code
9
- readability and build performance.
10
-
11
- ## Examples
12
-
13
- ### Incorrect
14
-
15
- ```tsx
16
- import { css } from '@compiled/react';
17
-
18
- export const styles = css({});
19
-
20
- export default css({});
21
- ```
22
-
23
- ### Correct
24
-
25
- ```tsx
26
- import { css } from '@compiled/react';
27
-
28
- const styles = css({});
29
- ```
30
-
31
- ## Options
32
-
33
- ### importSources
34
-
35
- By default, this rule will check `css` usages from:
36
-
37
- - `@atlaskit/css`
38
- - `@atlaskit/primitives`
39
- - `@compiled/react`
40
- - `@emotion/react`
41
- - `@emotion/core`
42
- - `@emotion/styled`
43
- - `styled-components`
44
-
45
- To change this list of libraries, you can define a custom set of `importSources`, which accepts an
46
- array of package names (strings).
47
-
48
- ```tsx
49
- // [{ importSources: ['other-lib'] }]
50
-
51
- import { css } from 'other-lib';
52
-
53
- // Invalid!
54
- export const styles = css({});
55
- ```
@@ -1,55 +0,0 @@
1
- # no-exported-keyframes
2
-
3
- Disallows `keyframes` export declarations that originate from a CSS-in-JS library, including
4
- `@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
5
-
6
- In Compiled (`@atlaskit/css` and `@compiled/react`), exporting `keyframes` declarations may result
7
- in unexpected errors when imported, because its value will be `null` at runtime. Additionally,
8
- co-locating `keyframes` definitions with their usage is considered best practice in order to improve
9
- code readability and build performance.
10
-
11
- ## Examples
12
-
13
- ### Incorrect
14
-
15
- ```tsx
16
- import { keyframes } from '@compiled/react';
17
-
18
- export const animation = keyframes({});
19
-
20
- export default keyframes({});
21
- ```
22
-
23
- ### Correct
24
-
25
- ```tsx
26
- import { keyframes } from '@compiled/react';
27
-
28
- const animation = keyframes({});
29
- ```
30
-
31
- ## Options
32
-
33
- ### importSources
34
-
35
- By default, this rule will check `keyframes` usages from:
36
-
37
- - `@atlaskit/css`
38
- - `@atlaskit/primitives`
39
- - `@compiled/react`
40
- - `@emotion/react`
41
- - `@emotion/core`
42
- - `@emotion/styled`
43
- - `styled-components`
44
-
45
- To change this list of libraries, you can define a custom set of `importSources`, which accepts an
46
- array of package names (strings).
47
-
48
- ```tsx
49
- // [{ importSources: ['other-lib'] }]
50
-
51
- import { keyframes } from 'other-lib';
52
-
53
- // Invalid!
54
- export const animation = keyframes({});
55
- ```
@@ -1,46 +0,0 @@
1
- # no-html-anchor
2
-
3
- Don't use native HTML anchors. The Atlassian Design System provides ready-made link components that
4
- include event tracking, automatic router configuration, ensure accessible implementations, and
5
- provide access to ADS styling features like design tokens.
6
-
7
- Use Atlassian Design System components such as the [Link](/components/link/) or
8
- [LinkButton](/components/button/link-button/) components when suitable. There may also be other
9
- components better-suited depending on the use case. If these components aren't suitable, use the
10
- [Anchor primitive](/components/primitives/anchor/) which helps you build custom links with Atlassian
11
- Design System styling.
12
-
13
- ## Examples
14
-
15
- This rule marks code as violations when it finds native HTML anchor elements.
16
-
17
- ### Incorrect
18
-
19
- ```jsx
20
- <a href="/">
21
- ^ Using a native HTML `<a>`
22
- Hello, World!
23
- </a>
24
-
25
- <div role="link" tabIndex="0" data-href="https://www.atlassian.com">
26
- ^^^^^^^^^^^ Using `role="link"` to create links
27
- Hello, World!
28
- </div>
29
-
30
- ```
31
-
32
- ### Correct
33
-
34
- ```jsx
35
- import Anchor from '@atlaskit/primitives/anchor';
36
-
37
- <Anchor href="/">Hello, World!</Anchor>;
38
-
39
- import Link from '@atlaskit/link';
40
-
41
- <Link href="/">Hello, World!</Link>;
42
-
43
- import { LinkButton } from '@atlaskit/button/new';
44
-
45
- <LinkButton href="/">Hello, World!</LinkButton>;
46
- ```
@@ -1,52 +0,0 @@
1
- # no-html-button
2
-
3
- Don't use native HTML buttons. The Atlassian Design System provides ready-made button components
4
- that include event tracking, ensure accessible implementations, and provide access to ADS styling
5
- features like design tokens.
6
-
7
- Use Atlassian Design System components such as the [Button component](/components/button/) when
8
- suitable. There may also be other components better-suited depending on the use case. If these
9
- components aren't suitable, use the [Pressable primitive](/components/primitives/pressable/) which
10
- helps you build custom buttons with Atlassian Design System styling.
11
-
12
- ## Examples
13
-
14
- This rule marks code as violations when it finds native HTML button elements.
15
-
16
- ### Incorrect
17
-
18
- ```jsx
19
- <button>
20
- ^^^^^^ Using a native HTML `<button>`
21
- Hello, World!
22
- </button>
23
-
24
- <div role="button" tabIndex="0">
25
- ^^^^^^^^^^^^^ Using `role="button"` to create buttons
26
- Hello, World!
27
- </div>
28
-
29
- <input type="button" value="Button" />
30
- ^^^^^^^^^^^^^ Using a `<input>` as a button
31
-
32
- <input type="submit" value="Submit" />
33
- ^^^^^^^^^^^^^ Using a `<input>` as a button
34
-
35
- <input type="reset" value="Reset" />
36
- ^^^^^^^^^^^^ Using a `<input>` as a button
37
-
38
- <input type="image" alt="Submit" src="/submit-button.png" />
39
- ^^^^^^^^^^^^ Using a `<input>` as a button
40
- ```
41
-
42
- ### Correct
43
-
44
- ```jsx
45
- import Pressable from '@atlaskit/primitives/pressable';
46
-
47
- <Pressable>Hello, World!</Pressable>;
48
-
49
- import Button from '@atlaskit/button/new';
50
-
51
- <Button>Hello, World!</Button>;
52
- ```