@atlaskit/eslint-plugin-ui-styling-standard 0.17.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.
Files changed (152) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/presets/all.codegen.js +3 -2
  3. package/dist/cjs/presets/recommended.codegen.js +3 -2
  4. package/dist/cjs/rules/external-rules.js +3 -1
  5. package/dist/es2019/presets/all.codegen.js +3 -2
  6. package/dist/es2019/presets/recommended.codegen.js +3 -2
  7. package/dist/es2019/rules/external-rules.js +3 -1
  8. package/dist/esm/presets/all.codegen.js +3 -2
  9. package/dist/esm/presets/recommended.codegen.js +3 -2
  10. package/dist/esm/rules/external-rules.js +3 -1
  11. package/dist/types/index.codegen.d.ts +2 -0
  12. package/dist/types/presets/all.codegen.d.ts +2 -1
  13. package/dist/types/presets/recommended.codegen.d.ts +2 -1
  14. package/dist/types-ts4.5/index.codegen.d.ts +2 -0
  15. package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
  16. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +2 -1
  17. package/package.json +2 -2
  18. package/afm-cc/tsconfig.json +0 -28
  19. package/afm-jira/tsconfig.json +0 -28
  20. package/build/tsconfig.json +0 -18
  21. package/constellation/atlaskit-theme/usage.mdx +0 -132
  22. package/constellation/consistent-css-prop-usage/usage.mdx +0 -7
  23. package/constellation/convert-props-syntax/usage.mdx +0 -130
  24. package/constellation/enforce-style-prop/usage.mdx +0 -47
  25. package/constellation/index/migration-guide.mdx +0 -309
  26. package/constellation/index/overview.mdx +0 -250
  27. package/constellation/index/props.mdx +0 -30
  28. package/constellation/local-cx-xcss/usage.mdx +0 -53
  29. package/constellation/no-array-arguments/usage.mdx +0 -49
  30. package/constellation/no-classname-prop/usage.mdx +0 -49
  31. package/constellation/no-container-queries/usage.mdx +0 -101
  32. package/constellation/no-css-tagged-template-expression/usage.mdx +0 -8
  33. package/constellation/no-dynamic-styles/usage.mdx +0 -130
  34. package/constellation/no-empty-styled-expression/usage.mdx +0 -8
  35. package/constellation/no-exported-css/usage.mdx +0 -8
  36. package/constellation/no-exported-keyframes/usage.mdx +0 -8
  37. package/constellation/no-exported-styles/usage.mdx +0 -87
  38. package/constellation/no-global-styles/usage.mdx +0 -60
  39. package/constellation/no-important-styles/usage.mdx +0 -33
  40. package/constellation/no-imported-style-values/usage.mdx +0 -157
  41. package/constellation/no-invalid-css-map/usage.mdx +0 -8
  42. package/constellation/no-js-xcss/usage.mdx +0 -7
  43. package/constellation/no-keyframes-tagged-template-expression/usage.mdx +0 -8
  44. package/constellation/no-nested-selectors/usage.mdx +0 -95
  45. package/constellation/no-styled/usage.mdx +0 -92
  46. package/constellation/no-styled-tagged-template-expression/usage.mdx +0 -8
  47. package/constellation/no-suppress-xcss/usage.mdx +0 -28
  48. package/constellation/no-unsafe-selectors/usage.mdx +0 -370
  49. package/constellation/no-unsafe-values/usage.mdx +0 -318
  50. package/constellation/use-compiled/usage.mdx +0 -54
  51. package/index.js +0 -24
  52. package/scripts/codegen.tsx +0 -373
  53. package/src/index.codegen.tsx +0 -14
  54. package/src/index.tsx +0 -1
  55. package/src/presets/all.codegen.tsx +0 -79
  56. package/src/presets/recommended.codegen.tsx +0 -79
  57. package/src/rules/TEMPLATE.md +0 -29
  58. package/src/rules/__tests__/utils/_tester.tsx +0 -40
  59. package/src/rules/atlaskit-theme/README.md +0 -130
  60. package/src/rules/atlaskit-theme/__tests__/test.ts +0 -133
  61. package/src/rules/atlaskit-theme/index.ts +0 -134
  62. package/src/rules/convert-props-syntax/README.md +0 -128
  63. package/src/rules/convert-props-syntax/__tests__/invalid.test.tsx +0 -76
  64. package/src/rules/convert-props-syntax/__tests__/rule.test.tsx +0 -584
  65. package/src/rules/convert-props-syntax/__tests__/type-annotations.test.tsx +0 -140
  66. package/src/rules/convert-props-syntax/__tests__/unusual-properties.test.tsx +0 -69
  67. package/src/rules/convert-props-syntax/index.tsx +0 -414
  68. package/src/rules/enforce-style-prop/README.md +0 -45
  69. package/src/rules/enforce-style-prop/__tests__/rule.test.tsx +0 -243
  70. package/src/rules/enforce-style-prop/index.tsx +0 -172
  71. package/src/rules/external-rules.tsx +0 -175
  72. package/src/rules/index.codegen.tsx +0 -42
  73. package/src/rules/local-cx-xcss/README.md +0 -51
  74. package/src/rules/local-cx-xcss/__tests__/rule.test.tsx +0 -102
  75. package/src/rules/local-cx-xcss/index.tsx +0 -62
  76. package/src/rules/no-array-arguments/README.md +0 -47
  77. package/src/rules/no-array-arguments/__tests__/rule.test.tsx +0 -107
  78. package/src/rules/no-array-arguments/index.tsx +0 -86
  79. package/src/rules/no-classname-prop/README.md +0 -47
  80. package/src/rules/no-classname-prop/__tests__/rule.test.tsx +0 -39
  81. package/src/rules/no-classname-prop/index.tsx +0 -34
  82. package/src/rules/no-container-queries/README.md +0 -99
  83. package/src/rules/no-container-queries/__tests__/rule.test.tsx +0 -139
  84. package/src/rules/no-container-queries/index.tsx +0 -94
  85. package/src/rules/no-dynamic-styles/README.md +0 -128
  86. package/src/rules/no-dynamic-styles/__tests__/rule.test.tsx +0 -135
  87. package/src/rules/no-dynamic-styles/index.tsx +0 -60
  88. package/src/rules/no-exported-styles/README.md +0 -85
  89. package/src/rules/no-exported-styles/__tests__/rule.test.tsx +0 -216
  90. package/src/rules/no-exported-styles/index.tsx +0 -52
  91. package/src/rules/no-global-styles/README.md +0 -58
  92. package/src/rules/no-global-styles/__tests__/no-css-modules.test.tsx +0 -33
  93. package/src/rules/no-global-styles/__tests__/no-global-styles.test.tsx +0 -46
  94. package/src/rules/no-global-styles/index.tsx +0 -82
  95. package/src/rules/no-important-styles/README.md +0 -31
  96. package/src/rules/no-important-styles/__tests__/rule.test.tsx +0 -165
  97. package/src/rules/no-important-styles/index.tsx +0 -70
  98. package/src/rules/no-imported-style-values/README.md +0 -155
  99. package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +0 -491
  100. package/src/rules/no-imported-style-values/index.tsx +0 -188
  101. package/src/rules/no-nested-selectors/README.md +0 -93
  102. package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +0 -335
  103. package/src/rules/no-nested-selectors/index.tsx +0 -99
  104. package/src/rules/no-styled/README.md +0 -90
  105. package/src/rules/no-styled/__tests__/rule.test.tsx +0 -73
  106. package/src/rules/no-styled/index.tsx +0 -45
  107. package/src/rules/no-unsafe-selectors/README.md +0 -368
  108. package/src/rules/no-unsafe-selectors/__tests__/no-ambiguous-pseudos.test.tsx +0 -368
  109. package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +0 -57
  110. package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +0 -73
  111. package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +0 -40
  112. package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +0 -101
  113. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +0 -131
  114. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +0 -132
  115. package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +0 -25
  116. package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +0 -35
  117. package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +0 -257
  118. package/src/rules/no-unsafe-selectors/constants.tsx +0 -91
  119. package/src/rules/no-unsafe-selectors/index.tsx +0 -198
  120. package/src/rules/no-unsafe-selectors/lint-selector.tsx +0 -155
  121. package/src/rules/no-unsafe-selectors/source-position-utils.tsx +0 -55
  122. package/src/rules/no-unsafe-selectors/walk-css-map.tsx +0 -226
  123. package/src/rules/no-unsafe-values/README.md +0 -316
  124. package/src/rules/no-unsafe-values/__tests__/no-array-values.test.tsx +0 -27
  125. package/src/rules/no-unsafe-values/__tests__/no-conditional-values.test.tsx +0 -37
  126. package/src/rules/no-unsafe-values/__tests__/no-dynamic-keys.test.tsx +0 -229
  127. package/src/rules/no-unsafe-values/__tests__/no-function-calls.test.tsx +0 -267
  128. package/src/rules/no-unsafe-values/__tests__/no-identifier-arguments.test.tsx +0 -52
  129. package/src/rules/no-unsafe-values/__tests__/no-object-access.test.tsx +0 -106
  130. package/src/rules/no-unsafe-values/__tests__/no-object-references.test.tsx +0 -44
  131. package/src/rules/no-unsafe-values/__tests__/no-spread-elements.test.tsx +0 -48
  132. package/src/rules/no-unsafe-values/__tests__/no-unsafe-values.test.tsx +0 -75
  133. package/src/rules/no-unsafe-values/__tests__/no-variables.test.tsx +0 -121
  134. package/src/rules/no-unsafe-values/index.tsx +0 -94
  135. package/src/rules/no-unsafe-values/messages.tsx +0 -86
  136. package/src/rules/no-unsafe-values/utils.tsx +0 -387
  137. package/src/rules/use-compiled/README.md +0 -52
  138. package/src/rules/use-compiled/__tests__/can-auto-fix.test.tsx +0 -73
  139. package/src/rules/use-compiled/__tests__/css.test.tsx +0 -126
  140. package/src/rules/use-compiled/__tests__/imports.test.tsx +0 -158
  141. package/src/rules/use-compiled/__tests__/keyframes.test.tsx +0 -140
  142. package/src/rules/use-compiled/__tests__/pragma.test.tsx +0 -108
  143. package/src/rules/use-compiled/__tests__/styled.test.tsx +0 -114
  144. package/src/rules/use-compiled/__tests__/use-compiled.test.tsx +0 -15
  145. package/src/rules/use-compiled/index.tsx +0 -252
  146. package/src/rules/use-compiled/is-safe.tsx +0 -159
  147. package/src/rules/use-compiled/utils.tsx +0 -33
  148. package/src/rules/utils/create-rule-with-typed-config.tsx +0 -86
  149. package/src/rules/utils/create-rule.tsx +0 -13
  150. package/tsconfig.app.json +0 -47
  151. package/tsconfig.dev.json +0 -45
  152. package/tsconfig.json +0 -25
