@atlaskit/eslint-plugin-ui-styling-standard 0.15.1 → 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.
Files changed (99) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/constellation/index/migration-guide.mdx +309 -0
  3. package/constellation/index/overview.mdx +4 -0
  4. package/constellation/index/props.mdx +9 -5
  5. package/dist/cjs/rules/no-nested-selectors/index.js +68 -49
  6. package/dist/es2019/rules/no-nested-selectors/index.js +63 -45
  7. package/dist/esm/rules/no-nested-selectors/index.js +64 -49
  8. package/dist/types/rules/no-unsafe-selectors/constants.d.ts +1 -4
  9. package/index.js +9 -9
  10. package/package.json +3 -3
  11. package/scripts/codegen.tsx +223 -284
  12. package/src/rules/__tests__/utils/_tester.tsx +24 -24
  13. package/src/rules/atlaskit-theme/README.md +21 -19
  14. package/src/rules/atlaskit-theme/__tests__/test.ts +53 -53
  15. package/src/rules/atlaskit-theme/index.ts +107 -115
  16. package/src/rules/convert-props-syntax/README.md +32 -22
  17. package/src/rules/convert-props-syntax/__tests__/invalid.test.tsx +46 -46
  18. package/src/rules/convert-props-syntax/__tests__/rule.test.tsx +175 -175
  19. package/src/rules/convert-props-syntax/__tests__/type-annotations.test.tsx +52 -52
  20. package/src/rules/convert-props-syntax/__tests__/unusual-properties.test.tsx +33 -33
  21. package/src/rules/convert-props-syntax/index.tsx +356 -386
  22. package/src/rules/enforce-style-prop/README.md +21 -18
  23. package/src/rules/enforce-style-prop/__tests__/rule.test.tsx +90 -96
  24. package/src/rules/enforce-style-prop/index.tsx +144 -160
  25. package/src/rules/external-rules.tsx +163 -164
  26. package/src/rules/local-cx-xcss/README.md +10 -6
  27. package/src/rules/local-cx-xcss/__tests__/rule.test.tsx +26 -26
  28. package/src/rules/local-cx-xcss/index.tsx +46 -56
  29. package/src/rules/no-array-arguments/README.md +2 -1
  30. package/src/rules/no-array-arguments/__tests__/rule.test.tsx +37 -46
  31. package/src/rules/no-array-arguments/index.tsx +68 -69
  32. package/src/rules/no-classname-prop/README.md +7 -4
  33. package/src/rules/no-classname-prop/__tests__/rule.test.tsx +22 -22
  34. package/src/rules/no-classname-prop/index.tsx +25 -25
  35. package/src/rules/no-container-queries/README.md +11 -9
  36. package/src/rules/no-container-queries/__tests__/rule.test.tsx +47 -50
  37. package/src/rules/no-container-queries/index.tsx +75 -81
  38. package/src/rules/no-dynamic-styles/README.md +16 -19
  39. package/src/rules/no-dynamic-styles/__tests__/rule.test.tsx +58 -67
  40. package/src/rules/no-dynamic-styles/index.tsx +45 -48
  41. package/src/rules/no-exported-styles/README.md +17 -12
  42. package/src/rules/no-exported-styles/__tests__/rule.test.tsx +102 -111
  43. package/src/rules/no-exported-styles/index.tsx +36 -36
  44. package/src/rules/no-global-styles/README.md +15 -14
  45. package/src/rules/no-global-styles/__tests__/no-css-modules.test.tsx +28 -28
  46. package/src/rules/no-global-styles/__tests__/no-global-styles.test.tsx +37 -37
  47. package/src/rules/no-global-styles/index.tsx +59 -62
  48. package/src/rules/no-important-styles/README.md +5 -3
  49. package/src/rules/no-important-styles/__tests__/rule.test.tsx +66 -66
  50. package/src/rules/no-important-styles/index.tsx +49 -49
  51. package/src/rules/no-imported-style-values/README.md +23 -15
  52. package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +123 -123
  53. package/src/rules/no-imported-style-values/index.tsx +116 -120
  54. package/src/rules/no-nested-selectors/README.md +15 -13
  55. package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +186 -149
  56. package/src/rules/no-nested-selectors/index.tsx +92 -105
  57. package/src/rules/no-styled/README.md +14 -9
  58. package/src/rules/no-styled/__tests__/rule.test.tsx +31 -31
  59. package/src/rules/no-styled/index.tsx +34 -41
  60. package/src/rules/no-unsafe-selectors/README.md +103 -93
  61. package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +21 -24
  62. package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +44 -44
  63. package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +21 -21
  64. package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +57 -57
  65. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +58 -58
  66. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +85 -85
  67. package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +12 -12
  68. package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +23 -23
  69. package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +114 -114
  70. package/src/rules/no-unsafe-selectors/constants.tsx +69 -77
  71. package/src/rules/no-unsafe-selectors/source-position-utils.tsx +38 -38
  72. package/src/rules/no-unsafe-selectors/walk-css-map.tsx +178 -184
  73. package/src/rules/no-unsafe-values/README.md +34 -40
  74. package/src/rules/no-unsafe-values/__tests__/no-array-values.test.tsx +13 -13
  75. package/src/rules/no-unsafe-values/__tests__/no-conditional-values.test.tsx +18 -18
  76. package/src/rules/no-unsafe-values/__tests__/no-dynamic-keys.test.tsx +104 -104
  77. package/src/rules/no-unsafe-values/__tests__/no-function-calls.test.tsx +128 -128
  78. package/src/rules/no-unsafe-values/__tests__/no-identifier-arguments.test.tsx +23 -23
  79. package/src/rules/no-unsafe-values/__tests__/no-object-access.test.tsx +38 -38
  80. package/src/rules/no-unsafe-values/__tests__/no-object-references.test.tsx +18 -18
  81. package/src/rules/no-unsafe-values/__tests__/no-spread-elements.test.tsx +18 -18
  82. package/src/rules/no-unsafe-values/__tests__/no-unsafe-values.test.tsx +28 -28
  83. package/src/rules/no-unsafe-values/__tests__/no-variables.test.tsx +47 -47
  84. package/src/rules/no-unsafe-values/index.tsx +76 -78
  85. package/src/rules/no-unsafe-values/messages.tsx +12 -12
  86. package/src/rules/no-unsafe-values/utils.tsx +370 -382
  87. package/src/rules/use-compiled/README.md +11 -8
  88. package/src/rules/use-compiled/__tests__/can-auto-fix.test.tsx +32 -32
  89. package/src/rules/use-compiled/__tests__/css.test.tsx +53 -53
  90. package/src/rules/use-compiled/__tests__/imports.test.tsx +90 -95
  91. package/src/rules/use-compiled/__tests__/keyframes.test.tsx +47 -47
  92. package/src/rules/use-compiled/__tests__/pragma.test.tsx +64 -64
  93. package/src/rules/use-compiled/__tests__/styled.test.tsx +53 -53
  94. package/src/rules/use-compiled/__tests__/use-compiled.test.tsx +10 -10
  95. package/src/rules/use-compiled/index.tsx +203 -226
  96. package/src/rules/use-compiled/is-safe.tsx +113 -117
  97. package/src/rules/use-compiled/utils.tsx +14 -18
  98. package/src/rules/utils/create-rule-with-typed-config.tsx +62 -63
  99. package/src/rules/utils/create-rule.tsx +3 -6
