@atlaskit/eslint-plugin-ui-styling-standard 0.15.2 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/constellation/index/migration-guide.mdx +309 -0
- package/constellation/index/overview.mdx +4 -0
- package/constellation/index/props.mdx +9 -5
- package/dist/types/rules/no-unsafe-selectors/constants.d.ts +1 -4
- package/index.js +9 -9
- package/package.json +3 -3
- package/scripts/codegen.tsx +223 -284
- package/src/rules/__tests__/utils/_tester.tsx +24 -24
- package/src/rules/atlaskit-theme/README.md +21 -19
- package/src/rules/atlaskit-theme/__tests__/test.ts +53 -53
- package/src/rules/atlaskit-theme/index.ts +107 -115
- package/src/rules/convert-props-syntax/README.md +32 -22
- package/src/rules/convert-props-syntax/__tests__/invalid.test.tsx +46 -46
- package/src/rules/convert-props-syntax/__tests__/rule.test.tsx +175 -175
- package/src/rules/convert-props-syntax/__tests__/type-annotations.test.tsx +52 -52
- package/src/rules/convert-props-syntax/__tests__/unusual-properties.test.tsx +33 -33
- package/src/rules/convert-props-syntax/index.tsx +356 -386
- package/src/rules/enforce-style-prop/README.md +21 -18
- package/src/rules/enforce-style-prop/__tests__/rule.test.tsx +90 -96
- package/src/rules/enforce-style-prop/index.tsx +144 -160
- package/src/rules/external-rules.tsx +163 -164
- package/src/rules/local-cx-xcss/README.md +10 -6
- package/src/rules/local-cx-xcss/__tests__/rule.test.tsx +26 -26
- package/src/rules/local-cx-xcss/index.tsx +46 -56
- package/src/rules/no-array-arguments/README.md +2 -1
- package/src/rules/no-array-arguments/__tests__/rule.test.tsx +37 -46
- package/src/rules/no-array-arguments/index.tsx +68 -69
- package/src/rules/no-classname-prop/README.md +7 -4
- package/src/rules/no-classname-prop/__tests__/rule.test.tsx +22 -22
- package/src/rules/no-classname-prop/index.tsx +25 -25
- package/src/rules/no-container-queries/README.md +11 -9
- package/src/rules/no-container-queries/__tests__/rule.test.tsx +47 -50
- package/src/rules/no-container-queries/index.tsx +75 -81
- package/src/rules/no-dynamic-styles/README.md +16 -19
- package/src/rules/no-dynamic-styles/__tests__/rule.test.tsx +58 -67
- package/src/rules/no-dynamic-styles/index.tsx +45 -48
- package/src/rules/no-exported-styles/README.md +17 -12
- package/src/rules/no-exported-styles/__tests__/rule.test.tsx +102 -111
- package/src/rules/no-exported-styles/index.tsx +36 -36
- package/src/rules/no-global-styles/README.md +15 -14
- package/src/rules/no-global-styles/__tests__/no-css-modules.test.tsx +28 -28
- package/src/rules/no-global-styles/__tests__/no-global-styles.test.tsx +37 -37
- package/src/rules/no-global-styles/index.tsx +59 -62
- package/src/rules/no-important-styles/README.md +5 -3
- package/src/rules/no-important-styles/__tests__/rule.test.tsx +66 -66
- package/src/rules/no-important-styles/index.tsx +49 -49
- package/src/rules/no-imported-style-values/README.md +23 -15
- package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +123 -123
- package/src/rules/no-imported-style-values/index.tsx +116 -120
- package/src/rules/no-nested-selectors/README.md +15 -13
- package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +128 -128
- package/src/rules/no-styled/README.md +14 -9
- package/src/rules/no-styled/__tests__/rule.test.tsx +31 -31
- package/src/rules/no-styled/index.tsx +34 -41
- package/src/rules/no-unsafe-selectors/README.md +103 -93
- package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +21 -24
- package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +44 -44
- package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +21 -21
- package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +57 -57
- package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +58 -58
- package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +85 -85
- package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +12 -12
- package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +23 -23
- package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +114 -114
- package/src/rules/no-unsafe-selectors/constants.tsx +69 -77
- package/src/rules/no-unsafe-selectors/source-position-utils.tsx +38 -38
- package/src/rules/no-unsafe-selectors/walk-css-map.tsx +178 -184
- package/src/rules/no-unsafe-values/README.md +34 -40
- package/src/rules/no-unsafe-values/__tests__/no-array-values.test.tsx +13 -13
- package/src/rules/no-unsafe-values/__tests__/no-conditional-values.test.tsx +18 -18
- package/src/rules/no-unsafe-values/__tests__/no-dynamic-keys.test.tsx +104 -104
- package/src/rules/no-unsafe-values/__tests__/no-function-calls.test.tsx +128 -128
- package/src/rules/no-unsafe-values/__tests__/no-identifier-arguments.test.tsx +23 -23
- package/src/rules/no-unsafe-values/__tests__/no-object-access.test.tsx +38 -38
- package/src/rules/no-unsafe-values/__tests__/no-object-references.test.tsx +18 -18
- package/src/rules/no-unsafe-values/__tests__/no-spread-elements.test.tsx +18 -18
- package/src/rules/no-unsafe-values/__tests__/no-unsafe-values.test.tsx +28 -28
- package/src/rules/no-unsafe-values/__tests__/no-variables.test.tsx +47 -47
- package/src/rules/no-unsafe-values/index.tsx +76 -78
- package/src/rules/no-unsafe-values/messages.tsx +12 -12
- package/src/rules/no-unsafe-values/utils.tsx +370 -382
- package/src/rules/use-compiled/README.md +11 -8
- package/src/rules/use-compiled/__tests__/can-auto-fix.test.tsx +32 -32
- package/src/rules/use-compiled/__tests__/css.test.tsx +53 -53
- package/src/rules/use-compiled/__tests__/imports.test.tsx +90 -95
- package/src/rules/use-compiled/__tests__/keyframes.test.tsx +47 -47
- package/src/rules/use-compiled/__tests__/pragma.test.tsx +64 -64
- package/src/rules/use-compiled/__tests__/styled.test.tsx +53 -53
- package/src/rules/use-compiled/__tests__/use-compiled.test.tsx +10 -10
- package/src/rules/use-compiled/index.tsx +203 -226
- package/src/rules/use-compiled/is-safe.tsx +113 -117
- package/src/rules/use-compiled/utils.tsx +14 -18
- package/src/rules/utils/create-rule-with-typed-config.tsx +62 -63
- package/src/rules/utils/create-rule.tsx +3 -6
|
@@ -2,34 +2,34 @@ import { typescriptEslintTester } from '../../__tests__/utils/_tester';
|
|
|
2
2
|
import rule from '../index';
|
|
3
3
|
|
|
4
4
|
typescriptEslintTester.run(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
'no-unsafe-values',
|
|
6
|
+
// @ts-expect-error
|
|
7
|
+
rule,
|
|
8
|
+
{
|
|
9
|
+
valid: [
|
|
10
|
+
{
|
|
11
|
+
name: 'key is an identifier',
|
|
12
|
+
code: `
|
|
13
13
|
import { css } from '@compiled/react';
|
|
14
14
|
|
|
15
15
|
const styles = css({
|
|
16
16
|
color: 'blue',
|
|
17
17
|
});
|
|
18
18
|
`,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'key is a literal',
|
|
22
|
+
code: `
|
|
23
23
|
import { css } from '@compiled/react';
|
|
24
24
|
|
|
25
25
|
const styles = css({
|
|
26
26
|
'color': 'blue',
|
|
27
27
|
});
|
|
28
28
|
`,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'key is an allow listed value',
|
|
32
|
+
code: `
|
|
33
33
|
import { css } from '@compiled/react';
|
|
34
34
|
import { media } from 'my-package';
|
|
35
35
|
|
|
@@ -37,15 +37,15 @@ typescriptEslintTester.run(
|
|
|
37
37
|
[media.above.xxs]: { height: '2px' }
|
|
38
38
|
});
|
|
39
39
|
`,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
options: [
|
|
41
|
+
{
|
|
42
|
+
allowedDynamicKeys: [['my-package', 'media']],
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'key is a simple, statically resolvable CSS var',
|
|
48
|
+
code: `
|
|
49
49
|
import { css } from '@compiled/react';
|
|
50
50
|
|
|
51
51
|
const myVar = '--my-var';
|
|
@@ -53,10 +53,10 @@ typescriptEslintTester.run(
|
|
|
53
53
|
[myVar]: 'red'
|
|
54
54
|
});
|
|
55
55
|
`,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'key is on the default allow list',
|
|
59
|
+
code: `
|
|
60
60
|
import { css } from '@compiled/react';
|
|
61
61
|
import { media } from '@atlaskit/primitives/responsive';
|
|
62
62
|
|
|
@@ -64,17 +64,17 @@ typescriptEslintTester.run(
|
|
|
64
64
|
[media.above.xxs]: { height: '2px' }
|
|
65
65
|
});
|
|
66
66
|
`,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
67
|
+
options: [
|
|
68
|
+
{
|
|
69
|
+
allowedDynamicKeys: [],
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
invalid: [
|
|
75
|
+
{
|
|
76
|
+
name: 'key is a template literal',
|
|
77
|
+
code: `
|
|
78
78
|
import { css } from '@compiled/react';
|
|
79
79
|
|
|
80
80
|
const something = 'selector';
|
|
@@ -84,11 +84,11 @@ typescriptEslintTester.run(
|
|
|
84
84
|
},
|
|
85
85
|
});
|
|
86
86
|
`,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
errors: [{ messageId: 'no-dynamic-keys' }],
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'nested key is a template literal',
|
|
91
|
+
code: `
|
|
92
92
|
import { css } from '@compiled/react';
|
|
93
93
|
|
|
94
94
|
const something = 'selector';
|
|
@@ -102,11 +102,11 @@ typescriptEslintTester.run(
|
|
|
102
102
|
},
|
|
103
103
|
});
|
|
104
104
|
`,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
errors: [{ messageId: 'no-dynamic-keys' }],
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: 'key is an identifier for a string literal',
|
|
109
|
+
code: `
|
|
110
110
|
import { css } from '@compiled/react';
|
|
111
111
|
|
|
112
112
|
const something = 'selector';
|
|
@@ -116,11 +116,11 @@ typescriptEslintTester.run(
|
|
|
116
116
|
},
|
|
117
117
|
});
|
|
118
118
|
`,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
errors: [{ messageId: 'no-dynamic-keys' }],
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: 'nested key is an identifier for a string literal',
|
|
123
|
+
code: `
|
|
124
124
|
import { css } from '@compiled/react';
|
|
125
125
|
|
|
126
126
|
const something = 'selector';
|
|
@@ -134,33 +134,33 @@ typescriptEslintTester.run(
|
|
|
134
134
|
},
|
|
135
135
|
});
|
|
136
136
|
`,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
137
|
+
errors: [{ messageId: 'no-dynamic-keys' }],
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: 'key is a string literal inside square brackets',
|
|
141
|
+
code: `
|
|
142
142
|
import { css } from '@compiled/react';
|
|
143
143
|
|
|
144
144
|
const styles = css({
|
|
145
145
|
['color']: 'blue',
|
|
146
146
|
});
|
|
147
147
|
`,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
148
|
+
errors: [{ messageId: 'no-dynamic-keys' }],
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: 'key is a concatenation of string literals',
|
|
152
|
+
code: `
|
|
153
153
|
import { css } from '@compiled/react';
|
|
154
154
|
|
|
155
155
|
const styles = css({
|
|
156
156
|
['col' + 'or']: 'blue',
|
|
157
157
|
});
|
|
158
158
|
`,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
159
|
+
errors: [{ messageId: 'no-dynamic-keys' }],
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: 'nested key is a string literal inside square brackets',
|
|
163
|
+
code: `
|
|
164
164
|
import { css } from '@compiled/react';
|
|
165
165
|
|
|
166
166
|
const styles = css({
|
|
@@ -171,11 +171,11 @@ typescriptEslintTester.run(
|
|
|
171
171
|
},
|
|
172
172
|
});
|
|
173
173
|
`,
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
174
|
+
errors: [{ messageId: 'no-dynamic-keys' }],
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: 'key is an import from a non-allow-listed library',
|
|
178
|
+
code: `
|
|
179
179
|
import { css } from '@compiled/react';
|
|
180
180
|
import { media } from 'my-package';
|
|
181
181
|
|
|
@@ -183,16 +183,16 @@ typescriptEslintTester.run(
|
|
|
183
183
|
[media.above.xxs]: { height: '2px' }
|
|
184
184
|
});
|
|
185
185
|
`,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
186
|
+
errors: [{ messageId: 'no-dynamic-keys' }],
|
|
187
|
+
options: [
|
|
188
|
+
{
|
|
189
|
+
allowedDynamicKeys: [],
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: 'key is a non-allow-listed import from an allow-listed library',
|
|
195
|
+
code: `
|
|
196
196
|
import { css } from '@compiled/react';
|
|
197
197
|
import { mediaNext as media } from 'my-package';
|
|
198
198
|
|
|
@@ -200,16 +200,16 @@ typescriptEslintTester.run(
|
|
|
200
200
|
[media.above.xxs]: { height: '2px' }
|
|
201
201
|
});
|
|
202
202
|
`,
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
203
|
+
errors: [{ messageId: 'no-dynamic-keys' }],
|
|
204
|
+
options: [
|
|
205
|
+
{
|
|
206
|
+
allowedDynamicKeys: [['my-package', 'media']],
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
name: 'key is from a nested entrypoint of an allow-listed library',
|
|
212
|
+
code: `
|
|
213
213
|
import { css } from '@compiled/react';
|
|
214
214
|
import { media } from 'my-package/primitives/responsive';
|
|
215
215
|
|
|
@@ -217,13 +217,13 @@ typescriptEslintTester.run(
|
|
|
217
217
|
[media.above.xxs]: { height: '2px' }
|
|
218
218
|
});
|
|
219
219
|
`,
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
220
|
+
errors: [{ messageId: 'no-dynamic-keys' }],
|
|
221
|
+
options: [
|
|
222
|
+
{
|
|
223
|
+
allowedDynamicKeys: [['my-package/primitives', 'media']],
|
|
224
|
+
},
|
|
225
|
+
],
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
},
|
|
229
229
|
);
|
|
@@ -2,59 +2,59 @@ import { typescriptEslintTester } from '../../__tests__/utils/_tester';
|
|
|
2
2
|
import rule from '../index';
|
|
3
3
|
|
|
4
4
|
typescriptEslintTester.run(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
'no-unsafe-values',
|
|
6
|
+
// @ts-expect-error
|
|
7
|
+
rule,
|
|
8
|
+
{
|
|
9
|
+
valid: [
|
|
10
|
+
{
|
|
11
|
+
name: 'whitelisted function call as value',
|
|
12
|
+
code: `
|
|
13
13
|
import { css } from '@compiled/react';
|
|
14
14
|
import { token } from '@atlaskit/tokens';
|
|
15
15
|
const styles = css({
|
|
16
16
|
height: token('test'),
|
|
17
17
|
});
|
|
18
18
|
`,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
options: [
|
|
20
|
+
{
|
|
21
|
+
allowedFunctionCalls: [['@atlaskit/tokens', 'token']],
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'whitelisted function call as value (variant)',
|
|
27
|
+
code: `
|
|
28
28
|
import { css } from '@compiled/react';
|
|
29
29
|
import { token } from '@atlaskit/tokens';
|
|
30
30
|
const styles = css(() => ({
|
|
31
31
|
height: token('test'),
|
|
32
32
|
}));
|
|
33
33
|
`,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
options: [
|
|
35
|
+
{
|
|
36
|
+
allowedFunctionCalls: [['@atlaskit/tokens', 'token']],
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'whitelisted function call in template literal in value',
|
|
42
|
+
code: `
|
|
43
43
|
import { css } from '@compiled/react';
|
|
44
44
|
import { token } from '@atlaskit/tokens';
|
|
45
45
|
const styles = css({
|
|
46
46
|
height: \`\${token('test')}px\`,
|
|
47
47
|
});
|
|
48
48
|
`,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
options: [
|
|
50
|
+
{
|
|
51
|
+
allowedFunctionCalls: [['@atlaskit/tokens', 'token']],
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'multiple whitelisted functions',
|
|
57
|
+
code: `
|
|
58
58
|
import { css } from '@compiled/react';
|
|
59
59
|
import { token } from '@atlaskit/tokens';
|
|
60
60
|
// We are unlikely to ever do this but I couldn't think of a better example
|
|
@@ -65,18 +65,18 @@ typescriptEslintTester.run(
|
|
|
65
65
|
width: tokenNext('test')
|
|
66
66
|
});
|
|
67
67
|
`,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
68
|
+
options: [
|
|
69
|
+
{
|
|
70
|
+
allowedFunctionCalls: [
|
|
71
|
+
['@atlaskit/tokens', 'token'],
|
|
72
|
+
['@atlaskit/tokens-next', 'tokenNext'],
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'whitelisted functions with aliasing',
|
|
79
|
+
code: `
|
|
80
80
|
import { css } from '@compiled/react';
|
|
81
81
|
import { token } from '@atlaskit/tokens';
|
|
82
82
|
// We are unlikely to ever do this but I couldn't think of a better example
|
|
@@ -87,18 +87,18 @@ typescriptEslintTester.run(
|
|
|
87
87
|
width: tokenNext('test')
|
|
88
88
|
});
|
|
89
89
|
`,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
90
|
+
options: [
|
|
91
|
+
{
|
|
92
|
+
allowedFunctionCalls: [
|
|
93
|
+
['@atlaskit/tokens', 'token'],
|
|
94
|
+
['@atlaskit/tokens-next', 'token'],
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'identifier resolving to whitelisted function call',
|
|
101
|
+
code: `
|
|
102
102
|
import { css } from '@compiled/react';
|
|
103
103
|
import { token } from '@atlaskit/tokens';
|
|
104
104
|
|
|
@@ -108,15 +108,15 @@ typescriptEslintTester.run(
|
|
|
108
108
|
height
|
|
109
109
|
});
|
|
110
110
|
`,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
options: [
|
|
112
|
+
{
|
|
113
|
+
allowedFunctionCalls: [['@atlaskit/tokens', 'token']],
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: 'interpolation with identifier resolving to whitelisted function call',
|
|
119
|
+
code: `
|
|
120
120
|
import { css, keyframes } from '@compiled/react';
|
|
121
121
|
|
|
122
122
|
const fadeIn = keyframes({
|
|
@@ -132,15 +132,15 @@ typescriptEslintTester.run(
|
|
|
132
132
|
animation: \`\${fadeIn} 1s\`
|
|
133
133
|
});
|
|
134
134
|
`,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
135
|
+
options: [
|
|
136
|
+
{
|
|
137
|
+
allowedFunctionCalls: [['@compiled/react', 'keyframes']],
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: 'layers from @atlaskit/theme/constants',
|
|
143
|
+
code: `
|
|
144
144
|
import { css } from '@compiled/react';
|
|
145
145
|
import { layers } from '@atlaskit/theme/constants';
|
|
146
146
|
|
|
@@ -148,12 +148,12 @@ typescriptEslintTester.run(
|
|
|
148
148
|
zIndex: layers.modal(),
|
|
149
149
|
});
|
|
150
150
|
`,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
invalid: [
|
|
154
|
+
{
|
|
155
|
+
name: 'function call as value',
|
|
156
|
+
code: `
|
|
157
157
|
import { css } from '@compiled/react';
|
|
158
158
|
|
|
159
159
|
function myFunction() {
|
|
@@ -164,11 +164,11 @@ typescriptEslintTester.run(
|
|
|
164
164
|
height: myFunction(),
|
|
165
165
|
});
|
|
166
166
|
`,
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
167
|
+
errors: [{ messageId: 'no-function-calls' }],
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: 'function call in template literal in value',
|
|
171
|
+
code: `
|
|
172
172
|
import { css } from '@compiled/react';
|
|
173
173
|
|
|
174
174
|
function myFunction() {
|
|
@@ -179,11 +179,11 @@ typescriptEslintTester.run(
|
|
|
179
179
|
height: \`\${myFunction()}px\`,
|
|
180
180
|
});
|
|
181
181
|
`,
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
errors: [{ messageId: 'no-function-calls' }],
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: 'function call in variable as value',
|
|
186
|
+
code: `
|
|
187
187
|
import { css } from '@compiled/react';
|
|
188
188
|
|
|
189
189
|
function runFunction() { return '5px'; }
|
|
@@ -193,22 +193,22 @@ typescriptEslintTester.run(
|
|
|
193
193
|
height: myFunction,
|
|
194
194
|
});
|
|
195
195
|
`,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
196
|
+
errors: [{ messageId: 'no-function-calls' }],
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: 'immediately-invoked function expression (IIFE) as value',
|
|
200
|
+
code: `
|
|
201
201
|
import { css } from '@compiled/react';
|
|
202
202
|
|
|
203
203
|
const styles = css({
|
|
204
204
|
height: (() => 'red')(),
|
|
205
205
|
});
|
|
206
206
|
`,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
207
|
+
errors: [{ messageId: 'no-function-calls' }],
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
name: 'function call as value with same name as whitelisted function, but from wrong library',
|
|
211
|
+
code: `
|
|
212
212
|
import { css } from '@compiled/react';
|
|
213
213
|
import { token } from 'wrong-library';
|
|
214
214
|
|
|
@@ -216,27 +216,27 @@ typescriptEslintTester.run(
|
|
|
216
216
|
height: token('test'),
|
|
217
217
|
});
|
|
218
218
|
`,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
219
|
+
options: [
|
|
220
|
+
{
|
|
221
|
+
allowedFunctionCalls: [['@atlaskit/tokens', 'token']],
|
|
222
|
+
},
|
|
223
|
+
],
|
|
224
|
+
errors: [{ messageId: 'no-function-calls' }],
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
name: 'tagged template expression in value',
|
|
228
|
+
code: `
|
|
229
229
|
import { css } from '@compiled/react';
|
|
230
230
|
|
|
231
231
|
const styles = css({
|
|
232
232
|
height: someFunction\`color: blue\`,
|
|
233
233
|
});
|
|
234
234
|
`,
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
235
|
+
errors: [{ messageId: 'no-function-calls' }],
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
name: 'tagged template expression in variable',
|
|
239
|
+
code: `
|
|
240
240
|
import { css } from '@compiled/react';
|
|
241
241
|
|
|
242
242
|
const height = someFunction\`color: blue\`
|
|
@@ -245,11 +245,11 @@ typescriptEslintTester.run(
|
|
|
245
245
|
height,
|
|
246
246
|
});
|
|
247
247
|
`,
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
248
|
+
errors: [{ messageId: 'no-function-calls' }],
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
name: 'tagged template expression even if it is an allowed function',
|
|
252
|
+
code: `
|
|
253
253
|
import { css } from '@compiled/react';
|
|
254
254
|
import { someFunction } from 'my-package';
|
|
255
255
|
|
|
@@ -259,9 +259,9 @@ typescriptEslintTester.run(
|
|
|
259
259
|
height,
|
|
260
260
|
});
|
|
261
261
|
`,
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
262
|
+
errors: [{ messageId: 'no-function-calls' }],
|
|
263
|
+
options: [{ allowedFunctionCalls: [['my-package', 'someFunction']] }],
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
},
|
|
267
267
|
);
|