@atlaskit/eslint-plugin-ui-styling-standard 0.10.0 → 0.11.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 +16 -0
- package/README.md +2 -0
- package/constellation/index/overview.mdx +2 -0
- package/constellation/no-exported-styles/usage.mdx +87 -0
- package/constellation/no-unsafe-values/usage.mdx +222 -0
- package/dist/cjs/presets/all.codegen.js +3 -1
- package/dist/cjs/presets/recommended.codegen.js +3 -1
- package/dist/cjs/rules/index.codegen.js +6 -2
- package/dist/cjs/rules/no-exported-styles/index.js +39 -0
- package/dist/cjs/rules/no-unsafe-values/index.js +85 -0
- package/dist/cjs/rules/no-unsafe-values/messages.js +24 -0
- package/dist/cjs/rules/no-unsafe-values/utils.js +437 -0
- package/dist/es2019/presets/all.codegen.js +3 -1
- package/dist/es2019/presets/recommended.codegen.js +3 -1
- package/dist/es2019/rules/index.codegen.js +6 -2
- package/dist/es2019/rules/no-exported-styles/index.js +33 -0
- package/dist/es2019/rules/no-unsafe-values/index.js +80 -0
- package/dist/es2019/rules/no-unsafe-values/messages.js +72 -0
- package/dist/es2019/rules/no-unsafe-values/utils.js +350 -0
- package/dist/esm/presets/all.codegen.js +3 -1
- package/dist/esm/presets/recommended.codegen.js +3 -1
- package/dist/esm/rules/index.codegen.js +6 -2
- package/dist/esm/rules/no-exported-styles/index.js +33 -0
- package/dist/esm/rules/no-unsafe-values/index.js +79 -0
- package/dist/esm/rules/no-unsafe-values/messages.js +17 -0
- package/dist/esm/rules/no-unsafe-values/utils.js +430 -0
- package/dist/types/index.codegen.d.ts +4 -0
- package/dist/types/presets/all.codegen.d.ts +3 -1
- package/dist/types/presets/recommended.codegen.d.ts +3 -1
- package/dist/types/rules/index.codegen.d.ts +2 -0
- package/dist/types/rules/no-exported-styles/index.d.ts +2 -0
- package/dist/types/rules/no-unsafe-values/index.d.ts +2 -0
- package/dist/types/rules/no-unsafe-values/messages.d.ts +13 -0
- package/dist/types/rules/no-unsafe-values/utils.d.ts +28 -0
- package/dist/types-ts4.5/index.codegen.d.ts +4 -0
- package/dist/types-ts4.5/presets/all.codegen.d.ts +3 -1
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +3 -1
- package/dist/types-ts4.5/rules/index.codegen.d.ts +2 -0
- package/dist/types-ts4.5/rules/no-exported-styles/index.d.ts +2 -0
- package/dist/types-ts4.5/rules/no-unsafe-values/index.d.ts +2 -0
- package/dist/types-ts4.5/rules/no-unsafe-values/messages.d.ts +13 -0
- package/dist/types-ts4.5/rules/no-unsafe-values/utils.d.ts +28 -0
- package/package.json +4 -4
- package/src/presets/all.codegen.tsx +3 -1
- package/src/presets/recommended.codegen.tsx +3 -1
- package/src/rules/index.codegen.tsx +5 -1
- package/src/rules/no-exported-styles/README.md +85 -0
- package/src/rules/no-exported-styles/__tests__/rule.test.tsx +225 -0
- package/src/rules/no-exported-styles/index.tsx +52 -0
- package/src/rules/no-unsafe-values/README.md +220 -0
- package/src/rules/no-unsafe-values/__tests__/no-array-values.test.tsx +27 -0
- package/src/rules/no-unsafe-values/__tests__/no-conditional-values.test.tsx +37 -0
- package/src/rules/no-unsafe-values/__tests__/no-dynamic-keys.test.tsx +229 -0
- package/src/rules/no-unsafe-values/__tests__/no-function-calls.test.tsx +267 -0
- package/src/rules/no-unsafe-values/__tests__/no-identifier-arguments.test.tsx +52 -0
- package/src/rules/no-unsafe-values/__tests__/no-object-access.test.tsx +106 -0
- package/src/rules/no-unsafe-values/__tests__/no-object-references.test.tsx +44 -0
- package/src/rules/no-unsafe-values/__tests__/no-spread-elements.test.tsx +48 -0
- package/src/rules/no-unsafe-values/__tests__/no-unsafe-values.test.tsx +75 -0
- package/src/rules/no-unsafe-values/__tests__/no-variables.test.tsx +121 -0
- package/src/rules/no-unsafe-values/index.tsx +96 -0
- package/src/rules/no-unsafe-values/messages.tsx +86 -0
- package/src/rules/no-unsafe-values/utils.tsx +399 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-ui-styling-standard
|
|
2
2
|
|
|
3
|
+
## 0.11.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#92963](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/92963) [`1bb8557fb0b6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1bb8557fb0b6) - Added no-exported-styles eslint rule to disallow exports of css, cssMap, keyframes, styled and xcss styling
|
|
8
|
+
|
|
9
|
+
## 0.11.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#87213](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/87213) [`fbfa5a58cf39`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fbfa5a58cf39) - Adds `no-unsafe-values` rule, which forbids most dynamic styling in `css`/`styled`/`keyframes`/`cssMap`/`xcss` function calls. This includes object spreading, function calls, and so on.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 0.10.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -20,8 +20,10 @@ Not intended for use outside the Atlassian frontend repository.
|
|
|
20
20
|
| <a href="./src/rules/no-classname-prop/README.md">no-classname-prop</a> | Disallows usage of the `className` prop in JSX | Yes | | |
|
|
21
21
|
| <a href="./src/rules/no-container-queries/README.md">no-container-queries</a> | Prevents usage of @container query within css styling | Yes | | |
|
|
22
22
|
| <a href="./src/rules/no-dynamic-styles/README.md">no-dynamic-styles</a> | Disallows use of dynamic styles in CSS-in-JS calls | Yes | | |
|
|
23
|
+
| <a href="./src/rules/no-exported-styles/README.md">no-exported-styles</a> | Disallows exports of css, keyframes, styled and xcss | Yes | | |
|
|
23
24
|
| <a href="./src/rules/no-important-styles/README.md">no-important-styles</a> | Disallows important style declarations | Yes | | |
|
|
24
25
|
| <a href="./src/rules/no-nested-selectors/README.md">no-nested-selectors</a> | Prevents usage of nested selectors within css styling | Yes | | |
|
|
26
|
+
| <a href="./src/rules/no-unsafe-values/README.md">no-unsafe-values</a> | Disallows styles that are difficult/impossible to statically anaylze. | Yes | | |
|
|
25
27
|
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/consistent-css-prop-usage/usage">@atlaskit/design-system/consistent-css-prop-usage</a> | Ensures consistency with `css` and `xcss` prop usages | Yes | Yes | |
|
|
26
28
|
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-css-tagged-template-expression/usage">@atlaskit/design-system/no-css-tagged-template-expression</a> | Disallows any `css` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
|
|
27
29
|
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-keyframes-tagged-template-expression/usage">@atlaskit/design-system/no-keyframes-tagged-template-expression</a> | Disallows any `keyframe` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
|
|
@@ -18,8 +18,10 @@ but more are planned to support the standard over time.
|
|
|
18
18
|
| <a href="no-classname-prop/usage">no-classname-prop</a> | Disallows usage of the `className` prop in JSX | Yes | | |
|
|
19
19
|
| <a href="no-container-queries/usage">no-container-queries</a> | Prevents usage of @container query within css styling | Yes | | |
|
|
20
20
|
| <a href="no-dynamic-styles/usage">no-dynamic-styles</a> | Disallows use of dynamic styles in CSS-in-JS calls | Yes | | |
|
|
21
|
+
| <a href="no-exported-styles/usage">no-exported-styles</a> | Disallows exports of css, keyframes, styled and xcss | Yes | | |
|
|
21
22
|
| <a href="no-important-styles/usage">no-important-styles</a> | Disallows important style declarations | Yes | | |
|
|
22
23
|
| <a href="no-nested-selectors/usage">no-nested-selectors</a> | Prevents usage of nested selectors within css styling | Yes | | |
|
|
24
|
+
| <a href="no-unsafe-values/usage">no-unsafe-values</a> | Disallows styles that are difficult/impossible to statically anaylze. | Yes | | |
|
|
23
25
|
| <a href="consistent-css-prop-usage/usage">@atlaskit/design-system/consistent-css-prop-usage</a> | Ensures consistency with `css` and `xcss` prop usages | Yes | Yes | |
|
|
24
26
|
| <a href="no-css-tagged-template-expression/usage">@atlaskit/design-system/no-css-tagged-template-expression</a> | Disallows any `css` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
|
|
25
27
|
| <a href="no-keyframes-tagged-template-expression/usage">@atlaskit/design-system/no-keyframes-tagged-template-expression</a> | Disallows any `keyframe` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# no-exported-styles
|
|
2
|
+
|
|
3
|
+
This rule disallows exports of `css`, `cssMap`, `keyframes`, `styled`, `xcss` styles.
|
|
4
|
+
|
|
5
|
+
Exporting style declarations from these libraries may result in unexpected errors when imported, because its value will be null at runtime. Additionally, co-locating style definitions with their usage is considered best practice in order to improve code readability and build performance.
|
|
6
|
+
|
|
7
|
+
## Examples
|
|
8
|
+
|
|
9
|
+
### Incorrect
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
import { css } from '@compiled/react';
|
|
13
|
+
|
|
14
|
+
export const styles = css({});
|
|
15
|
+
|
|
16
|
+
export default css({});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import { keyframes } from '@compiled/react';
|
|
21
|
+
|
|
22
|
+
export const animation = keyframes({});
|
|
23
|
+
|
|
24
|
+
export default keyframes({});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Avoid exporting any style-like objects or values for consumption as well as these will violate our `no-imported-style-values` rule which blocks consumption of imported styles.
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
export default {
|
|
31
|
+
color: 'red',
|
|
32
|
+
margin: '0px',
|
|
33
|
+
};
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
import { css } from '@compiled/react';
|
|
38
|
+
|
|
39
|
+
const color = css({
|
|
40
|
+
/* */
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const styles = {
|
|
44
|
+
primary: {
|
|
45
|
+
text: {
|
|
46
|
+
color,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default styles.primary.text.color;
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Correct
|
|
55
|
+
|
|
56
|
+
Co-locate your styles next to your components to improve code readability, linting, and build performance.
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
import { css } from '@compiled/react';
|
|
60
|
+
|
|
61
|
+
const styles = css({});
|
|
62
|
+
export const Component = ({ children }) => <div css={styles}>{children}></div>;
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
import { keyframes } from '@compiled/react';
|
|
67
|
+
|
|
68
|
+
const animation = keyframes({});
|
|
69
|
+
const styles = css({ animate: `${animation} 1s ease-in` });
|
|
70
|
+
export const Component = ({ children }) => <div css={styles}>{children}></div>;
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Options
|
|
74
|
+
|
|
75
|
+
### importSources
|
|
76
|
+
|
|
77
|
+
By default, this rule will check `css` usages from:
|
|
78
|
+
|
|
79
|
+
- `@atlaskit/css`
|
|
80
|
+
- `@atlaskit/primitives`
|
|
81
|
+
- `@compiled/react`
|
|
82
|
+
- `@emotion/react`
|
|
83
|
+
- `@emotion/core`
|
|
84
|
+
- `@emotion/styled`
|
|
85
|
+
- `styled-components`
|
|
86
|
+
|
|
87
|
+
To change this list of libraries, you can define a custom set of `importSources`, which accepts an array of package names (strings).
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# no-unsafe-values
|
|
2
|
+
|
|
3
|
+
This rule prevents the usage of styles that are difficult/impossible to statically anaylze.
|
|
4
|
+
|
|
5
|
+
## Examples
|
|
6
|
+
|
|
7
|
+
### Incorrect
|
|
8
|
+
|
|
9
|
+
**Function calls**
|
|
10
|
+
|
|
11
|
+
Function calls are not allowed as arguments or as values,
|
|
12
|
+
unless they are specified in `allowedFunctionCalls` (or in the default list).
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { css } from '@compiled/react';
|
|
16
|
+
|
|
17
|
+
function getStyles() {
|
|
18
|
+
return { width: 100 };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const styles = css(getStyles());
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { css } from '@compiled/react';
|
|
26
|
+
|
|
27
|
+
function getWidth() {
|
|
28
|
+
return 100;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const styles = css({
|
|
32
|
+
width: getWidth(),
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Dynamic keys**
|
|
37
|
+
|
|
38
|
+
Dynamic keys are not allowed,
|
|
39
|
+
unless they are specified in `allowedDynamicKeys` (or in the default list).
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { css } from '@compiled/react';
|
|
43
|
+
import { SELECTOR } from 'my-package';
|
|
44
|
+
|
|
45
|
+
const styles = css({
|
|
46
|
+
[SELECTOR]: {
|
|
47
|
+
color: 'red',
|
|
48
|
+
},
|
|
49
|
+
[`${SELECTOR} > p`]: {
|
|
50
|
+
width: 100,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Variables**
|
|
56
|
+
|
|
57
|
+
Variables are not allowed as values, unless they:
|
|
58
|
+
|
|
59
|
+
- Have a simple, static value
|
|
60
|
+
- Are defined in the same file
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
import { css } from '@compiled/react';
|
|
64
|
+
import { SELECTOR } from 'my-package';
|
|
65
|
+
|
|
66
|
+
function myFunction() {
|
|
67
|
+
return '5px';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const styles = css({
|
|
71
|
+
height: myFunction,
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Object access**
|
|
76
|
+
|
|
77
|
+
Accessing object members is not allowed in values.
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
import { css } from '@compiled/react';
|
|
81
|
+
import { token } from '@atlaskit/tokens';
|
|
82
|
+
|
|
83
|
+
const colors = {
|
|
84
|
+
text: token('color.text'),
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const styles = css({
|
|
88
|
+
color: colors.text,
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Spread elements**
|
|
93
|
+
|
|
94
|
+
Spread elements are not allowed.
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import { css } from '@compiled/react';
|
|
98
|
+
|
|
99
|
+
const buttonStyles = {
|
|
100
|
+
color: 'blue',
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const styles = css({
|
|
104
|
+
...buttonStyles,
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Array values**
|
|
109
|
+
|
|
110
|
+
Array values are not allowed.
|
|
111
|
+
This syntax is not supported by most styling libraries.
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
import { css } from '@compiled/react';
|
|
115
|
+
|
|
116
|
+
const styles = css({
|
|
117
|
+
'::before': [{ fontWeight: 'bold' }, { color: 'red' }],
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Correct
|
|
122
|
+
|
|
123
|
+
Things to note about the following example:
|
|
124
|
+
|
|
125
|
+
- The `warningStyles` are conditionally applied using the `css` prop
|
|
126
|
+
- The dynamic `width` is applied using the `style` prop
|
|
127
|
+
- The `token()` calls are allowed because they are statically analyzable (and in the default allow-list)
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
import { css } from '@compiled/react';
|
|
131
|
+
import { token } from '@atlaskit/tokens';
|
|
132
|
+
|
|
133
|
+
const baseStyles = css({
|
|
134
|
+
height: 100,
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
const warningStyles = css({
|
|
138
|
+
color: token('color.text.warning'),
|
|
139
|
+
backgroundColor: token('color.background.warning'),
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const Component = ({
|
|
143
|
+
isWarning,
|
|
144
|
+
width,
|
|
145
|
+
}: {
|
|
146
|
+
isWarning: boolean;
|
|
147
|
+
width: number;
|
|
148
|
+
}) => {
|
|
149
|
+
return (
|
|
150
|
+
<div style={{ width }} css={[baseStyles, isWarning && warningStyles]} />
|
|
151
|
+
);
|
|
152
|
+
};
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Options
|
|
156
|
+
|
|
157
|
+
### `allowedDynamicKeys: [string, string][]`
|
|
158
|
+
|
|
159
|
+
Use this to allow specified imports as dynamic keys, in addition to the built-in allow-list.
|
|
160
|
+
|
|
161
|
+
Each value should be a two-element array. The first item is the entrypoint, and the second item is a named export.
|
|
162
|
+
|
|
163
|
+
Default imports are not supported.
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
// .eslintrc.js
|
|
167
|
+
|
|
168
|
+
// ...
|
|
169
|
+
rules: {
|
|
170
|
+
'@atlaskit/eslint-plugin-ui-styling-standard/no-unsafe-values': [
|
|
171
|
+
'error',
|
|
172
|
+
{
|
|
173
|
+
allowedDynamicKeys: [
|
|
174
|
+
['@atlaskit/primitives/responsive', 'media'],
|
|
175
|
+
]
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
// ...
|
|
179
|
+
},
|
|
180
|
+
// ...
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### `allowedFunctionCalls: [string, string][]`
|
|
184
|
+
|
|
185
|
+
Use this to allow specific functions to be called, in addition to the built-in allow-list.
|
|
186
|
+
|
|
187
|
+
Each value should be a two-element array. The first item is the entrypoint, and the second item is a named export.
|
|
188
|
+
|
|
189
|
+
Default imports are not currently supported.
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
// .eslintrc.js
|
|
193
|
+
|
|
194
|
+
// ...
|
|
195
|
+
rules: {
|
|
196
|
+
'@atlaskit/eslint-plugin-ui-styling-standard/no-unsafe-values': [
|
|
197
|
+
'error',
|
|
198
|
+
{
|
|
199
|
+
allowedFunctionCalls: [
|
|
200
|
+
['@atlaskit/tokens', 'token'],
|
|
201
|
+
]
|
|
202
|
+
},
|
|
203
|
+
],
|
|
204
|
+
// ...
|
|
205
|
+
},
|
|
206
|
+
// ...
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### `importSources : string[]`
|
|
210
|
+
|
|
211
|
+
By default, this rule will check `css` usages from:
|
|
212
|
+
|
|
213
|
+
- `@atlaskit/css`
|
|
214
|
+
- `@atlaskit/primitives`
|
|
215
|
+
- `@compiled/react`
|
|
216
|
+
- `@emotion/react`
|
|
217
|
+
- `@emotion/core`
|
|
218
|
+
- `@emotion/styled`
|
|
219
|
+
- `styled-components`
|
|
220
|
+
|
|
221
|
+
To change this list of libraries, you can define a custom set of `importSources`, which accepts an array of package names (strings).
|
|
222
|
+
This will override the built-in allow-list.
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
9
|
-
* @codegen <<SignedSource::
|
|
9
|
+
* @codegen <<SignedSource::42dc97374e2e4fd9ea068b3564bdcb72>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -19,8 +19,10 @@ var _default = exports.default = {
|
|
|
19
19
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
|
|
20
20
|
'@atlaskit/ui-styling-standard/no-container-queries': 'warn',
|
|
21
21
|
'@atlaskit/ui-styling-standard/no-dynamic-styles': 'warn',
|
|
22
|
+
'@atlaskit/ui-styling-standard/no-exported-styles': 'warn',
|
|
22
23
|
'@atlaskit/ui-styling-standard/no-important-styles': 'warn',
|
|
23
24
|
'@atlaskit/ui-styling-standard/no-nested-selectors': 'warn',
|
|
25
|
+
'@atlaskit/ui-styling-standard/no-unsafe-values': 'warn',
|
|
24
26
|
'@atlaskit/design-system/consistent-css-prop-usage': ['warn', {
|
|
25
27
|
excludeReactComponents: true
|
|
26
28
|
}],
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
9
|
-
* @codegen <<SignedSource::
|
|
9
|
+
* @codegen <<SignedSource::42dc97374e2e4fd9ea068b3564bdcb72>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -19,8 +19,10 @@ var _default = exports.default = {
|
|
|
19
19
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
|
|
20
20
|
'@atlaskit/ui-styling-standard/no-container-queries': 'warn',
|
|
21
21
|
'@atlaskit/ui-styling-standard/no-dynamic-styles': 'warn',
|
|
22
|
+
'@atlaskit/ui-styling-standard/no-exported-styles': 'warn',
|
|
22
23
|
'@atlaskit/ui-styling-standard/no-important-styles': 'warn',
|
|
23
24
|
'@atlaskit/ui-styling-standard/no-nested-selectors': 'warn',
|
|
25
|
+
'@atlaskit/ui-styling-standard/no-unsafe-values': 'warn',
|
|
24
26
|
'@atlaskit/design-system/consistent-css-prop-usage': ['warn', {
|
|
25
27
|
excludeReactComponents: true
|
|
26
28
|
}],
|
|
@@ -12,11 +12,13 @@ var _noArrayArguments = _interopRequireDefault(require("./no-array-arguments"));
|
|
|
12
12
|
var _noClassnameProp = _interopRequireDefault(require("./no-classname-prop"));
|
|
13
13
|
var _noContainerQueries = _interopRequireDefault(require("./no-container-queries"));
|
|
14
14
|
var _noDynamicStyles = _interopRequireDefault(require("./no-dynamic-styles"));
|
|
15
|
+
var _noExportedStyles = _interopRequireDefault(require("./no-exported-styles"));
|
|
15
16
|
var _noImportantStyles = _interopRequireDefault(require("./no-important-styles"));
|
|
16
17
|
var _noNestedSelectors = _interopRequireDefault(require("./no-nested-selectors"));
|
|
18
|
+
var _noUnsafeValues = _interopRequireDefault(require("./no-unsafe-values"));
|
|
17
19
|
/**
|
|
18
20
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
19
|
-
* @codegen <<SignedSource::
|
|
21
|
+
* @codegen <<SignedSource::1c60c9984196cab3d54e3144c59ba97c>>
|
|
20
22
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
21
23
|
*/
|
|
22
24
|
var _default = exports.default = {
|
|
@@ -27,6 +29,8 @@ var _default = exports.default = {
|
|
|
27
29
|
'no-classname-prop': _noClassnameProp.default,
|
|
28
30
|
'no-container-queries': _noContainerQueries.default,
|
|
29
31
|
'no-dynamic-styles': _noDynamicStyles.default,
|
|
32
|
+
'no-exported-styles': _noExportedStyles.default,
|
|
30
33
|
'no-important-styles': _noImportantStyles.default,
|
|
31
|
-
'no-nested-selectors': _noNestedSelectors.default
|
|
34
|
+
'no-nested-selectors': _noNestedSelectors.default,
|
|
35
|
+
'no-unsafe-values': _noUnsafeValues.default
|
|
32
36
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.rule = exports.default = void 0;
|
|
7
|
+
var _createRule = require("../utils/create-rule");
|
|
8
|
+
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
9
|
+
var _createNoExportedRule = require("@atlaskit/eslint-utils/create-no-exported-rule");
|
|
10
|
+
var schema = [{
|
|
11
|
+
type: 'object',
|
|
12
|
+
properties: {
|
|
13
|
+
importSources: {
|
|
14
|
+
type: 'array',
|
|
15
|
+
items: {
|
|
16
|
+
type: 'string'
|
|
17
|
+
},
|
|
18
|
+
uniqueItems: true
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}];
|
|
22
|
+
var supportedImports = [_isSupportedImport.isCss, _isSupportedImport.isCssMap, _isSupportedImport.isKeyframes, _isSupportedImport.isXcss, _isSupportedImport.isStyled];
|
|
23
|
+
var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
24
|
+
meta: {
|
|
25
|
+
name: 'no-exported-styles',
|
|
26
|
+
docs: {
|
|
27
|
+
description: 'Disallows exports of css, keyframes, styled and xcss',
|
|
28
|
+
recommended: true,
|
|
29
|
+
severity: 'warn'
|
|
30
|
+
},
|
|
31
|
+
messages: {
|
|
32
|
+
'no-exported-styles': 'Styles from css, cssMap, keyframes, styled and xcss should not be exported. All styles should be defined and used in the same file instead.'
|
|
33
|
+
},
|
|
34
|
+
type: 'problem',
|
|
35
|
+
schema: schema
|
|
36
|
+
},
|
|
37
|
+
create: (0, _createNoExportedRule.createNoExportedRule)(supportedImports, 'no-exported-styles')
|
|
38
|
+
});
|
|
39
|
+
var _default = exports.default = rule;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.rule = exports.default = void 0;
|
|
7
|
+
var _createRule = require("../utils/create-rule");
|
|
8
|
+
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
9
|
+
var _utils = require("./utils");
|
|
10
|
+
var _messages = require("./messages");
|
|
11
|
+
var schema = [{
|
|
12
|
+
type: 'object',
|
|
13
|
+
additionalProperties: false,
|
|
14
|
+
properties: {
|
|
15
|
+
importSources: {
|
|
16
|
+
type: 'array',
|
|
17
|
+
items: {
|
|
18
|
+
type: 'string'
|
|
19
|
+
},
|
|
20
|
+
uniqueItems: true
|
|
21
|
+
},
|
|
22
|
+
allowedFunctionCalls: {
|
|
23
|
+
type: 'array',
|
|
24
|
+
items: {
|
|
25
|
+
type: 'array',
|
|
26
|
+
minItems: 2,
|
|
27
|
+
maxItems: 2,
|
|
28
|
+
items: [{
|
|
29
|
+
type: 'string'
|
|
30
|
+
}, {
|
|
31
|
+
type: 'string'
|
|
32
|
+
}]
|
|
33
|
+
},
|
|
34
|
+
uniqueItems: true
|
|
35
|
+
},
|
|
36
|
+
allowedDynamicKeys: {
|
|
37
|
+
type: 'array',
|
|
38
|
+
items: {
|
|
39
|
+
type: 'array',
|
|
40
|
+
minItems: 2,
|
|
41
|
+
maxItems: 2,
|
|
42
|
+
items: [{
|
|
43
|
+
type: 'string'
|
|
44
|
+
}, {
|
|
45
|
+
type: 'string'
|
|
46
|
+
}]
|
|
47
|
+
},
|
|
48
|
+
uniqueItems: true
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}];
|
|
52
|
+
var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
53
|
+
meta: {
|
|
54
|
+
name: 'no-unsafe-values',
|
|
55
|
+
docs: {
|
|
56
|
+
description: 'Disallows styles that are difficult/impossible to statically anaylze.',
|
|
57
|
+
recommended: true,
|
|
58
|
+
severity: 'warn'
|
|
59
|
+
},
|
|
60
|
+
messages: _messages.messages,
|
|
61
|
+
type: 'problem',
|
|
62
|
+
schema: schema
|
|
63
|
+
},
|
|
64
|
+
create: function create(context) {
|
|
65
|
+
var importSources = (0, _isSupportedImport.getImportSources)(context);
|
|
66
|
+
return {
|
|
67
|
+
CallExpression: function CallExpression(node) {
|
|
68
|
+
var _context$sourceCode$g = context.sourceCode.getScope(node),
|
|
69
|
+
references = _context$sourceCode$g.references;
|
|
70
|
+
if (!(0, _isSupportedImport.isCss)(node.callee, references, importSources) && !(0, _isSupportedImport.isStyled)(node.callee, references, importSources) && !(0, _isSupportedImport.isKeyframes)(node.callee, references, importSources) && !(0, _isSupportedImport.isCssMap)(node.callee, references, importSources) && !(0, _isSupportedImport.isXcss)(node.callee, references, importSources)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if ((0, _isSupportedImport.isStyled)(node.callee, references, importSources) && (node.parent.type === 'CallExpression' || node.parent.type === 'TaggedTemplateExpression')) {
|
|
74
|
+
/**
|
|
75
|
+
* If it is of the form styled(Base)({}) we don't want to lint the inner function arguments.
|
|
76
|
+
*/
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
var linter = new _utils.Linter(context, node);
|
|
80
|
+
linter.run();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
var _default = exports.default = rule;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.messages = void 0;
|
|
8
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
|
+
var _outdent = _interopRequireDefault(require("outdent"));
|
|
10
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
|
|
11
|
+
var whereToGetHelp = "If you think this should be allowed, or if you're running into issues, reach out in #help-ui-styling-standard";
|
|
12
|
+
var messages = exports.messages = {
|
|
13
|
+
'no-array-values': (0, _outdent.default)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n Arrays are not allowed in style objects. Support is inconsistent between styling libraries.\n\n Compose styles with the css prop instead.\n\n ", "\n "])), whereToGetHelp),
|
|
14
|
+
'no-conditional-values': (0, _outdent.default)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n Conditional expressions are not allowed in style objects.\n\n Conditionally apply styles with the css prop instead.\n\n ", "\n "])), whereToGetHelp),
|
|
15
|
+
'no-dynamic-keys': (0, _outdent.default)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n Dynamic keys are not allowed in style objects.\n\n ", "\n "])), whereToGetHelp),
|
|
16
|
+
'no-function-calls': (0, _outdent.default)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n Function calls are not allowed in style objects.\n\n ", "\n "])), whereToGetHelp),
|
|
17
|
+
'no-identifier-arguments': (0, _outdent.default)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n Variable arguments are not allowed.\n\n Inline the object value, or compose styles with the css prop instead.\n\n ", "\n "])), whereToGetHelp),
|
|
18
|
+
'no-object-access': (0, _outdent.default)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n Accessing object values is not allowed in style objects.\n\n If you are accessing the component's props, use the style prop to apply dynamic values instead.\n\n ", "\n "])), whereToGetHelp),
|
|
19
|
+
'no-object-references': (0, _outdent.default)(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n Referencing objects is not allowed in style objects.\n\n Inline the object value instead.\n\n ", "\n "])), whereToGetHelp),
|
|
20
|
+
'no-spread-elements': (0, _outdent.default)(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["\n Spread elements are not allowed in style objects.\n\n Compose styles with the css prop instead.\n\n ", "\n "])), whereToGetHelp),
|
|
21
|
+
// Fallback case if a more specific message is not applicable
|
|
22
|
+
'no-unsafe-values': (0, _outdent.default)(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["\n Unsafe values are not allowed in style objects.\n\n ", "\n "])), whereToGetHelp),
|
|
23
|
+
'no-variables': (0, _outdent.default)(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2.default)(["\n Variables are not allowed in style objects, unless they:\n\n - Have a simple, static value.\n - Are defined in the same file.\n\n Use the style prop to apply dynamic values instead.\n\n ", "\n "])), whereToGetHelp)
|
|
24
|
+
};
|