@@ -1,4 +1,5 @@
1
- This rule prevents the usage of the nested selectors in style declarations. Avoid setting styles for any child elements or elements that require context from other elements.
1
+ This rule prevents the usage of the nested selectors in style declarations. Avoid setting styles for
2
+ any child elements or elements that require context from other elements.
2
3
 
3
4
  ## Examples
4
5
 
@@ -7,27 +8,27 @@ This rule prevents the usage of the nested selectors in style declarations. Avoi
7
8
  ```js
8
9
  import { css } from '@compiled/react';
9
10
  const styles = css({
10
- h2: {
11
- fontSize: '1.5rem',
12
- },
11
+ h2: {
12
+ fontSize: '1.5rem',
13
+ },
13
14
  });
14
15
  ```
15
16
 
16
17
  ```js
17
18
  import { styled } from '@compiled/react';
18
19
  const Component = styled.div({
19
- '*': {
20
- padding: 0,
21
- },
20
+ '*': {
21
+ padding: 0,
22
+ },
22
23
  });
23
24
  ```
24
25
 
25
26
  ```js
26
27
  import { styled } from '@compiled/react';
27
28
  const Component = styled.div({
28
- '.myclass': {
29
- padding: 0,
30
- },
29
+ '.myclass': {
30
+ padding: 0,
31
+ },
31
32
  });
32
33
  ```
