@atlaskit/eslint-plugin-ui-styling-standard 0.18.0 → 0.18.2
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/dist/cjs/rules/no-imported-style-values/index.js +36 -5
- package/dist/es2019/rules/no-imported-style-values/index.js +36 -5
- package/dist/esm/rules/no-imported-style-values/index.js +36 -5
- 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,267 +0,0 @@
|
|
|
1
|
-
import { typescriptEslintTester } from '../../__tests__/utils/_tester';
|
|
2
|
-
import rule from '../index';
|
|
3
|
-
|
|
4
|
-
typescriptEslintTester.run(
|
|
5
|
-
'no-unsafe-values',
|
|
6
|
-
// @ts-expect-error
|
|
7
|
-
rule,
|
|
8
|
-
{
|
|
9
|
-
valid: [
|
|
10
|
-
{
|
|
11
|
-
name: 'whitelisted function call as value',
|
|
12
|
-
code: `
|
|
13
|
-
import { css } from '@compiled/react';
|
|
14
|
-
import { token } from '@atlaskit/tokens';
|
|
15
|
-
const styles = css({
|
|
16
|
-
height: token('test'),
|
|
17
|
-
});
|
|
18
|
-
`,
|
|
19
|
-
options: [
|
|
20
|
-
{
|
|
21
|
-
allowedFunctionCalls: [['@atlaskit/tokens', 'token']],
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: 'whitelisted function call as value (variant)',
|
|
27
|
-
code: `
|
|
28
|
-
import { css } from '@compiled/react';
|
|
29
|
-
import { token } from '@atlaskit/tokens';
|
|
30
|
-
const styles = css(() => ({
|
|
31
|
-
height: token('test'),
|
|
32
|
-
}));
|
|
33
|
-
`,
|
|
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
|
-
import { css } from '@compiled/react';
|
|
44
|
-
import { token } from '@atlaskit/tokens';
|
|
45
|
-
const styles = css({
|
|
46
|
-
height: \`\${token('test')}px\`,
|
|
47
|
-
});
|
|
48
|
-
`,
|
|
49
|
-
options: [
|
|
50
|
-
{
|
|
51
|
-
allowedFunctionCalls: [['@atlaskit/tokens', 'token']],
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: 'multiple whitelisted functions',
|
|
57
|
-
code: `
|
|
58
|
-
import { css } from '@compiled/react';
|
|
59
|
-
import { token } from '@atlaskit/tokens';
|
|
60
|
-
// We are unlikely to ever do this but I couldn't think of a better example
|
|
61
|
-
import { tokenNext } from '@atlaskit/tokens-next';
|
|
62
|
-
|
|
63
|
-
const styles = css({
|
|
64
|
-
height: token('test'),
|
|
65
|
-
width: tokenNext('test')
|
|
66
|
-
});
|
|
67
|
-
`,
|
|
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
|
-
import { css } from '@compiled/react';
|
|
81
|
-
import { token } from '@atlaskit/tokens';
|
|
82
|
-
// We are unlikely to ever do this but I couldn't think of a better example
|
|
83
|
-
import { token as tokenNext } from '@atlaskit/tokens-next';
|
|
84
|
-
|
|
85
|
-
const styles = css({
|
|
86
|
-
height: token('test'),
|
|
87
|
-
width: tokenNext('test')
|
|
88
|
-
});
|
|
89
|
-
`,
|
|
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
|
-
import { css } from '@compiled/react';
|
|
103
|
-
import { token } from '@atlaskit/tokens';
|
|
104
|
-
|
|
105
|
-
const height = token('test');
|
|
106
|
-
|
|
107
|
-
const styles = css({
|
|
108
|
-
height
|
|
109
|
-
});
|
|
110
|
-
`,
|
|
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
|
-
import { css, keyframes } from '@compiled/react';
|
|
121
|
-
|
|
122
|
-
const fadeIn = keyframes({
|
|
123
|
-
'0%': {
|
|
124
|
-
opacity: 0
|
|
125
|
-
},
|
|
126
|
-
'100%': {
|
|
127
|
-
opacity: 1
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
const styles = css({
|
|
132
|
-
animation: \`\${fadeIn} 1s\`
|
|
133
|
-
});
|
|
134
|
-
`,
|
|
135
|
-
options: [
|
|
136
|
-
{
|
|
137
|
-
allowedFunctionCalls: [['@compiled/react', 'keyframes']],
|
|
138
|
-
},
|
|
139
|
-
],
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
name: 'layers from @atlaskit/theme/constants',
|
|
143
|
-
code: `
|
|
144
|
-
import { css } from '@compiled/react';
|
|
145
|
-
import { layers } from '@atlaskit/theme/constants';
|
|
146
|
-
|
|
147
|
-
const layerStyles = css({
|
|
148
|
-
zIndex: layers.modal(),
|
|
149
|
-
});
|
|
150
|
-
`,
|
|
151
|
-
},
|
|
152
|
-
],
|
|
153
|
-
invalid: [
|
|
154
|
-
{
|
|
155
|
-
name: 'function call as value',
|
|
156
|
-
code: `
|
|
157
|
-
import { css } from '@compiled/react';
|
|
158
|
-
|
|
159
|
-
function myFunction() {
|
|
160
|
-
return '5px';
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const styles = css({
|
|
164
|
-
height: myFunction(),
|
|
165
|
-
});
|
|
166
|
-
`,
|
|
167
|
-
errors: [{ messageId: 'no-function-calls' }],
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
name: 'function call in template literal in value',
|
|
171
|
-
code: `
|
|
172
|
-
import { css } from '@compiled/react';
|
|
173
|
-
|
|
174
|
-
function myFunction() {
|
|
175
|
-
return 5;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const styles = css({
|
|
179
|
-
height: \`\${myFunction()}px\`,
|
|
180
|
-
});
|
|
181
|
-
`,
|
|
182
|
-
errors: [{ messageId: 'no-function-calls' }],
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
name: 'function call in variable as value',
|
|
186
|
-
code: `
|
|
187
|
-
import { css } from '@compiled/react';
|
|
188
|
-
|
|
189
|
-
function runFunction() { return '5px'; }
|
|
190
|
-
const myFunction = runFunction();
|
|
191
|
-
|
|
192
|
-
const styles = css({
|
|
193
|
-
height: myFunction,
|
|
194
|
-
});
|
|
195
|
-
`,
|
|
196
|
-
errors: [{ messageId: 'no-function-calls' }],
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
name: 'immediately-invoked function expression (IIFE) as value',
|
|
200
|
-
code: `
|
|
201
|
-
import { css } from '@compiled/react';
|
|
202
|
-
|
|
203
|
-
const styles = css({
|
|
204
|
-
height: (() => 'red')(),
|
|
205
|
-
});
|
|
206
|
-
`,
|
|
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
|
-
import { css } from '@compiled/react';
|
|
213
|
-
import { token } from 'wrong-library';
|
|
214
|
-
|
|
215
|
-
const styles = css({
|
|
216
|
-
height: token('test'),
|
|
217
|
-
});
|
|
218
|
-
`,
|
|
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
|
-
import { css } from '@compiled/react';
|
|
230
|
-
|
|
231
|
-
const styles = css({
|
|
232
|
-
height: someFunction\`color: blue\`,
|
|
233
|
-
});
|
|
234
|
-
`,
|
|
235
|
-
errors: [{ messageId: 'no-function-calls' }],
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
name: 'tagged template expression in variable',
|
|
239
|
-
code: `
|
|
240
|
-
import { css } from '@compiled/react';
|
|
241
|
-
|
|
242
|
-
const height = someFunction\`color: blue\`
|
|
243
|
-
|
|
244
|
-
const styles = css({
|
|
245
|
-
height,
|
|
246
|
-
});
|
|
247
|
-
`,
|
|
248
|
-
errors: [{ messageId: 'no-function-calls' }],
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
name: 'tagged template expression even if it is an allowed function',
|
|
252
|
-
code: `
|
|
253
|
-
import { css } from '@compiled/react';
|
|
254
|
-
import { someFunction } from 'my-package';
|
|
255
|
-
|
|
256
|
-
const height = someFunction\`color: blue\`
|
|
257
|
-
|
|
258
|
-
const styles = css({
|
|
259
|
-
height,
|
|
260
|
-
});
|
|
261
|
-
`,
|
|
262
|
-
errors: [{ messageId: 'no-function-calls' }],
|
|
263
|
-
options: [{ allowedFunctionCalls: [['my-package', 'someFunction']] }],
|
|
264
|
-
},
|
|
265
|
-
],
|
|
266
|
-
},
|
|
267
|
-
);
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { typescriptEslintTester } from '../../__tests__/utils/_tester';
|
|
2
|
-
import rule from '../index';
|
|
3
|
-
|
|
4
|
-
typescriptEslintTester.run(
|
|
5
|
-
'no-unsafe-values',
|
|
6
|
-
// @ts-expect-error
|
|
7
|
-
rule,
|
|
8
|
-
{
|
|
9
|
-
valid: [],
|
|
10
|
-
invalid: [
|
|
11
|
-
{
|
|
12
|
-
name: 'passing an object through a variable',
|
|
13
|
-
code: `
|
|
14
|
-
import { css } from '@compiled/react';
|
|
15
|
-
|
|
16
|
-
const myStyles = {
|
|
17
|
-
height: '8px'
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const styles = css(myStyles);
|
|
21
|
-
`,
|
|
22
|
-
errors: [{ messageId: 'no-identifier-arguments' }],
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
name: 'passing the result of `css` through a variable',
|
|
26
|
-
code: `
|
|
27
|
-
import { css } from '@compiled/react';
|
|
28
|
-
|
|
29
|
-
const myStyles = css({
|
|
30
|
-
height: '8px'
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const styles = css(myStyles);
|
|
34
|
-
`,
|
|
35
|
-
errors: [{ messageId: 'no-identifier-arguments' }],
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
name: 'passing the result of `css` through a variable to `styled`',
|
|
39
|
-
code: `
|
|
40
|
-
import { styled } from '@compiled/react';
|
|
41
|
-
|
|
42
|
-
const myStyles = css({
|
|
43
|
-
height: '8px'
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const Component = styled.div(myStyles)
|
|
47
|
-
`,
|
|
48
|
-
errors: [{ messageId: 'no-identifier-arguments' }],
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
},
|
|
52
|
-
);
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { typescriptEslintTester } from '../../__tests__/utils/_tester';
|
|
2
|
-
import rule from '../index';
|
|
3
|
-
|
|
4
|
-
typescriptEslintTester.run(
|
|
5
|
-
'no-unsafe-values',
|
|
6
|
-
// @ts-expect-error
|
|
7
|
-
rule,
|
|
8
|
-
{
|
|
9
|
-
valid: [],
|
|
10
|
-
invalid: [
|
|
11
|
-
{
|
|
12
|
-
name: 'object indexing as value',
|
|
13
|
-
code: `
|
|
14
|
-
import { css } from '@compiled/react';
|
|
15
|
-
|
|
16
|
-
const myVariable = {
|
|
17
|
-
customHeight: '5px',
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const styles = css({
|
|
21
|
-
height: myVariable.customHeight,
|
|
22
|
-
});
|
|
23
|
-
`,
|
|
24
|
-
errors: [{ messageId: 'no-object-access' }],
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
name: 'object indexing as value (variant)',
|
|
28
|
-
code: `
|
|
29
|
-
import { css } from '@compiled/react';
|
|
30
|
-
|
|
31
|
-
const myVariable = {
|
|
32
|
-
customHeight: '5px',
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const styles = css({
|
|
36
|
-
height: myVariable['customHeight'],
|
|
37
|
-
});
|
|
38
|
-
`,
|
|
39
|
-
errors: [{ messageId: 'no-object-access' }],
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: 'object indexing as value (indexing through a variable)',
|
|
43
|
-
code: `
|
|
44
|
-
import { css } from '@compiled/react';
|
|
45
|
-
|
|
46
|
-
const myVariable = {
|
|
47
|
-
customHeight: '5px',
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const otherVariable = 'customHeight';
|
|
51
|
-
|
|
52
|
-
const styles = css({
|
|
53
|
-
height: myVariable[otherVariable],
|
|
54
|
-
});
|
|
55
|
-
`,
|
|
56
|
-
errors: [{ messageId: 'no-object-access' }],
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
name: 'object indexing as value (indexing through a variable defined as a function)',
|
|
60
|
-
code: `
|
|
61
|
-
import { css } from '@compiled/react';
|
|
62
|
-
|
|
63
|
-
const myVariable = {
|
|
64
|
-
customHeight: '5px',
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const otherVariable = () => 'customHeight';
|
|
68
|
-
|
|
69
|
-
const styles = css({
|
|
70
|
-
height: myVariable[otherVariable],
|
|
71
|
-
});
|
|
72
|
-
`,
|
|
73
|
-
errors: [{ messageId: 'no-object-access' }],
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
name: 'object indexing as value (indexing through a function directly)',
|
|
77
|
-
code: `
|
|
78
|
-
import { css } from '@compiled/react';
|
|
79
|
-
|
|
80
|
-
const myVariable = {
|
|
81
|
-
customHeight: '5px',
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
function myFunction() {
|
|
85
|
-
return 'customHeight';
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const styles = css({
|
|
89
|
-
height: myVariable[myFunction()],
|
|
90
|
-
});
|
|
91
|
-
`,
|
|
92
|
-
errors: [{ messageId: 'no-object-access' }],
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: 'accessing prop value',
|
|
96
|
-
code: `
|
|
97
|
-
import { styled } from '@compiled/react';
|
|
98
|
-
const styles = styled.div(
|
|
99
|
-
(props) => ({ color: props.height }),
|
|
100
|
-
);
|
|
101
|
-
`,
|
|
102
|
-
errors: [{ messageId: 'no-object-access' }],
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
},
|
|
106
|
-
);
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { typescriptEslintTester } from '../../__tests__/utils/_tester';
|
|
2
|
-
import rule from '../index';
|
|
3
|
-
|
|
4
|
-
typescriptEslintTester.run(
|
|
5
|
-
'no-unsafe-values',
|
|
6
|
-
// @ts-expect-error
|
|
7
|
-
rule,
|
|
8
|
-
{
|
|
9
|
-
valid: [],
|
|
10
|
-
invalid: [
|
|
11
|
-
{
|
|
12
|
-
name: 'object mapping',
|
|
13
|
-
code: `
|
|
14
|
-
import { css } from '@compiled/react';
|
|
15
|
-
|
|
16
|
-
const buttonStyles = {
|
|
17
|
-
color: 'blue',
|
|
18
|
-
};
|
|
19
|
-
const styles = css({
|
|
20
|
-
button: buttonStyles,
|
|
21
|
-
})
|
|
22
|
-
`,
|
|
23
|
-
errors: [{ messageId: 'no-object-references' }],
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: 'dynamic value in object mapping',
|
|
27
|
-
code: `
|
|
28
|
-
import { css } from '@compiled/react';
|
|
29
|
-
|
|
30
|
-
function myFunction() {
|
|
31
|
-
return 'blue';
|
|
32
|
-
}
|
|
33
|
-
const buttonStyles = {
|
|
34
|
-
color: myFunction(),
|
|
35
|
-
};
|
|
36
|
-
const styles = css({
|
|
37
|
-
button: buttonStyles,
|
|
38
|
-
})
|
|
39
|
-
`,
|
|
40
|
-
errors: [{ messageId: 'no-object-references' }],
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
},
|
|
44
|
-
);
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { typescriptEslintTester } from '../../__tests__/utils/_tester';
|
|
2
|
-
import rule from '../index';
|
|
3
|
-
|
|
4
|
-
typescriptEslintTester.run(
|
|
5
|
-
'no-unsafe-values',
|
|
6
|
-
// @ts-expect-error
|
|
7
|
-
rule,
|
|
8
|
-
{
|
|
9
|
-
valid: [],
|
|
10
|
-
invalid: [
|
|
11
|
-
{
|
|
12
|
-
name: 'object spread',
|
|
13
|
-
code: `
|
|
14
|
-
import { css } from '@compiled/react';
|
|
15
|
-
|
|
16
|
-
const buttonStyles = {
|
|
17
|
-
color: 'blue',
|
|
18
|
-
};
|
|
19
|
-
const styles = css({
|
|
20
|
-
...buttonStyles,
|
|
21
|
-
});
|
|
22
|
-
`,
|
|
23
|
-
errors: [{ messageId: 'no-spread-elements' }],
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: 'nested object spread',
|
|
27
|
-
code: `
|
|
28
|
-
import { css } from '@compiled/react';
|
|
29
|
-
|
|
30
|
-
const buttonStyles = {
|
|
31
|
-
color: 'blue',
|
|
32
|
-
};
|
|
33
|
-
const styles = css({
|
|
34
|
-
button: {
|
|
35
|
-
p: {
|
|
36
|
-
img: {
|
|
37
|
-
color: 'pink',
|
|
38
|
-
...buttonStyles,
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
`,
|
|
44
|
-
errors: [{ messageId: 'no-spread-elements' }],
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
},
|
|
48
|
-
);
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { typescriptEslintTester } from '../../__tests__/utils/_tester';
|
|
2
|
-
import rule from '../index';
|
|
3
|
-
|
|
4
|
-
typescriptEslintTester.run(
|
|
5
|
-
'no-unsafe-values',
|
|
6
|
-
// @ts-expect-error
|
|
7
|
-
rule,
|
|
8
|
-
{
|
|
9
|
-
valid: [
|
|
10
|
-
{
|
|
11
|
-
name: 'literal values',
|
|
12
|
-
code: `
|
|
13
|
-
import { css } from '@compiled/react';
|
|
14
|
-
|
|
15
|
-
const styles = css({
|
|
16
|
-
height: '5px',
|
|
17
|
-
opacity: 1
|
|
18
|
-
});
|
|
19
|
-
`,
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
name: 'variables referencing literal values',
|
|
23
|
-
code: `
|
|
24
|
-
import { css } from '@compiled/react';
|
|
25
|
-
|
|
26
|
-
const height = '5px';
|
|
27
|
-
const opacity = 1;
|
|
28
|
-
const styles = css({
|
|
29
|
-
height,
|
|
30
|
-
opacity
|
|
31
|
-
});
|
|
32
|
-
`,
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: 'template strings interpolating safe values',
|
|
36
|
-
code: `
|
|
37
|
-
import { css } from '@compiled/react';
|
|
38
|
-
|
|
39
|
-
const height = 5;
|
|
40
|
-
const paddingBlock = 10;
|
|
41
|
-
const paddingInline = 10;
|
|
42
|
-
|
|
43
|
-
const styles = css({
|
|
44
|
-
height: \`\${height}px\`,
|
|
45
|
-
padding: \`\${paddingBlock}px \${paddingInline}px\`
|
|
46
|
-
});
|
|
47
|
-
`,
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: 'base component',
|
|
51
|
-
code: `
|
|
52
|
-
import { styled } from '@compiled/react';
|
|
53
|
-
import { BaseComponent } from './base-component';
|
|
54
|
-
|
|
55
|
-
styled(BaseComponent)({});
|
|
56
|
-
`,
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
name: 'binary operations are allowed',
|
|
60
|
-
code: `
|
|
61
|
-
import { css } from '@compiled/react';
|
|
62
|
-
|
|
63
|
-
const ITEM_HEIGHT = 40;
|
|
64
|
-
|
|
65
|
-
const styles = css({
|
|
66
|
-
height: ITEM_HEIGHT,
|
|
67
|
-
width: ITEM_HEIGHT * 2,
|
|
68
|
-
marginBottom: ITEM_HEIGHT + 123,
|
|
69
|
-
});
|
|
70
|
-
`,
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
invalid: [],
|
|
74
|
-
},
|
|
75
|
-
);
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { typescriptEslintTester } from '../../__tests__/utils/_tester';
|
|
2
|
-
import rule from '../index';
|
|
3
|
-
|
|
4
|
-
typescriptEslintTester.run(
|
|
5
|
-
'no-unsafe-values',
|
|
6
|
-
// @ts-expect-error
|
|
7
|
-
rule,
|
|
8
|
-
{
|
|
9
|
-
valid: [
|
|
10
|
-
{
|
|
11
|
-
name: 'identifier resolves to string literal',
|
|
12
|
-
code: `
|
|
13
|
-
import { css } from '@compiled/react';
|
|
14
|
-
|
|
15
|
-
const margin = '5px';
|
|
16
|
-
const styles = css({
|
|
17
|
-
margin
|
|
18
|
-
})
|
|
19
|
-
`,
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
name: 'identifier resolves to a template string with allowed values as interpolations',
|
|
23
|
-
code: `
|
|
24
|
-
import styled from '@emotion/styled';
|
|
25
|
-
|
|
26
|
-
import { N30A } from '@atlaskit/theme/colors';
|
|
27
|
-
import { token } from '@atlaskit/tokens';
|
|
28
|
-
|
|
29
|
-
const borderStyle: string = \`2px solid \${token('color.border', N30A)}\`;
|
|
30
|
-
|
|
31
|
-
export const HorizontalDivider = styled.hr({
|
|
32
|
-
borderBottom: borderStyle,
|
|
33
|
-
});
|
|
34
|
-
`,
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
invalid: [
|
|
38
|
-
{
|
|
39
|
-
name: 'undefined is blocked',
|
|
40
|
-
code: `
|
|
41
|
-
import { css } from '@compiled/react';
|
|
42
|
-
|
|
43
|
-
const styles = css({
|
|
44
|
-
margin: undefined
|
|
45
|
-
})
|
|
46
|
-
`,
|
|
47
|
-
errors: [{ messageId: 'no-variables' }],
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: 'undefined is still blocked even if it has been shadowed',
|
|
51
|
-
code: `
|
|
52
|
-
import { css } from '@compiled/react';
|
|
53
|
-
import { someBlockedValue as undefined } from 'my-package';
|
|
54
|
-
|
|
55
|
-
const styles = css({
|
|
56
|
-
margin: undefined
|
|
57
|
-
})
|
|
58
|
-
`,
|
|
59
|
-
errors: [{ messageId: 'no-variables' }],
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
name: 'anon function in variable as value',
|
|
63
|
-
code: `
|
|
64
|
-
import { css } from '@compiled/react';
|
|
65
|
-
|
|
66
|
-
const myFunction = function() {
|
|
67
|
-
return '5px';
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const styles = css({
|
|
71
|
-
height: myFunction,
|
|
72
|
-
});
|
|
73
|
-
`,
|
|
74
|
-
errors: [{ messageId: 'no-variables' }],
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
name: 'arrow function in variable as value',
|
|
78
|
-
code: `
|
|
79
|
-
import { css } from '@compiled/react';
|
|
80
|
-
|
|
81
|
-
const myFunction = () => '5px';
|
|
82
|
-
|
|
83
|
-
const styles = css({
|
|
84
|
-
height: myFunction,
|
|
85
|
-
});
|
|
86
|
-
`,
|
|
87
|
-
errors: [{ messageId: 'no-variables' }],
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
name: 'function in variable as value',
|
|
91
|
-
code: `
|
|
92
|
-
import { css } from '@compiled/react';
|
|
93
|
-
|
|
94
|
-
function myFunction() {
|
|
95
|
-
return '5px';
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const styles = css({
|
|
99
|
-
height: myFunction,
|
|
100
|
-
});
|
|
101
|
-
`,
|
|
102
|
-
errors: [{ messageId: 'no-variables' }],
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
name: 'variable in array argument',
|
|
106
|
-
code: `
|
|
107
|
-
import { css } from '@compiled/react';
|
|
108
|
-
|
|
109
|
-
function myFunction() {
|
|
110
|
-
return '5px';
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const styles = css([
|
|
114
|
-
{ height: myFunction },
|
|
115
|
-
]);
|
|
116
|
-
`,
|
|
117
|
-
errors: [{ messageId: 'no-variables' }],
|
|
118
|
-
},
|
|
119
|
-
],
|
|
120
|
-
},
|
|
121
|
-
);
|