@@ -1,316 +0,0 @@
1
- Blocks styles that are difficult or impossible to statically analyze.
2
-
3
- ## Examples
4
-
5
- ### Function calls
6
-
7
- #### Incorrect
8
-
9
- Function calls are blocked as arguments or as values, unless they are specified in
10
- `allowedFunctionCalls` (or in the default list).
11
-
12
- ```tsx
13
- import { css } from '@compiled/react';
14
-
15
- function getStyles() {
16
- return { width: 100 };
17
- }
18
-
19
- const styles = css(getStyles());
20
- ```
21
-
22
- ```tsx
23
- import { css } from '@compiled/react';
24
-
25
- function getWidth() {
26
- return 100;
27
- }
28
-
29
- const styles = css({
30
- width: getWidth(),
31
- });
32
- ```
33
-
34
- #### Correct
35
-
36
- Use inline literals for static values.
37
-
38
- ```tsx
39
- import { css } from '@compiled/react';
40
-
41
- const styles = css({ width: 100 });
42
- ```
43
-
44
- Use the `style` prop for dynamic values.
45
-
46
- ```tsx
47
- const Component = ({ width }) => <div style={{ width }} />;
48
- ```
49
-
50
- Some functions such as `tokens()` are allowed.
51
-
52
- ```tsx
53
- import { css } from '@compiled/react';
54
- import { token } from '@atlaskit/tokens';
55
-
56
- const styles = css({ padding: token('space.100') });
57
- ```
58
-
59
- ### Dynamic keys
60
-
61
- #### Incorrect
62
-
63
- Dynamic keys are blocked, unless they are specified in `allowedDynamicKeys` (or in the default
64
- list).
65
-
66
- ```tsx
67
- import { css } from '@compiled/react';
68
-
69
- const HOVER_SELECTOR = '&:hover';
70
- const MARGIN = 'margin';
71
-
72
- const styles = css({
73
- [HOVER_SELECTOR]: {
74
- [MARGIN]: 0,
75
- },
76
- [`${HOVER_SELECTOR} > p`]: {
77
- width: 100,
78
- },
79
- });
80
- ```
81
-
82
- #### Correct
83
-
84
- Use literal values for pseudo-states and property names.
85
-
86
- Don't use nested selectors, apply styles directly instead.
87
-
88
- ```tsx
89
- import { css } from '@compiled/react';
90
-
91
- const styles = css({
92
- '&:hover': {
93
- margin: 0,
94
- },
95
- });
96
-
97
- const paragraphStyles = css({
98
- width: 100,
99
- });
100
- ```
101
-
102
- ### Variables
103
-
104
- #### Incorrect
105
-
106
- Variables are only allowed as values if they:
107
-
108
- - have a simple, static value
109
- - are defined in the same file
110
-
111
- ```tsx
112
- import { css } from '@compiled/react';
113
- import { HEIGHT } from '../shared';
114
-
115
- const styles = css({
116
- height: HEIGHT,
117
- });
118
- ```
119
-
120
- #### Correct
121
-
122
- Use inlined values.
123
-
124
- ```tsx
125
- import { css } from '@compiled/react';
126
-
127
- const styles = css({
128
- height: '32px',
129
- });
130
- ```
131
-
132
- Alternatively, define variables in the same file.
133
-
134
- ```tsx
135
- import { css } from '@compiled/react';
136
-
137
- const HEIGHT = '32px';
138
-
139
- const styles = css({
140
- height: HEIGHT,
141
- });
142
- ```
143
-
144
- ### Object access
145
-
146
- #### Incorrect
147
-
148
- Don't access object members in values.
149
-
150
- ```tsx
151
- import { css } from '@compiled/react';
152
- import { token } from '@atlaskit/tokens';
153
-
154
- const colors = {
155
- text: token('color.text'),
156
- };
157
-
158
- const styles = css({
159
- color: colors.text,
160
- });
161
- ```
162
-
163
- #### Correct
164
-
165
- Use inlined values.
166
-
167
- ```tsx
168
- import { css } from '@compiled/react';
169
- import { token } from '@atlaskit/tokens';
170
-
171
- const styles = css({
172
- color: token('color.text'),
173
- });
174
- ```
175
-
176
- ### Spread elements
177
-
178
- #### Incorrect
179
-
180
- Don't use the spread operator in styles.
181
-
182
- ```tsx
183
- import { css } from '@compiled/react';
184
- import { token } from '@atlaskit/tokens';
185
-
186
- const subtleTextStyles = {
187
- color: token('color.text.subtle'),
188
- };
189
-
190
- const styles = css({
191
- ...subtleTextStyles,
192
- margin: 0,
193
- });
194
- ```
195
-
196
- #### Correct
197
-
198
- Use the `css` prop to compose styles.
199
-
200
- ```tsx
201
- import { css } from '@compiled/react';
202
- import { token } from '@atlaskit/tokens';
203
-
204
- const subtleTextStyles = {
205
- color: token('color.text.subtle'),
206
- };
207
-
208
- const styles = css({
209
- margin: 0,
210
- });
211
-
212
- const Component = () => <div css={[subtleTextStyles, styles]} />;
213
- ```
214
-
215
- ### Array values
216
-
217
- #### Incorrect
218
-
219
- Don't use array values. This syntax is not supported by Compiled, or most other CSS-in-JS libraries.
220
-
221
- ```tsx
222
- import { css } from '@compiled/react';
223
- import { token } from '@atlaskit/tokens';
224
-
225
- const boldMixin = { fontWeight: token('font.weight.bold') };
226
-
227
- const styles = css({
228
- '&::before': [boldMixin, { color: token('color.text.danger') }],
229
- });
230
- ```
231
-
232
- #### Correct
233
-
234
- Use a single object with inlined styles.
235
-
236
- ```tsx
237
- import { css } from '@compiled/react';
238
- import { token } from '@atlaskit/tokens';
239
-
240
- const styles = css({
241
- '&::before': {
242
- fontWeight: token('font.weight.bold'),
243
- color: token('color.text.danger'),
244
- },
245
- });
246
- ```
247
-
248
- ## Options
249
-
250
- ### `allowedDynamicKeys: [string, string][]`
251
-
252
- Use this to allow specified imports as dynamic keys, in addition to the built-in allow-list.
253
-
254
- Each value should be a two-element array. The first item is the entrypoint, and the second item is a
255
- named export.
256
-
257
- Default imports are not supported.
258
-
259
- ```tsx
260
- // .eslintrc.js
261
-
262
- // ...
263
- rules: {
264
- '@atlaskit/eslint-plugin-ui-styling-standard/no-unsafe-values': [
265
- 'error',
266
- {
267
- allowedDynamicKeys: [
268
- ['@atlaskit/primitives/responsive', 'media'],
269
- ]
270
- },
271
- ],
272
- // ...
273
- },
274
- // ...
275
- ```
276
-
277
- ### `allowedFunctionCalls: [string, string][]`
278
-
279
- Use this to allow specific functions to be called, in addition to the built-in allow-list.
280
-
281
- Each value should be a two-element array. The first item is the entrypoint, and the second item is a
282
- named export.
283
-
284
- Default imports are not currently supported.
285
-
286
- ```tsx
287
- // .eslintrc.js
288
-
289
- // ...
290
- rules: {
291
- '@atlaskit/eslint-plugin-ui-styling-standard/no-unsafe-values': [
292
- 'error',
293
- {
294
- allowedFunctionCalls: [
295
- ['@atlaskit/tokens', 'token'],
296
- ]
297
- },
298
- ],
299
- // ...
300
- },
301
- // ...
302
- ```
303
-
304
- ### `importSources: string[]`
305
-
306
- By default, this rule will check styles using:
307
-
308
- - `@atlaskit/css`
309
- - `@atlaskit/primitives`
310
- - `@compiled/react`
311
- - `@emotion/react`
312
- - `@emotion/core`
313
- - `@emotion/styled`
314
- - `styled-components`
315
-
316
- Override this list with the `importSources` option, which accepts an array of package names.
@@ -1,27 +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 array of values',
13
- code: `
14
- import { css } from '@compiled/react';
15
-
16
- const styles = css({
17
- selector: [
18
- { height: 40 },
19
- { width: 40 }
20
- ]
21
- });
22
- `,
23
- errors: [{ messageId: 'no-array-values' }],
24
- },
25
- ],
26
- },
27
- );
@@ -1,37 +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: 'ternary value',
13
- code: `
14
- import { css } from '@compiled/react';
15
-
16
- const isVisible = false;
17
- const styles = css({
18
- opacity: isVisible ? 1 : 0
19
- });
20
- `,
21
- errors: [{ messageId: 'no-conditional-values' }],
22
- },
23
- {
24
- name: 'boolean expression values',
25
- code: `
26
- import { css } from '@compiled/react';
27
-
28
- const isVisible = false;
29
- const styles = css({
30
- opacity: isVisible && 1
31
- });
32
- `,
33
- errors: [{ messageId: 'no-conditional-values' }],
34
- },
35
- ],
36
- },
37
- );
@@ -1,229 +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: 'key is an identifier',
12
- code: `
13
- import { css } from '@compiled/react';
14
-
15
- const styles = css({
16
- color: 'blue',
17
- });
18
- `,
19
- },
20
- {
21
- name: 'key is a literal',
22
- code: `
23
- import { css } from '@compiled/react';
24
-
25
- const styles = css({
26
- 'color': 'blue',
27
- });
28
- `,
29
- },
30
- {
31
- name: 'key is an allow listed value',
32
- code: `
33
- import { css } from '@compiled/react';
34
- import { media } from 'my-package';
35
-
36
- const styles = css({
37
- [media.above.xxs]: { height: '2px' }
38
- });
39
- `,
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
- import { css } from '@compiled/react';
50
-
51
- const myVar = '--my-var';
52
- const styles = css({
53
- [myVar]: 'red'
54
- });
55
- `,
56
- },
57
- {
58
- name: 'key is on the default allow list',
59
- code: `
60
- import { css } from '@compiled/react';
61
- import { media } from '@atlaskit/primitives/responsive';
62
-
63
- const styles = css({
64
- [media.above.xxs]: { height: '2px' }
65
- });
66
- `,
67
- options: [
68
- {
69
- allowedDynamicKeys: [],
70
- },
71
- ],
72
- },
73
- ],
74
- invalid: [
75
- {
76
- name: 'key is a template literal',
77
- code: `
78
- import { css } from '@compiled/react';
79
-
80
- const something = 'selector';
81
- const styles = css({
82
- [\`\${something} > p\`]: {
83
- color: 'blue',
84
- },
85
- });
86
- `,
87
- errors: [{ messageId: 'no-dynamic-keys' }],
88
- },
89
- {
90
- name: 'nested key is a template literal',
91
- code: `
92
- import { css } from '@compiled/react';
93
-
94
- const something = 'selector';
95
- const styles = css({
96
- button: {
97
- p: {
98
- [\`\${something} > p\`]: {
99
- color: 'blue',
100
- },
101
- },
102
- },
103
- });
104
- `,
105
- errors: [{ messageId: 'no-dynamic-keys' }],
106
- },
107
- {
108
- name: 'key is an identifier for a string literal',
109
- code: `
110
- import { css } from '@compiled/react';
111
-
112
- const something = 'selector';
113
- const styles = css({
114
- [something]: {
115
- color: 'blue',
116
- },
117
- });
118
- `,
119
- errors: [{ messageId: 'no-dynamic-keys' }],
120
- },
121
- {
122
- name: 'nested key is an identifier for a string literal',
123
- code: `
124
- import { css } from '@compiled/react';
125
-
126
- const something = 'selector';
127
- const styles = css({
128
- button: {
129
- p: {
130
- [something]: {
131
- color: 'blue',
132
- },
133
- },
134
- },
135
- });
136
- `,
137
- errors: [{ messageId: 'no-dynamic-keys' }],
138
- },
139
- {
140
- name: 'key is a string literal inside square brackets',
141
- code: `
142
- import { css } from '@compiled/react';
143
-
144
- const styles = css({
145
- ['color']: 'blue',
146
- });
147
- `,
148
- errors: [{ messageId: 'no-dynamic-keys' }],
149
- },
150
- {
151
- name: 'key is a concatenation of string literals',
152
- code: `
153
- import { css } from '@compiled/react';
154
-
155
- const styles = css({
156
- ['col' + 'or']: 'blue',
157
- });
158
- `,
159
- errors: [{ messageId: 'no-dynamic-keys' }],
160
- },
161
- {
162
- name: 'nested key is a string literal inside square brackets',
163
- code: `
164
- import { css } from '@compiled/react';
165
-
166
- const styles = css({
167
- button: {
168
- p: {
169
- ['color']: 'blue',
170
- },
171
- },
172
- });
173
- `,
174
- errors: [{ messageId: 'no-dynamic-keys' }],
175
- },
176
- {
177
- name: 'key is an import from a non-allow-listed library',
178
- code: `
179
- import { css } from '@compiled/react';
180
- import { media } from 'my-package';
181
-
182
- const styles = css({
183
- [media.above.xxs]: { height: '2px' }
184
- });
185
- `,
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
- import { css } from '@compiled/react';
197
- import { mediaNext as media } from 'my-package';
198
-
199
- const styles = css({
200
- [media.above.xxs]: { height: '2px' }
201
- });
202
- `,
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
- import { css } from '@compiled/react';
214
- import { media } from 'my-package/primitives/responsive';
215
-
216
- const styles = css({
217
- [media.above.xxs]: { height: '2px' }
218
- });
219
- `,
220
- errors: [{ messageId: 'no-dynamic-keys' }],
221
- options: [
222
- {
223
- allowedDynamicKeys: [['my-package/primitives', 'media']],
224
- },
225
- ],
226
- },
227
- ],
228
- },
229
- );