33
34
 
@@ -36,8 +37,8 @@ const Component = styled.div({
36
37
  ```js
37
38
  import { css } from '@compiled/react';
38
39
  const styles = css({
39
- display: 'flex',
40
- flexDirection: 'column',
40
+ display: 'flex',
41
+ flexDirection: 'column',
41
42
  });
42
43
  ```
43
44
 
@@ -55,4 +56,5 @@ By default, this rule will check `css` usages from:
55
56
  - `@emotion/styled`
56
57
  - `styled-components`
57
58
 
58
- To change this list of libraries, you can define a custom set of `importSources`, which accepts an array of package names (strings).
59
+ To change this list of libraries, you can define a custom set of `importSources`, which accepts an
60
+ array of package names (strings).
@@ -2,34 +2,34 @@ import { typescriptEslintTester } from '../../__tests__/utils/_tester';
2
2
  import rule from '../index';
3
3
 
4
4
  typescriptEslintTester.run(
5
- 'no-nested-selectors',
6
- // @ts-expect-error
7
- rule,
8
- {
9
- valid: [
10
- {
11
- name: 'Basic valid test',
12
- code: `
5
+ 'no-nested-selectors',
6
+ // @ts-expect-error
7
+ rule,
8
+ {
9
+ valid: [
10
+ {
11
+ name: 'Basic valid test',
12
+ code: `
13
13
  import { css } from '@compiled/react';
14
14
  const styles = css({
15
15
  display: 'flex',
16
16
  flexDirection: 'column',
17
17
  });
18
18
  `,
19
- },
20
- {
21
- name: 'Basic valid test using emotion',
22
- code: `
19
+ },
20
+ {
21
+ name: 'Basic valid test using emotion',
22
+ code: `
23
23
  import styled from '@emotion/styled';
24
24
  const Container = styled.div({
25
25
  display: 'flex',
26
26
  flexDirection: 'column'
27
27
  })
28
28
  `,
29
- },
30
- {
31
- name: 'Custom import sources (subtractive)',
32
- code: `
29
+ },
30
+ {
31
+ name: 'Custom import sources (subtractive)',
32
+ code: `
33
33
  import { css } from '@compiled/react';
34
34
  const styles = css({
35
35
  h2: {
@@ -37,15 +37,15 @@ typescriptEslintTester.run(
37
37
  }
38
38
  });
39
39
  `,
40
- options: [
41
- {
42
- importSources: [],
43
- },
44
- ],
45
- },
46
- {
47
- name: 'Styled div with no selectors',
48
- code: `
40
+ options: [
41
+ {
42
+ importSources: [],
43
+ },
44
+ ],
45
+ },
46
+ {
47
+ name: 'Styled div with no selectors',
48
+ code: `
49
49
  import { styled } from '@compiled/react';
50
50
  const Component = styled.div({
51
51
  padding: 0,
@@ -54,10 +54,10 @@ typescriptEslintTester.run(
54
54
  boxSizing: 'border-box',
55
55
  });
56
56
  `,
57
- },
58
- {
59
- name: 'Pseudo element selectors',
60
- code: `
57
+ },
58
+ {
59
+ name: 'Pseudo element selectors',
60
+ code: `
61
61
  import { styled } from '@compiled/react';
62
62
  const Component = styled.div({
63
63
  '&:hover': {
@@ -71,32 +71,10 @@ typescriptEslintTester.run(
71
71
  },
72
72
  });
73
73
  `,
74
- },
75
- {
76
- name: 'Next sibling selector on non-HTML element',
77
- code: `
78
- import { styled } from '@compiled/react';
79
- styled.div({
80
- '& + &': {
81
- color: 'orange'
82
- }
83
- });
84
- `,
85
- },
86
- {
87
- name: 'Subsequent sibling selector on non-HTML element',
88
- code: `
89
- import { styled } from '@compiled/react';
90
- styled.div({
91
- '& ~ &': {
92
- color: 'orange'
93
- }
94
- });
95
- `,
96
- },
97
- {
98
- name: 'Skips @ queries',
99
- code: `
74
+ },
75
+ {
76
+ name: 'Skips @ queries',
77
+ code: `
100
78
  import { css } from '@compiled/react';
101
79
  const styles = css({
102
80
  '@container (width > 400px)': {
@@ -108,46 +86,12 @@ typescriptEslintTester.run(
108
86
  },
109
87
  });
110
88
  `,
111
- },
112
- {
113
- name: 'Skip cssMap call',
114
- code: `
115
- import { cssMap } from '@atlaskit/css';
116
-
117
- const styles = cssMap({
118
- success: {
119
- color: 'var(--ds-text-inverse)',
120
- backgroundColor: 'var(--ds-background-success-bold)',
121
- '&:hover': {
122
- backgroundColor: 'var(--ds-background-success-bold-hovered)',
123
- },
124
- '&:active': {
125
- backgroundColor: 'var(--ds-background-success-bold-pressed)',
126
- },
127
- },
128
- });
129
- `,
130
- },
131
- {
132
- name: 'Skip keyframes call',
133
- code: `
134
- import { keyframes } from '@emotion/react';
135
-
136
- const keyFrameStyles = keyframes({
137
- 'from, to': {
138
- opacity: 0,
139
- },
140
- '50%': {
141
- opacity: 1,
142
- },
143
- });
144
- `,
145
- },
146
- ],
147
- invalid: [
148
- {
149
- name: 'Universal selector',
150
- code: `
89
+ },
90
+ ],
91
+ invalid: [
92
+ {
93
+ name: 'Universal selector',
94
+ code: `
151
95
  import { styled } from '@compiled/react';
152
96
  const Component = styled.div({
153
97
  '*': {
@@ -155,11 +99,11 @@ typescriptEslintTester.run(
155
99
  }
156
100
  });
157
101
  `,
158
- errors: [{ messageId: 'no-nested-selectors' }],
159
- },
160
- {
161
- name: 'Class selector',
162
- code: `
102
+ errors: [{ messageId: 'no-nested-selectors' }],
103
+ },
104
+ {
105
+ name: 'Class selector',
106
+ code: `
163
107
  import { styled } from '@compiled/react';
164
108
  const Component = styled.div({
165
109
  '.myclass': {
@@ -167,11 +111,11 @@ typescriptEslintTester.run(
167
111
  }
168
112
  });
169
113
  `,
170
- errors: [{ messageId: 'no-nested-selectors' }],
171
- },
172
- {
173
- name: 'ID selector',
174
- code: `
114
+ errors: [{ messageId: 'no-nested-selectors' }],
115
+ },
116
+ {
117
+ name: 'ID selector',
118
+ code: `
175
119
  import { styled } from '@compiled/react';
176
120
  const Component = styled.div({
177
121
  '#myid': {
@@ -179,11 +123,11 @@ typescriptEslintTester.run(
179
123
  }
180
124
  });
181
125
  `,
182
- errors: [{ messageId: 'no-nested-selectors' }],
183
- },
184
- {
185
- name: 'HTML element selector',
186
- code: `
126
+ errors: [{ messageId: 'no-nested-selectors' }],
127
+ },
128
+ {
129
+ name: 'HTML element selector',
130
+ code: `
187
131
  import { styled } from '@compiled/react';
188
132
  const Component = styled.div({
189
133
  h2: {
@@ -191,11 +135,11 @@ typescriptEslintTester.run(
191
135
  }
192
136
  });
193
137
  `,
194
- errors: [{ messageId: 'no-nested-selectors' }],
195
- },
196
- {
197
- name: 'Data-component-selector',
198
- code: `
138
+ errors: [{ messageId: 'no-nested-selectors' }],
139
+ },
140
+ {
141
+ name: 'Data-component-selector',
142
+ code: `
199
143
  import { styled } from '@compiled/react';
200
144
  const Component = styled.div({
201
145
  '[data-component-selector="my.button"]': {
@@ -203,11 +147,11 @@ typescriptEslintTester.run(
203
147
  },
204
148
  });
205
149
  `,
206
- errors: [{ messageId: 'no-nested-selectors' }],
207
- },
208
- {
209
- name: 'Grouping selector',
210
- code: `
150
+ errors: [{ messageId: 'no-nested-selectors' }],
151
+ },
152
+ {
153
+ name: 'Grouping selector',
154
+ code: `
211
155
  import { styled } from '@compiled/react';
212
156
  const Component = styled.div({
213
157
  'div, p, span': {
@@ -217,11 +161,11 @@ typescriptEslintTester.run(
217
161
  backgroundColor: 'red',
218
162
  });
219
163
  `,
220
- errors: [{ messageId: 'no-nested-selectors' }],
221
- },
222
- {
223
- name: 'Selector including a variable',
224
- code: `
164
+ errors: [{ messageId: 'no-nested-selectors' }],
165
+ },
166
+ {
167
+ name: 'Selector including a variable',
168
+ code: `
225
169
  import { styled } from '@compiled/react';
226
170
  styled.div({
227
171
  [\`\${SOME_VAR} > *\`]: {
@@ -229,11 +173,11 @@ typescriptEslintTester.run(
229
173
  },
230
174
  });
231
175
  `,
232
- errors: [{ messageId: 'no-nested-selectors' }],
233
- },
234
- {
235
- name: 'Current element selector',
236
- code: `
176
+ errors: [{ messageId: 'no-nested-selectors' }],
177
+ },
178
+ {
179
+ name: 'Current element selector',
180
+ code: `
237
181
  import { styled } from '@compiled/react';
238
182
  styled.div({
239
183
  color: 'darkorchid',
@@ -242,11 +186,11 @@ typescriptEslintTester.run(
242
186
  }
243
187
  });
244
188
  `,
245
- errors: [{ messageId: 'no-nested-selectors' }],
246
- },
247
- {
248
- name: 'Child combinator',
249
- code: `
189
+ errors: [{ messageId: 'no-nested-selectors' }],
190
+ },
191
+ {
192
+ name: 'Child combinator',
193
+ code: `
250
194
  import { styled } from '@compiled/react';
251
195
  styled.div({
252
196
  '& > &': {
@@ -254,11 +198,23 @@ typescriptEslintTester.run(
254
198
  }
255
199
  });
256
200
  `,
257
- errors: [{ messageId: 'no-nested-selectors' }],
258
- },
259
- {
260
- name: 'Column combinator',
261
- code: `
201
+ errors: [{ messageId: 'no-nested-selectors' }],
202
+ },
203
+ {
204
+ name: 'Child combinator without whitespace',
205
+ code: `
206
+ import { styled } from '@compiled/react';
207
+ styled.div({
208
+ '&>a': {
209
+ color: 'orange'
210
+ }
211
+ });
212
+ `,
213
+ errors: [{ messageId: 'no-nested-selectors' }],
214
+ },
215
+ {
216
+ name: 'Column combinator',
217
+ code: `
262
218
  import { styled } from '@compiled/react';
263
219
  styled.div({
264
220
  'col.selected||td': {
@@ -266,11 +222,11 @@ typescriptEslintTester.run(
266
222
  }
267
223
  });
268
224
  `,
269
- errors: [{ messageId: 'no-nested-selectors' }],
270
- },
271
- {
272
- name: 'Namespace selector',
273
- code: `
225
+ errors: [{ messageId: 'no-nested-selectors' }],
226
+ },
227
+ {
228
+ name: 'Namespace selector',
229
+ code: `
274
230
  import { styled } from '@compiled/react';
275
231
  styled.div({
276
232
  'myNameSpace|a': {
@@ -278,8 +234,89 @@ typescriptEslintTester.run(
278
234
  }
279
235
  });
280
236
  `,
281
- errors: [{ messageId: 'no-nested-selectors' }],
282
- },
283
- ],
284
- },
237
+ errors: [{ messageId: 'no-nested-selectors' }],
238
+ },
239
+ {
240
+ name: 'Descendant combinator',
241
+ code: `
242
+ import { styled } from '@compiled/react';
243
+ const Component = styled.div({
244
+ '& &:hover': {
245
+ padding: 0,
246
+ }
247
+ });
248
+ `,
249
+ errors: [{ messageId: 'no-nested-selectors' }],
250
+ },
251
+ {
252
+ name: 'cssMap API',
253
+ code: `
254
+ import { cssMap } from '@compiled/react';
255
+
256
+ const styles = cssMap({
257
+ success: {
258
+ '[data-component-selector="my.button"]': {
259
+ color: 'var(--ds-text-inverse)',
260
+ }
261
+ },
262
+ });
263
+ `,
264
+ errors: [{ messageId: 'no-nested-selectors' }],
265
+ },
266
+ {
267
+ name: 'keyframes API',
268
+ code: `
269
+ import { keyframes } from '@emotion/react';
270
+
271
+ const keyFrameStyles = keyframes({
272
+ 'from, to': {
273
+ div: {
274
+ opacity: 0,
275
+ }
276
+ },
277
+ '50%': {
278
+ opacity: 1,
279
+ },
280
+ });
281
+ `,
282
+ errors: [{ messageId: 'no-nested-selectors' }],
283
+ },
284
+ {
285
+ name: 'Next sibling selector',
286
+ code: `
287
+ import { styled } from '@compiled/react';
288
+ styled.div({
289
+ '&+a': {
290
+ color: 'orange'
291
+ }
292
+ });
293
+ `,
294
+ errors: [{ messageId: 'no-nested-selectors' }],
295
+ },
296
+ {
297
+ name: 'Next sibling selector on non-HTML element',
298
+ code: `
299
+ import { styled } from '@compiled/react';
300
+ styled.div({
301
+ '& + &': {
302
+ color: 'orange'
303
+ }
304
+ });
305
+ `,
306
+ errors: [{ messageId: 'no-nested-selectors' }],
307
+ },
308
+ {
309
+ name: 'Subsequent sibling selector on non-HTML element',
310
+ code: `
311
+ import { styled } from '@compiled/react';
312
+ styled.div({
313
+ '& ~ &': {
314
+ color: 'orange'
315
+ }
316
+ });
317
+ `,
318
+ errors: [{ messageId: 'no-nested-selectors' }],
319
+ },
320
+ ],
321
+ },
285
322
  );