@atlaskit/eslint-plugin-ui-styling-standard 0.18.0 → 0.18.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.
- package/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/afm-cc/tsconfig.json +0 -28
- package/afm-jira/tsconfig.json +0 -27
- package/build/tsconfig.json +0 -18
- package/constellation/atlaskit-theme/usage.mdx +0 -132
- package/constellation/consistent-css-prop-usage/usage.mdx +0 -7
- package/constellation/convert-props-syntax/usage.mdx +0 -130
- package/constellation/enforce-style-prop/usage.mdx +0 -47
- package/constellation/index/migration-guide.mdx +0 -309
- package/constellation/index/overview.mdx +0 -250
- package/constellation/index/props.mdx +0 -30
- package/constellation/local-cx-xcss/usage.mdx +0 -53
- package/constellation/no-array-arguments/usage.mdx +0 -49
- package/constellation/no-classname-prop/usage.mdx +0 -49
- package/constellation/no-container-queries/usage.mdx +0 -101
- package/constellation/no-css-tagged-template-expression/usage.mdx +0 -8
- package/constellation/no-dynamic-styles/usage.mdx +0 -130
- package/constellation/no-empty-styled-expression/usage.mdx +0 -8
- package/constellation/no-exported-css/usage.mdx +0 -8
- package/constellation/no-exported-keyframes/usage.mdx +0 -8
- package/constellation/no-exported-styles/usage.mdx +0 -87
- package/constellation/no-global-styles/usage.mdx +0 -60
- package/constellation/no-important-styles/usage.mdx +0 -33
- package/constellation/no-imported-style-values/usage.mdx +0 -157
- package/constellation/no-invalid-css-map/usage.mdx +0 -8
- package/constellation/no-js-xcss/usage.mdx +0 -7
- package/constellation/no-keyframes-tagged-template-expression/usage.mdx +0 -8
- package/constellation/no-nested-selectors/usage.mdx +0 -95
- package/constellation/no-styled/usage.mdx +0 -92
- package/constellation/no-styled-tagged-template-expression/usage.mdx +0 -8
- package/constellation/no-suppress-xcss/usage.mdx +0 -28
- package/constellation/no-unsafe-selectors/usage.mdx +0 -370
- package/constellation/no-unsafe-values/usage.mdx +0 -318
- package/constellation/use-compiled/usage.mdx +0 -54
- package/index.js +0 -24
- package/scripts/codegen.tsx +0 -373
- package/src/index.codegen.tsx +0 -14
- package/src/index.tsx +0 -1
- package/src/presets/all.codegen.tsx +0 -79
- package/src/presets/recommended.codegen.tsx +0 -79
- package/src/rules/TEMPLATE.md +0 -29
- package/src/rules/__tests__/utils/_tester.tsx +0 -40
- package/src/rules/atlaskit-theme/README.md +0 -130
- package/src/rules/atlaskit-theme/__tests__/test.ts +0 -133
- package/src/rules/atlaskit-theme/index.ts +0 -134
- package/src/rules/convert-props-syntax/README.md +0 -128
- package/src/rules/convert-props-syntax/__tests__/invalid.test.tsx +0 -76
- package/src/rules/convert-props-syntax/__tests__/rule.test.tsx +0 -584
- package/src/rules/convert-props-syntax/__tests__/type-annotations.test.tsx +0 -140
- package/src/rules/convert-props-syntax/__tests__/unusual-properties.test.tsx +0 -69
- package/src/rules/convert-props-syntax/index.tsx +0 -414
- package/src/rules/enforce-style-prop/README.md +0 -45
- package/src/rules/enforce-style-prop/__tests__/rule.test.tsx +0 -243
- package/src/rules/enforce-style-prop/index.tsx +0 -172
- package/src/rules/external-rules.tsx +0 -177
- package/src/rules/index.codegen.tsx +0 -42
- package/src/rules/local-cx-xcss/README.md +0 -51
- package/src/rules/local-cx-xcss/__tests__/rule.test.tsx +0 -102
- package/src/rules/local-cx-xcss/index.tsx +0 -62
- package/src/rules/no-array-arguments/README.md +0 -47
- package/src/rules/no-array-arguments/__tests__/rule.test.tsx +0 -107
- package/src/rules/no-array-arguments/index.tsx +0 -86
- package/src/rules/no-classname-prop/README.md +0 -47
- package/src/rules/no-classname-prop/__tests__/rule.test.tsx +0 -39
- package/src/rules/no-classname-prop/index.tsx +0 -34
- package/src/rules/no-container-queries/README.md +0 -99
- package/src/rules/no-container-queries/__tests__/rule.test.tsx +0 -139
- package/src/rules/no-container-queries/index.tsx +0 -94
- package/src/rules/no-dynamic-styles/README.md +0 -128
- package/src/rules/no-dynamic-styles/__tests__/rule.test.tsx +0 -135
- package/src/rules/no-dynamic-styles/index.tsx +0 -60
- package/src/rules/no-exported-styles/README.md +0 -85
- package/src/rules/no-exported-styles/__tests__/rule.test.tsx +0 -216
- package/src/rules/no-exported-styles/index.tsx +0 -52
- package/src/rules/no-global-styles/README.md +0 -58
- package/src/rules/no-global-styles/__tests__/no-css-modules.test.tsx +0 -33
- package/src/rules/no-global-styles/__tests__/no-global-styles.test.tsx +0 -46
- package/src/rules/no-global-styles/index.tsx +0 -82
- package/src/rules/no-important-styles/README.md +0 -31
- package/src/rules/no-important-styles/__tests__/rule.test.tsx +0 -165
- package/src/rules/no-important-styles/index.tsx +0 -70
- package/src/rules/no-imported-style-values/README.md +0 -155
- package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +0 -491
- package/src/rules/no-imported-style-values/index.tsx +0 -188
- package/src/rules/no-nested-selectors/README.md +0 -93
- package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +0 -335
- package/src/rules/no-nested-selectors/index.tsx +0 -99
- package/src/rules/no-styled/README.md +0 -90
- package/src/rules/no-styled/__tests__/rule.test.tsx +0 -73
- package/src/rules/no-styled/index.tsx +0 -45
- package/src/rules/no-unsafe-selectors/README.md +0 -368
- package/src/rules/no-unsafe-selectors/__tests__/no-ambiguous-pseudos.test.tsx +0 -368
- package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +0 -57
- package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +0 -73
- package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +0 -40
- package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +0 -101
- package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +0 -131
- package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +0 -132
- package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +0 -25
- package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +0 -35
- package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +0 -257
- package/src/rules/no-unsafe-selectors/constants.tsx +0 -91
- package/src/rules/no-unsafe-selectors/index.tsx +0 -198
- package/src/rules/no-unsafe-selectors/lint-selector.tsx +0 -155
- package/src/rules/no-unsafe-selectors/source-position-utils.tsx +0 -55
- package/src/rules/no-unsafe-selectors/walk-css-map.tsx +0 -226
- package/src/rules/no-unsafe-values/README.md +0 -316
- package/src/rules/no-unsafe-values/__tests__/no-array-values.test.tsx +0 -27
- package/src/rules/no-unsafe-values/__tests__/no-conditional-values.test.tsx +0 -37
- package/src/rules/no-unsafe-values/__tests__/no-dynamic-keys.test.tsx +0 -229
- package/src/rules/no-unsafe-values/__tests__/no-function-calls.test.tsx +0 -267
- package/src/rules/no-unsafe-values/__tests__/no-identifier-arguments.test.tsx +0 -52
- package/src/rules/no-unsafe-values/__tests__/no-object-access.test.tsx +0 -106
- package/src/rules/no-unsafe-values/__tests__/no-object-references.test.tsx +0 -44
- package/src/rules/no-unsafe-values/__tests__/no-spread-elements.test.tsx +0 -48
- package/src/rules/no-unsafe-values/__tests__/no-unsafe-values.test.tsx +0 -75
- package/src/rules/no-unsafe-values/__tests__/no-variables.test.tsx +0 -121
- package/src/rules/no-unsafe-values/index.tsx +0 -94
- package/src/rules/no-unsafe-values/messages.tsx +0 -86
- package/src/rules/no-unsafe-values/utils.tsx +0 -387
- package/src/rules/use-compiled/README.md +0 -52
- package/src/rules/use-compiled/__tests__/can-auto-fix.test.tsx +0 -73
- package/src/rules/use-compiled/__tests__/css.test.tsx +0 -126
- package/src/rules/use-compiled/__tests__/imports.test.tsx +0 -158
- package/src/rules/use-compiled/__tests__/keyframes.test.tsx +0 -140
- package/src/rules/use-compiled/__tests__/pragma.test.tsx +0 -108
- package/src/rules/use-compiled/__tests__/styled.test.tsx +0 -114
- package/src/rules/use-compiled/__tests__/use-compiled.test.tsx +0 -15
- package/src/rules/use-compiled/index.tsx +0 -252
- package/src/rules/use-compiled/is-safe.tsx +0 -159
- package/src/rules/use-compiled/utils.tsx +0 -33
- package/src/rules/utils/create-rule-with-typed-config.tsx +0 -86
- package/src/rules/utils/create-rule.tsx +0 -13
- package/tsconfig.app.json +0 -47
- package/tsconfig.dev.json +0 -45
- package/tsconfig.json +0 -25
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# no-array-arguments
|
|
2
|
-
|
|
3
|
-
Blocks passing array arguments to style declaration functions.
|
|
4
|
-
|
|
5
|
-
## Examples
|
|
6
|
-
|
|
7
|
-
### Incorrect
|
|
8
|
-
|
|
9
|
-
```tsx
|
|
10
|
-
import { css } from '@compiled/react';
|
|
11
|
-
|
|
12
|
-
const styles = css([{ width: 100 }, { height: 100 }]);
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
```tsx
|
|
16
|
-
import { styled } from '@compiled/react';
|
|
17
|
-
|
|
18
|
-
const styles = css([{ width: 100 }, ...items]);
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
### Correct
|
|
22
|
-
|
|
23
|
-
```tsx
|
|
24
|
-
import { css } from '@compiled/react';
|
|
25
|
-
|
|
26
|
-
const styles = css({ width: 100 }, { height: 100 });
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
```tsx
|
|
30
|
-
import { css } from '@compiled/react';
|
|
31
|
-
|
|
32
|
-
const styles = css({ width: 100 }, ...items);
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Options
|
|
36
|
-
|
|
37
|
-
### `importSources: string[]`
|
|
38
|
-
|
|
39
|
-
By default, this rule will check styles using:
|
|
40
|
-
|
|
41
|
-
- `@atlaskit/css`
|
|
42
|
-
- `@atlaskit/primitives`
|
|
43
|
-
- `@compiled/react`
|
|
44
|
-
- `@emotion/react`
|
|
45
|
-
- `@emotion/core`
|
|
46
|
-
- `@emotion/styled`
|
|
47
|
-
- `styled-components`
|
|
48
|
-
|
|
49
|
-
Override this list with the `importSources` option, which accepts an array of package names.
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# no-classname-prop
|
|
2
|
-
|
|
3
|
-
Blocks the `className` prop, which encourages unsafe global styles and cannot be statically
|
|
4
|
-
resolved.
|
|
5
|
-
|
|
6
|
-
Use the `css` prop for styling, with props for configuration and `xcss` for bounded overrides.
|
|
7
|
-
|
|
8
|
-
## Examples
|
|
9
|
-
|
|
10
|
-
### Incorrect
|
|
11
|
-
|
|
12
|
-
```tsx
|
|
13
|
-
<div className="my-class">
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
```tsx
|
|
17
|
-
<MyComponent className={isDisabled ? 'disabled' : undefined} />
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
### Correct
|
|
21
|
-
|
|
22
|
-
```tsx
|
|
23
|
-
import { css } from '@compiled/react';
|
|
24
|
-
import { token } from '@atlaskit/tokens';
|
|
25
|
-
|
|
26
|
-
const myStyles = css({ padding: token('space.100') });
|
|
27
|
-
|
|
28
|
-
<div css={myStyles} />;
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
```tsx
|
|
32
|
-
<MyComponent isDisabled={isDisabled} />
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
```tsx
|
|
36
|
-
import { Checkbox } from '@atlaskit/checkbox';
|
|
37
|
-
|
|
38
|
-
<Checkbox xcss={{ alignItems: 'center' }} />;
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## FAQ
|
|
42
|
-
|
|
43
|
-
### What if I'm using `className` to target elements with JavaScript?
|
|
44
|
-
|
|
45
|
-
There are some cases where a selector is required to integrate with a 3rd party library, such as
|
|
46
|
-
legacy code using jQuery.
|
|
47
|
-
|
|
48
|
-
Use a `ref` if possible. Otherwise, if you _must_ have a selector, use a `data-*` attribute that
|
|
49
|
-
gives enough context and is unique enough, for example `data-editor-table-target="true"`.
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
# no-container-queries
|
|
2
|
-
|
|
3
|
-
Blocks `@container` at-rules
|
|
4
|
-
([container queries](https://developer.mozilla.org/en-US/docs/Web/CSS/@container)), which are
|
|
5
|
-
unsafe.
|
|
6
|
-
|
|
7
|
-
Container queries are unsafe because they:
|
|
8
|
-
|
|
9
|
-
- break the rules of scope
|
|
10
|
-
- aren't deterministic
|
|
11
|
-
- aren't type-safe
|
|
12
|
-
- aren't fully supported across our frontend tech stacks
|
|
13
|
-
|
|
14
|
-
Use [media queries](https://atlassian.design/components/primitives/responsive/breakpoints/examples),
|
|
15
|
-
a
|
|
16
|
-
[WidthObserver](https://atlaskit.atlassian.com/packages/design-system/width-detector/docs/migration-guide),
|
|
17
|
-
or a custom [ResizeObserver](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver)
|
|
18
|
-
instead.
|
|
19
|
-
|
|
20
|
-
## Examples
|
|
21
|
-
|
|
22
|
-
### Incorrect
|
|
23
|
-
|
|
24
|
-
```tsx
|
|
25
|
-
import { css } from '@compiled/react';
|
|
26
|
-
import { token } from '@atlaskit/tokens';
|
|
27
|
-
|
|
28
|
-
const headingStyles = css({
|
|
29
|
-
'@container (width > 400px)': {
|
|
30
|
-
font: token('font.heading.large'),
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### Correct
|
|
36
|
-
|
|
37
|
-
#### Media queries
|
|
38
|
-
|
|
39
|
-
```tsx
|
|
40
|
-
import { css } from '@compiled/react';
|
|
41
|
-
import { media } from '@atlaskit/primitives/responsive';
|
|
42
|
-
import { token } from '@atlaskit/tokens';
|
|
43
|
-
|
|
44
|
-
const headingStyles = css({
|
|
45
|
-
[media.above.sm]: {
|
|
46
|
-
font: token('font.heading.large'),
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
#### WidthObserver
|
|
52
|
-
|
|
53
|
-
```tsx
|
|
54
|
-
import { useState } from 'react';
|
|
55
|
-
import { css, cssMap } from '@compiled/react';
|
|
56
|
-
import throttle from 'lodash/throttle';
|
|
57
|
-
import { WidthObserver } from '@atlaskit/width-detector';
|
|
58
|
-
import { token } from '@atlaskit/tokens';
|
|
59
|
-
|
|
60
|
-
const containerStyles = css({
|
|
61
|
-
// Required for the `WidthObserver`, which is absolutely positioned
|
|
62
|
-
position: 'relative',
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
const headingStyles = cssMap({
|
|
66
|
-
small: {
|
|
67
|
-
font: token('font.heading.small'),
|
|
68
|
-
},
|
|
69
|
-
large: {
|
|
70
|
-
font: token('font.heading.large'),
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const ResponsiveH2 = () => {
|
|
75
|
-
const [width = 0, setWidth] = useState<number | undefined>(undefined);
|
|
76
|
-
const throttledSetWidth = throttle(setWidth, 50);
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<div css={containerStyles}>
|
|
80
|
-
<WidthObserver setWidth={throttledSetWidth} />
|
|
81
|
-
<h2 css={width < 400 ? headingStyles.small : headingStyles.large}>Title</h2>
|
|
82
|
-
</div>
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Options
|
|
88
|
-
|
|
89
|
-
### `importSources: string[]`
|
|
90
|
-
|
|
91
|
-
By default, this rule will check styles using:
|
|
92
|
-
|
|
93
|
-
- `@atlaskit/css`
|
|
94
|
-
- `@atlaskit/primitives`
|
|
95
|
-
- `@compiled/react`
|
|
96
|
-
- `@emotion/react`
|
|
97
|
-
- `@emotion/core`
|
|
98
|
-
- `@emotion/styled`
|
|
99
|
-
- `styled-components`
|
|
100
|
-
|
|
101
|
-
Override this list with the `importSources` option, which accepts an array of package names.
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# @atlaskit/design-system/no-css-tagged-template-expression
|
|
2
|
-
|
|
3
|
-
Disallows any `css` tagged template expressions that originate from a CSS-in-JS library, including
|
|
4
|
-
`@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
|
|
5
|
-
|
|
6
|
-
This rule is maintained by another package and configured here; refer to
|
|
7
|
-
https://atlassian.design/components/eslint-plugin-design-system/no-css-tagged-template-expression/usage
|
|
8
|
-
for more details.
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
# no-dynamic-styles
|
|
2
|
-
|
|
3
|
-
Blocks dynamic styles (function expressions) in style declarations.
|
|
4
|
-
|
|
5
|
-
This ensures that style declarations:
|
|
6
|
-
|
|
7
|
-
- are statically analyzable
|
|
8
|
-
- can be efficiently extracted into atomic CSS
|
|
9
|
-
- are more readable and deterministic, thus easier to maintain
|
|
10
|
-
|
|
11
|
-
## Examples
|
|
12
|
-
|
|
13
|
-
### Incorrect
|
|
14
|
-
|
|
15
|
-
```tsx
|
|
16
|
-
import { styled } from '@compiled/react';
|
|
17
|
-
|
|
18
|
-
const Component = styled.div<{ width: number }>((props) => ({
|
|
19
|
-
width: props.width,
|
|
20
|
-
}));
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
```tsx
|
|
24
|
-
import styled from 'styled-components';
|
|
25
|
-
|
|
26
|
-
const Component = styled.div<{ width: number }>({
|
|
27
|
-
width: (props) => props.width,
|
|
28
|
-
});
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
```tsx
|
|
32
|
-
import styled from 'styled-components';
|
|
33
|
-
|
|
34
|
-
const Container = styled.div<{ hasPadding: boolean }>({
|
|
35
|
-
padding: ({ hasPadding }) => (hasPadding ? token('space.100', '8px') : token('space.0', '0px')),
|
|
36
|
-
});
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### Correct
|
|
40
|
-
|
|
41
|
-
Define all styles statically, and dynamically apply them using the `css` prop. Use the `style` prop
|
|
42
|
-
for values that are only known at runtime.
|
|
43
|
-
|
|
44
|
-
For further guidance, consult our
|
|
45
|
-
[migration guide](https://atlassian.design/components/eslint-plugin-ui-styling-standard/migration-guide).
|
|
46
|
-
|
|
47
|
-
#### Flags
|
|
48
|
-
|
|
49
|
-
If you have a style that is on/off depending on a prop, use the `css` prop to conditionally apply
|
|
50
|
-
it.
|
|
51
|
-
|
|
52
|
-
```tsx
|
|
53
|
-
import { css } from '@compiled/react';
|
|
54
|
-
|
|
55
|
-
const baseStyles = css({ padding: token('space.0') });
|
|
56
|
-
const hasPaddingStyles = css({ padding: token('space.100') });
|
|
57
|
-
|
|
58
|
-
const Container = ({ hasPadding = false }: { hasPadding?: boolean }) => {
|
|
59
|
-
return <div css={[baseStyles, hasPadding && hasPaddingStyles]} />;
|
|
60
|
-
};
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
#### Variants
|
|
64
|
-
|
|
65
|
-
If you have variants which are known ahead of time, use `cssMap` to define them and the `css` prop
|
|
66
|
-
to conditionally apply it.
|
|
67
|
-
|
|
68
|
-
```tsx
|
|
69
|
-
import { css } from '@compiled/react';
|
|
70
|
-
|
|
71
|
-
const baseStyles = css({ width: 100 });
|
|
72
|
-
const stylesMap = cssMap({
|
|
73
|
-
primary: {
|
|
74
|
-
background: token('color.background.brand.bold'),
|
|
75
|
-
'&:hover': { background: token('color.background.brand.bold.hovered') },
|
|
76
|
-
},
|
|
77
|
-
error: {
|
|
78
|
-
background: token('color.background.warning.bold'),
|
|
79
|
-
'&:hover': { background: token('color.background.warning.bold.hovered') },
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
const Wrapper = ({ appearance = 'primary' }: { appearance?: 'primary' | 'error' }) => (
|
|
84
|
-
<div css={[baseStyles, stylesMap[appearance]} />
|
|
85
|
-
);
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
#### Dynamic values
|
|
89
|
-
|
|
90
|
-
If you have styles which are truly dynamic, use the `style` prop.
|
|
91
|
-
|
|
92
|
-
This approach should be used as a last resort.
|
|
93
|
-
|
|
94
|
-
```tsx
|
|
95
|
-
import { css } from '@compiled/react';
|
|
96
|
-
|
|
97
|
-
const Component = ({ width }: { width: number }) => {
|
|
98
|
-
return <div style={{ width }} />;
|
|
99
|
-
};
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
```tsx
|
|
103
|
-
import { css } from '@compiled/react';
|
|
104
|
-
|
|
105
|
-
const containerStyles = css({
|
|
106
|
-
'&::before': {
|
|
107
|
-
width: 'var(--ak-example-width)',
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
function Example({ width }: { width: number }) {
|
|
112
|
-
return <div css={containerStyles} style={{ '--ak-example-width': `${width}px` }} />;
|
|
113
|
-
}
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
## Options
|
|
117
|
-
|
|
118
|
-
### `importSources: string[]`
|
|
119
|
-
|
|
120
|
-
By default, this rule will check styles using:
|
|
121
|
-
|
|
122
|
-
- `@atlaskit/css`
|
|
123
|
-
- `@atlaskit/primitives`
|
|
124
|
-
- `@compiled/react`
|
|
125
|
-
- `@emotion/react`
|
|
126
|
-
- `@emotion/core`
|
|
127
|
-
- `@emotion/styled`
|
|
128
|
-
- `styled-components`
|
|
129
|
-
|
|
130
|
-
Override this list with the `importSources` option, which accepts an array of package names.
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# @atlaskit/design-system/no-empty-styled-expression
|
|
2
|
-
|
|
3
|
-
Forbids any styled expression to be used when passing empty arguments to styled.div() (or other JSX
|
|
4
|
-
elements).
|
|
5
|
-
|
|
6
|
-
This rule is maintained by another package and configured here; refer to
|
|
7
|
-
https://atlassian.design/components/eslint-plugin-design-system/no-empty-styled-expression/usage for
|
|
8
|
-
more details.
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# @atlaskit/design-system/no-exported-css
|
|
2
|
-
|
|
3
|
-
Forbid exporting `css` function calls. Exporting `css` function calls can result in unexpected
|
|
4
|
-
behaviour at runtime, and is not statically analysable.
|
|
5
|
-
|
|
6
|
-
This rule is maintained by another package and configured here; refer to
|
|
7
|
-
https://atlassian.design/components/eslint-plugin-design-system/no-exported-css/usage for more
|
|
8
|
-
details.
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# @atlaskit/design-system/no-exported-keyframes
|
|
2
|
-
|
|
3
|
-
Forbid exporting `keyframes` function calls. Exporting `css` function calls can result in unexpected
|
|
4
|
-
behaviour at runtime, and is not statically analysable.
|
|
5
|
-
|
|
6
|
-
This rule is maintained by another package and configured here; refer to
|
|
7
|
-
https://atlassian.design/components/eslint-plugin-design-system/no-exported-keyframes/usage for more
|
|
8
|
-
details.
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
# no-exported-styles
|
|
2
|
-
|
|
3
|
-
Blocks exports of `css`, `cssMap`, `keyframes`, `styled`, `xcss` styles, which are unsafe.
|
|
4
|
-
|
|
5
|
-
Use alongside `no-imported-style-values` which blocks consumption of imported styles.
|
|
6
|
-
|
|
7
|
-
Compiled style declarations are null at runtime, so using imported styles will cause unexpected
|
|
8
|
-
errors.
|
|
9
|
-
|
|
10
|
-
Co-locate style definitions with their usage instead. This will also improve code readability,
|
|
11
|
-
maintainability and build performance.
|
|
12
|
-
|
|
13
|
-
## Examples
|
|
14
|
-
|
|
15
|
-
### Incorrect
|
|
16
|
-
|
|
17
|
-
```tsx
|
|
18
|
-
import { css } from '@compiled/react';
|
|
19
|
-
|
|
20
|
-
export const styles = css({});
|
|
21
|
-
|
|
22
|
-
export default css({});
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
```tsx
|
|
26
|
-
import { keyframes } from '@compiled/react';
|
|
27
|
-
|
|
28
|
-
export const animation = keyframes({});
|
|
29
|
-
|
|
30
|
-
export default keyframes({});
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
```tsx
|
|
34
|
-
import { css } from '@compiled/react';
|
|
35
|
-
import { token } from '@atlaskit/tokens';
|
|
36
|
-
|
|
37
|
-
const colorStyles = css({
|
|
38
|
-
color: token('color.text'),
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const styles = {
|
|
42
|
-
primary: {
|
|
43
|
-
text: {
|
|
44
|
-
color,
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export default styles.primary.text.color;
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Correct
|
|
53
|
-
|
|
54
|
-
Co-locate styles with components to improve code readability, linting, and build performance.
|
|
55
|
-
|
|
56
|
-
```tsx
|
|
57
|
-
import { css } from '@compiled/react';
|
|
58
|
-
|
|
59
|
-
const styles = css({});
|
|
60
|
-
|
|
61
|
-
export const Component = () => <div css={styles} />;
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
```tsx
|
|
65
|
-
import { css, keyframes } from '@compiled/react';
|
|
66
|
-
|
|
67
|
-
const animation = keyframes({});
|
|
68
|
-
const styles = css({ animate: `${animation} 1s ease-in` });
|
|
69
|
-
|
|
70
|
-
export const Component = () => <div css={styles} />;
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Options
|
|
74
|
-
|
|
75
|
-
### `importSources: string[]`
|
|
76
|
-
|
|
77
|
-
By default, this rule will check styles using:
|
|
78
|
-
|
|
79
|
-
- `@atlaskit/css`
|
|
80
|
-
- `@atlaskit/primitives`
|
|
81
|
-
- `@compiled/react`
|
|
82
|
-
- `@emotion/react`
|
|
83
|
-
- `@emotion/core`
|
|
84
|
-
- `@emotion/styled`
|
|
85
|
-
- `styled-components`
|
|
86
|
-
|
|
87
|
-
Override this list with the `importSources` option, which accepts an array of package names.
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
# no-global-styles
|
|
2
|
-
|
|
3
|
-
Blocks global styles through CSS-in-JS and CSS module imports.
|
|
4
|
-
|
|
5
|
-
Use local styles so that style dependencies are statically resolvable.
|
|
6
|
-
|
|
7
|
-
The only global styling that should be used is `@atlaskit/css-reset`.
|
|
8
|
-
|
|
9
|
-
## Examples
|
|
10
|
-
|
|
11
|
-
### Incorrect
|
|
12
|
-
|
|
13
|
-
```tsx
|
|
14
|
-
import { Global } from '@emotion/react';
|
|
15
|
-
|
|
16
|
-
<Global
|
|
17
|
-
styles={{
|
|
18
|
-
'.some-class': {
|
|
19
|
-
fontSize: 50,
|
|
20
|
-
textAlign: 'center',
|
|
21
|
-
},
|
|
22
|
-
}}
|
|
23
|
-
/>;
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
```tsx
|
|
27
|
-
import { createGlobalStyle } from 'styled-components';
|
|
28
|
-
|
|
29
|
-
const GlobalStyle = createGlobalStyle({
|
|
30
|
-
body: {
|
|
31
|
-
margin: 0,
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
```tsx
|
|
37
|
-
import { injectGlobal } from 'styled-components';
|
|
38
|
-
|
|
39
|
-
injectGlobal({
|
|
40
|
-
body: {
|
|
41
|
-
margin: 0,
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
```tsx
|
|
47
|
-
<style>
|
|
48
|
-
{`
|
|
49
|
-
.some-class {
|
|
50
|
-
color: red;
|
|
51
|
-
}
|
|
52
|
-
`}
|
|
53
|
-
</style>
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### Correct
|
|
57
|
-
|
|
58
|
-
```tsx
|
|
59
|
-
import '@atlaskit/css-reset';
|
|
60
|
-
```
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# no-important-styles
|
|
2
|
-
|
|
3
|
-
Blocks the `!important` flag in style declarations.
|
|
4
|
-
|
|
5
|
-
Properly composed styles will never need an `!important` flag. It is used to override specificity
|
|
6
|
-
when working across different scopes, and the UI Styling Standard enforces styles with minimal
|
|
7
|
-
scope.
|
|
8
|
-
|
|
9
|
-
The use of `!important` is a code smell and greatly impacts readability and determinism.
|
|
10
|
-
|
|
11
|
-
## Examples
|
|
12
|
-
|
|
13
|
-
### Incorrect
|
|
14
|
-
|
|
15
|
-
```js
|
|
16
|
-
import { css } from '@compiled/react';
|
|
17
|
-
import { token } from '@atlaskit/tokens';
|
|
18
|
-
|
|
19
|
-
const styles = css({
|
|
20
|
-
color: `${token('color.text.danger')}!important`,
|
|
21
|
-
});
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Correct
|
|
25
|
-
|
|
26
|
-
```js
|
|
27
|
-
import { css } from '@compiled/react';
|
|
28
|
-
import { token } from '@atlaskit/tokens';
|
|
29
|
-
|
|
30
|
-
const styles = css({
|
|
31
|
-
color: token('color.text.danger'),
|
|
32
|
-
});
|
|
33
|
-
```
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
# no-imported-style-values
|
|
2
|
-
|
|
3
|
-
Blocks imported style values in `css`, `cssMap`, `styled`, `keyframes` and `xcss` calls.
|
|
4
|
-
|
|
5
|
-
Use alongside `no-exported-styles` which blocks exporting styles.
|
|
6
|
-
|
|
7
|
-
Compiled style declarations are null at runtime, so using imported styles will cause unexpected
|
|
8
|
-
errors.
|
|
9
|
-
|
|
10
|
-
Co-locate style definitions with their usage instead. This will also improve code readability and
|
|
11
|
-
build performance.
|
|
12
|
-
|
|
13
|
-
## Examples
|
|
14
|
-
|
|
15
|
-
### Incorrect
|
|
16
|
-
|
|
17
|
-
```tsx
|
|
18
|
-
import { css } from '@compiled/react';
|
|
19
|
-
import { colors, getColor } from '../shared';
|
|
20
|
-
|
|
21
|
-
const styles = css({
|
|
22
|
-
color: getColor('red'),
|
|
23
|
-
backgroundColor: colors['red'],
|
|
24
|
-
});
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
```tsx
|
|
28
|
-
import { css } from '@compiled/react';
|
|
29
|
-
import { ff } from '@atlaskit/ff';
|
|
30
|
-
import { buttonStyles, cssShared, HEIGHT, colorKey } from '../shared';
|
|
31
|
-
|
|
32
|
-
const sharedObject = { padding: 0 };
|
|
33
|
-
|
|
34
|
-
const styles = css({
|
|
35
|
-
...cssShared,
|
|
36
|
-
...sharedObject,
|
|
37
|
-
height: `${HEIGHT}px`,
|
|
38
|
-
width: ff('…') ? `${HEIGHT}px` : undefined,
|
|
39
|
-
});
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
Importing styles to use in style composition is not allowed.
|
|
43
|
-
|
|
44
|
-
```tsx
|
|
45
|
-
import { css } from '@compiled/react';
|
|
46
|
-
import { token } from '@atlaskit/tokens';
|
|
47
|
-
import { buttonStyles } from '../shared';
|
|
48
|
-
|
|
49
|
-
const styles = css({
|
|
50
|
-
color: token('color.text'),
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const Component = () => <div css={[styles, buttonStyles]} />;
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Importing styles to pass to the style prop is also not allowed.
|
|
57
|
-
|
|
58
|
-
```tsx
|
|
59
|
-
import { importedWidth } from '../shared';
|
|
60
|
-
|
|
61
|
-
const Component = () => <div style={{ width: importedWidth }} />;
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### Correct
|
|
65
|
-
|
|
66
|
-
Co-locate styles with components to improve code readability, linting, and build performance.
|
|
67
|
-
|
|
68
|
-
```tsx
|
|
69
|
-
import { css } from '@compiled/react';
|
|
70
|
-
import { token } from '@atlaskit/tokens';
|
|
71
|
-
|
|
72
|
-
const styles = css({
|
|
73
|
-
color: token('color.text'),
|
|
74
|
-
padding: token('space.150'),
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
const Component = () => <div css={styles} />;
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
```tsx
|
|
81
|
-
import { keyframes } from '@compiled/react';
|
|
82
|
-
|
|
83
|
-
const animation = keyframes({});
|
|
84
|
-
const styles = css({ animate: `${animation} 1s ease-in` });
|
|
85
|
-
|
|
86
|
-
const Component = () => <div css={styles} />;
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
## Options
|
|
90
|
-
|
|
91
|
-
### `allowedDynamicKeys: [string, string][]`
|
|
92
|
-
|
|
93
|
-
Use this to allow specified imports as dynamic keys, in addition to the built-in allow-list.
|
|
94
|
-
|
|
95
|
-
Each value should be a two-element array. The first item is the entrypoint, and the second item is a
|
|
96
|
-
named export.
|
|
97
|
-
|
|
98
|
-
Default imports are not supported.
|
|
99
|
-
|
|
100
|
-
```tsx
|
|
101
|
-
// .eslintrc.js
|
|
102
|
-
|
|
103
|
-
// ...
|
|
104
|
-
rules: {
|
|
105
|
-
'@atlaskit/eslint-plugin-ui-styling-standard/no-unsafe-values': [
|
|
106
|
-
'error',
|
|
107
|
-
{
|
|
108
|
-
allowedDynamicKeys: [
|
|
109
|
-
['@atlaskit/primitives/responsive', 'media'],
|
|
110
|
-
]
|
|
111
|
-
},
|
|
112
|
-
],
|
|
113
|
-
// ...
|
|
114
|
-
},
|
|
115
|
-
// ...
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### `allowedFunctionCalls: [string, string][]`
|
|
119
|
-
|
|
120
|
-
Use this to allow specific functions to be called, in addition to the built-in allow-list.
|
|
121
|
-
|
|
122
|
-
Each value should be a two-element array. The first item is the entrypoint, and the second item is a
|
|
123
|
-
named export.
|
|
124
|
-
|
|
125
|
-
Default imports are not currently supported.
|
|
126
|
-
|
|
127
|
-
```tsx
|
|
128
|
-
// .eslintrc.js
|
|
129
|
-
|
|
130
|
-
// ...
|
|
131
|
-
rules: {
|
|
132
|
-
'@atlaskit/eslint-plugin-ui-styling-standard/no-unsafe-values': [
|
|
133
|
-
'error',
|
|
134
|
-
{
|
|
135
|
-
allowedFunctionCalls: [
|
|
136
|
-
['@atlaskit/tokens', 'token'],
|
|
137
|
-
]
|
|
138
|
-
},
|
|
139
|
-
],
|
|
140
|
-
// ...
|
|
141
|
-
},
|
|
142
|
-
// ...
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### `importSources: string[]`
|
|
146
|
-
|
|
147
|
-
By default, this rule will check styles using:
|
|
148
|
-
|
|
149
|
-
- `@atlaskit/css`
|
|
150
|
-
- `@atlaskit/primitives`
|
|
151
|
-
- `@compiled/react`
|
|
152
|
-
- `@emotion/react`
|
|
153
|
-
- `@emotion/core`
|
|
154
|
-
- `@emotion/styled`
|
|
155
|
-
- `styled-components`
|
|
156
|
-
|
|
157
|
-
Override this list with the `importSources` option, which accepts an array of package names.
|