@atlaskit/eslint-plugin-ui-styling-standard 0.14.2 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +188 -167
- package/README.md +1 -0
- package/afm-cc/tsconfig.json +10 -3
- package/afm-jira/tsconfig.json +28 -0
- package/constellation/atlaskit-theme/usage.mdx +17 -17
- package/constellation/convert-props-syntax/usage.mdx +14 -14
- package/constellation/enforce-style-prop/usage.mdx +17 -17
- package/constellation/index/overview.mdx +99 -98
- package/constellation/local-cx-xcss/usage.mdx +4 -4
- package/constellation/no-array-arguments/usage.mdx +7 -7
- package/constellation/no-container-queries/usage.mdx +14 -14
- package/constellation/no-dynamic-styles/usage.mdx +19 -19
- package/constellation/no-exported-styles/usage.mdx +15 -15
- package/constellation/no-global-styles/usage.mdx +13 -13
- package/constellation/no-important-styles/usage.mdx +2 -2
- package/constellation/no-imported-style-values/usage.mdx +16 -16
- package/constellation/no-nested-selectors/usage.mdx +18 -18
- package/constellation/no-styled/usage.mdx +6 -6
- package/constellation/no-unsafe-selectors/usage.mdx +244 -0
- package/constellation/no-unsafe-values/usage.mdx +33 -33
- package/dist/cjs/index.codegen.js +1 -1
- package/dist/cjs/presets/all.codegen.js +2 -1
- package/dist/cjs/presets/recommended.codegen.js +2 -1
- package/dist/cjs/rules/index.codegen.js +3 -1
- package/dist/cjs/rules/no-unsafe-selectors/constants.js +30 -0
- package/dist/cjs/rules/no-unsafe-selectors/index.js +188 -0
- package/dist/cjs/rules/no-unsafe-selectors/lint-selector.js +198 -0
- package/dist/cjs/rules/no-unsafe-selectors/source-position-utils.js +42 -0
- package/dist/cjs/rules/no-unsafe-selectors/walk-css-map.js +186 -0
- package/dist/es2019/index.codegen.js +1 -1
- package/dist/es2019/presets/all.codegen.js +2 -1
- package/dist/es2019/presets/recommended.codegen.js +2 -1
- package/dist/es2019/rules/index.codegen.js +3 -1
- package/dist/es2019/rules/no-unsafe-selectors/constants.js +22 -0
- package/dist/es2019/rules/no-unsafe-selectors/index.js +176 -0
- package/dist/es2019/rules/no-unsafe-selectors/lint-selector.js +161 -0
- package/dist/es2019/rules/no-unsafe-selectors/source-position-utils.js +31 -0
- package/dist/es2019/rules/no-unsafe-selectors/walk-css-map.js +180 -0
- package/dist/esm/index.codegen.js +1 -1
- package/dist/esm/presets/all.codegen.js +2 -1
- package/dist/esm/presets/recommended.codegen.js +2 -1
- package/dist/esm/rules/index.codegen.js +3 -1
- package/dist/esm/rules/no-unsafe-selectors/constants.js +24 -0
- package/dist/esm/rules/no-unsafe-selectors/index.js +181 -0
- package/dist/esm/rules/no-unsafe-selectors/lint-selector.js +191 -0
- package/dist/esm/rules/no-unsafe-selectors/source-position-utils.js +34 -0
- package/dist/esm/rules/no-unsafe-selectors/walk-css-map.js +179 -0
- package/dist/types/index.codegen.d.ts +2 -0
- package/dist/types/presets/all.codegen.d.ts +2 -1
- package/dist/types/presets/recommended.codegen.d.ts +2 -1
- package/dist/types/rules/index.codegen.d.ts +1 -0
- package/dist/types/rules/no-unsafe-selectors/constants.d.ts +23 -0
- package/dist/types/rules/no-unsafe-selectors/index.d.ts +3 -0
- package/dist/types/rules/no-unsafe-selectors/lint-selector.d.ts +14 -0
- package/dist/types/rules/no-unsafe-selectors/source-position-utils.d.ts +20 -0
- package/dist/types/rules/no-unsafe-selectors/walk-css-map.d.ts +23 -0
- package/dist/types-ts4.5/index.codegen.d.ts +2 -0
- package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +2 -1
- package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
- package/dist/types-ts4.5/rules/no-unsafe-selectors/constants.d.ts +84 -0
- package/dist/types-ts4.5/rules/no-unsafe-selectors/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/no-unsafe-selectors/lint-selector.d.ts +14 -0
- package/dist/types-ts4.5/rules/no-unsafe-selectors/source-position-utils.d.ts +23 -0
- package/dist/types-ts4.5/rules/no-unsafe-selectors/walk-css-map.d.ts +23 -0
- package/package.json +7 -8
- package/scripts/codegen.tsx +3 -4
- package/src/index.codegen.tsx +3 -3
- package/src/presets/all.codegen.tsx +70 -72
- package/src/presets/recommended.codegen.tsx +70 -72
- package/src/rules/index.codegen.tsx +19 -17
- package/src/rules/no-classname-prop/index.tsx +1 -1
- package/src/rules/no-nested-selectors/index.tsx +1 -1
- package/src/rules/no-unsafe-selectors/README.md +232 -0
- package/src/rules/no-unsafe-selectors/__tests__/no-ambiguous-pseudos.test.tsx +368 -0
- package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +60 -0
- package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +73 -0
- package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +40 -0
- package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +101 -0
- package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +131 -0
- package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +132 -0
- package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +25 -0
- package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +35 -0
- package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +238 -0
- package/src/rules/no-unsafe-selectors/constants.tsx +99 -0
- package/src/rules/no-unsafe-selectors/index.tsx +198 -0
- package/src/rules/no-unsafe-selectors/lint-selector.tsx +155 -0
- package/src/rules/no-unsafe-selectors/source-position-utils.tsx +55 -0
- package/src/rules/no-unsafe-selectors/walk-css-map.tsx +232 -0
- package/tsconfig.app.json +45 -45
- package/tsconfig.dev.json +43 -43
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import outdent from 'outdent';
|
|
2
|
+
|
|
3
|
+
import { tester } from '../../__tests__/utils/_tester';
|
|
4
|
+
import rule from '../index';
|
|
5
|
+
|
|
6
|
+
tester.run('no-ambiguous-pseudos', rule, {
|
|
7
|
+
valid: [
|
|
8
|
+
{
|
|
9
|
+
name: '& is used',
|
|
10
|
+
code: `
|
|
11
|
+
import { css } from '@compiled/react';
|
|
12
|
+
|
|
13
|
+
css({
|
|
14
|
+
'&:hover': {},
|
|
15
|
+
'&:focus, &:active': {},
|
|
16
|
+
});
|
|
17
|
+
`,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: '& is used with compound selector',
|
|
21
|
+
code: `
|
|
22
|
+
import { css } from '@compiled/react';
|
|
23
|
+
|
|
24
|
+
css({
|
|
25
|
+
'&:hover:focus': {}
|
|
26
|
+
});
|
|
27
|
+
`,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: '* is used',
|
|
31
|
+
code: `
|
|
32
|
+
import { css } from '@compiled/react';
|
|
33
|
+
|
|
34
|
+
css({
|
|
35
|
+
'*:hover': {},
|
|
36
|
+
'*:focus, *:active': {},
|
|
37
|
+
'*:hover:focus': {},
|
|
38
|
+
});
|
|
39
|
+
`,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'missing & after attribute',
|
|
43
|
+
code: `
|
|
44
|
+
import { css } from '@compiled/react';
|
|
45
|
+
|
|
46
|
+
css({
|
|
47
|
+
'[data-testid]:hover': {}
|
|
48
|
+
});
|
|
49
|
+
`,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'missing & after attribute with value',
|
|
53
|
+
code: `
|
|
54
|
+
import { css } from '@compiled/react';
|
|
55
|
+
|
|
56
|
+
css({
|
|
57
|
+
'[data-testid="abc"]:hover': {}
|
|
58
|
+
});
|
|
59
|
+
`,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'missing & after descendant selector',
|
|
63
|
+
code: `
|
|
64
|
+
import { css } from '@compiled/react';
|
|
65
|
+
|
|
66
|
+
css({
|
|
67
|
+
'& :hover': {},
|
|
68
|
+
});
|
|
69
|
+
`,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'missing & after sibling selector',
|
|
73
|
+
code: `
|
|
74
|
+
import { css } from '@compiled/react';
|
|
75
|
+
|
|
76
|
+
css({
|
|
77
|
+
'& + :hover': {},
|
|
78
|
+
});
|
|
79
|
+
`,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'should ignore xcss',
|
|
83
|
+
code: `
|
|
84
|
+
import { xcss } from '@atlaskit/primitives';
|
|
85
|
+
|
|
86
|
+
xcss({
|
|
87
|
+
':hover': {},
|
|
88
|
+
});
|
|
89
|
+
`,
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
invalid: [
|
|
93
|
+
{
|
|
94
|
+
name: 'missing &',
|
|
95
|
+
code: outdent`
|
|
96
|
+
import { css } from '@compiled/react';
|
|
97
|
+
|
|
98
|
+
css({
|
|
99
|
+
':hover': {},
|
|
100
|
+
});
|
|
101
|
+
`,
|
|
102
|
+
output: outdent`
|
|
103
|
+
import { css } from '@compiled/react';
|
|
104
|
+
|
|
105
|
+
css({
|
|
106
|
+
'&:hover': {},
|
|
107
|
+
});
|
|
108
|
+
`,
|
|
109
|
+
errors: [
|
|
110
|
+
{
|
|
111
|
+
messageId: 'no-ambiguous-pseudos',
|
|
112
|
+
line: 4,
|
|
113
|
+
column: 4,
|
|
114
|
+
endColumn: 10,
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: 'multiple selectors in list with missing &',
|
|
120
|
+
code: outdent`
|
|
121
|
+
import { css } from '@compiled/react';
|
|
122
|
+
|
|
123
|
+
css({
|
|
124
|
+
':hover, :focus': {},
|
|
125
|
+
});
|
|
126
|
+
`,
|
|
127
|
+
output: outdent`
|
|
128
|
+
import { css } from '@compiled/react';
|
|
129
|
+
|
|
130
|
+
css({
|
|
131
|
+
'&:hover, &:focus': {},
|
|
132
|
+
});
|
|
133
|
+
`,
|
|
134
|
+
errors: [
|
|
135
|
+
{
|
|
136
|
+
messageId: 'no-ambiguous-pseudos',
|
|
137
|
+
line: 4,
|
|
138
|
+
column: 4,
|
|
139
|
+
endColumn: 10,
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
messageId: 'no-ambiguous-pseudos',
|
|
143
|
+
line: 4,
|
|
144
|
+
column: 12,
|
|
145
|
+
endColumn: 18,
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: 'multiple selectors in list with one missing &',
|
|
151
|
+
code: outdent`
|
|
152
|
+
import { css } from '@compiled/react';
|
|
153
|
+
|
|
154
|
+
css({
|
|
155
|
+
'&:hover, :focus': {},
|
|
156
|
+
});
|
|
157
|
+
`,
|
|
158
|
+
output: outdent`
|
|
159
|
+
import { css } from '@compiled/react';
|
|
160
|
+
|
|
161
|
+
css({
|
|
162
|
+
'&:hover, &:focus': {},
|
|
163
|
+
});
|
|
164
|
+
`,
|
|
165
|
+
errors: [
|
|
166
|
+
{
|
|
167
|
+
messageId: 'no-ambiguous-pseudos',
|
|
168
|
+
line: 4,
|
|
169
|
+
column: 13,
|
|
170
|
+
endColumn: 19,
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: 'compound selector with missing &',
|
|
176
|
+
code: outdent`
|
|
177
|
+
import { css } from '@compiled/react';
|
|
178
|
+
|
|
179
|
+
css({
|
|
180
|
+
':hover:focus': {},
|
|
181
|
+
});
|
|
182
|
+
`,
|
|
183
|
+
output: outdent`
|
|
184
|
+
import { css } from '@compiled/react';
|
|
185
|
+
|
|
186
|
+
css({
|
|
187
|
+
'&:hover:focus': {},
|
|
188
|
+
});
|
|
189
|
+
`,
|
|
190
|
+
errors: [
|
|
191
|
+
{
|
|
192
|
+
messageId: 'no-ambiguous-pseudos',
|
|
193
|
+
line: 4,
|
|
194
|
+
column: 4,
|
|
195
|
+
endColumn: 10,
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
tester.run(
|
|
203
|
+
'no-ambiguous-pseudos with shouldAlwaysInsertNestingSelectorForAmbiguousPseudos disabled',
|
|
204
|
+
rule,
|
|
205
|
+
{
|
|
206
|
+
valid: [],
|
|
207
|
+
invalid: [
|
|
208
|
+
{
|
|
209
|
+
name: 'missing &',
|
|
210
|
+
code: outdent`
|
|
211
|
+
import { css } from '@compiled/react';
|
|
212
|
+
|
|
213
|
+
css({
|
|
214
|
+
':hover': {},
|
|
215
|
+
});
|
|
216
|
+
`,
|
|
217
|
+
options: [
|
|
218
|
+
{
|
|
219
|
+
shouldAlwaysInsertNestingSelectorForAmbiguousPseudos: false,
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
errors: [
|
|
223
|
+
{
|
|
224
|
+
messageId: 'no-ambiguous-pseudos',
|
|
225
|
+
line: 4,
|
|
226
|
+
column: 4,
|
|
227
|
+
endColumn: 10,
|
|
228
|
+
suggestions: [
|
|
229
|
+
{
|
|
230
|
+
messageId: 'insert-nesting-selector',
|
|
231
|
+
output: outdent`
|
|
232
|
+
import { css } from '@compiled/react';
|
|
233
|
+
|
|
234
|
+
css({
|
|
235
|
+
'&:hover': {},
|
|
236
|
+
});
|
|
237
|
+
`,
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
name: 'multiple selectors in list with missing &',
|
|
245
|
+
code: outdent`
|
|
246
|
+
import { css } from '@compiled/react';
|
|
247
|
+
|
|
248
|
+
css({
|
|
249
|
+
':hover, :focus': {},
|
|
250
|
+
});
|
|
251
|
+
`,
|
|
252
|
+
options: [
|
|
253
|
+
{
|
|
254
|
+
shouldAlwaysInsertNestingSelectorForAmbiguousPseudos: false,
|
|
255
|
+
},
|
|
256
|
+
],
|
|
257
|
+
errors: [
|
|
258
|
+
{
|
|
259
|
+
messageId: 'no-ambiguous-pseudos',
|
|
260
|
+
line: 4,
|
|
261
|
+
column: 4,
|
|
262
|
+
endColumn: 10,
|
|
263
|
+
suggestions: [
|
|
264
|
+
{
|
|
265
|
+
messageId: 'insert-nesting-selector',
|
|
266
|
+
output: outdent`
|
|
267
|
+
import { css } from '@compiled/react';
|
|
268
|
+
|
|
269
|
+
css({
|
|
270
|
+
'&:hover, :focus': {},
|
|
271
|
+
});
|
|
272
|
+
`,
|
|
273
|
+
},
|
|
274
|
+
],
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
messageId: 'no-ambiguous-pseudos',
|
|
278
|
+
line: 4,
|
|
279
|
+
column: 12,
|
|
280
|
+
endColumn: 18,
|
|
281
|
+
suggestions: [
|
|
282
|
+
{
|
|
283
|
+
messageId: 'insert-nesting-selector',
|
|
284
|
+
output: outdent`
|
|
285
|
+
import { css } from '@compiled/react';
|
|
286
|
+
|
|
287
|
+
css({
|
|
288
|
+
':hover, &:focus': {},
|
|
289
|
+
});
|
|
290
|
+
`,
|
|
291
|
+
},
|
|
292
|
+
],
|
|
293
|
+
},
|
|
294
|
+
],
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
name: 'multiple selectors in list with one missing &',
|
|
298
|
+
code: outdent`
|
|
299
|
+
import { css } from '@compiled/react';
|
|
300
|
+
|
|
301
|
+
css({
|
|
302
|
+
'&:hover, :focus': {},
|
|
303
|
+
});
|
|
304
|
+
`,
|
|
305
|
+
options: [
|
|
306
|
+
{
|
|
307
|
+
shouldAlwaysInsertNestingSelectorForAmbiguousPseudos: false,
|
|
308
|
+
},
|
|
309
|
+
],
|
|
310
|
+
errors: [
|
|
311
|
+
{
|
|
312
|
+
messageId: 'no-ambiguous-pseudos',
|
|
313
|
+
line: 4,
|
|
314
|
+
column: 13,
|
|
315
|
+
endColumn: 19,
|
|
316
|
+
suggestions: [
|
|
317
|
+
{
|
|
318
|
+
messageId: 'insert-nesting-selector',
|
|
319
|
+
output: outdent`
|
|
320
|
+
import { css } from '@compiled/react';
|
|
321
|
+
|
|
322
|
+
css({
|
|
323
|
+
'&:hover, &:focus': {},
|
|
324
|
+
});
|
|
325
|
+
`,
|
|
326
|
+
},
|
|
327
|
+
],
|
|
328
|
+
},
|
|
329
|
+
],
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
name: 'compound selector with missing &',
|
|
333
|
+
code: outdent`
|
|
334
|
+
import { css } from '@compiled/react';
|
|
335
|
+
|
|
336
|
+
css({
|
|
337
|
+
':hover:focus': {},
|
|
338
|
+
});
|
|
339
|
+
`,
|
|
340
|
+
options: [
|
|
341
|
+
{
|
|
342
|
+
shouldAlwaysInsertNestingSelectorForAmbiguousPseudos: false,
|
|
343
|
+
},
|
|
344
|
+
],
|
|
345
|
+
errors: [
|
|
346
|
+
{
|
|
347
|
+
messageId: 'no-ambiguous-pseudos',
|
|
348
|
+
line: 4,
|
|
349
|
+
column: 4,
|
|
350
|
+
endColumn: 10,
|
|
351
|
+
suggestions: [
|
|
352
|
+
{
|
|
353
|
+
messageId: 'insert-nesting-selector',
|
|
354
|
+
output: outdent`
|
|
355
|
+
import { css } from '@compiled/react';
|
|
356
|
+
|
|
357
|
+
css({
|
|
358
|
+
'&:hover:focus': {},
|
|
359
|
+
});
|
|
360
|
+
`,
|
|
361
|
+
},
|
|
362
|
+
],
|
|
363
|
+
},
|
|
364
|
+
],
|
|
365
|
+
},
|
|
366
|
+
],
|
|
367
|
+
},
|
|
368
|
+
);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { tester } from '../../__tests__/utils/_tester';
|
|
2
|
+
import rule from '../index';
|
|
3
|
+
|
|
4
|
+
tester.run('no-grouped-at-rules', rule, {
|
|
5
|
+
valid: [],
|
|
6
|
+
invalid: [
|
|
7
|
+
{
|
|
8
|
+
name: '@media grouping',
|
|
9
|
+
code: `
|
|
10
|
+
import { cssMap } from '@compiled/react';
|
|
11
|
+
|
|
12
|
+
cssMap({
|
|
13
|
+
variant: {
|
|
14
|
+
'@media': {
|
|
15
|
+
'(min-width: 900px)': {},
|
|
16
|
+
'(min-width: 1200px)': {},
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
`,
|
|
21
|
+
errors: [{ messageId: 'no-grouped-at-rules' }],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: '@keyframes grouping',
|
|
25
|
+
code: `
|
|
26
|
+
import { cssMap } from '@compiled/react';
|
|
27
|
+
|
|
28
|
+
cssMap({
|
|
29
|
+
success: {
|
|
30
|
+
'@keyframes': {
|
|
31
|
+
'fadeIn': {}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
`,
|
|
36
|
+
errors: [
|
|
37
|
+
{ messageId: 'no-grouped-at-rules' },
|
|
38
|
+
{ messageId: 'no-keyframes-at-rules' },
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: '@scope grouping',
|
|
43
|
+
code: `
|
|
44
|
+
import { cssMap } from '@compiled/react';
|
|
45
|
+
|
|
46
|
+
cssMap({
|
|
47
|
+
success: {
|
|
48
|
+
'@scope': {
|
|
49
|
+
'(body) to (article)': {}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
`,
|
|
54
|
+
errors: [
|
|
55
|
+
{ messageId: 'no-grouped-at-rules' },
|
|
56
|
+
{ messageId: 'no-restricted-at-rules', data: { atRule: '@scope' } },
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { tester } from '../../__tests__/utils/_tester';
|
|
2
|
+
import rule from '../index';
|
|
3
|
+
|
|
4
|
+
tester.run('no-increased-specificity', rule, {
|
|
5
|
+
valid: [
|
|
6
|
+
{
|
|
7
|
+
name: 'multiple & in selector list',
|
|
8
|
+
code: `
|
|
9
|
+
import { css } from '@compiled/react';
|
|
10
|
+
|
|
11
|
+
css({
|
|
12
|
+
'&:hover, &:active': {},
|
|
13
|
+
});
|
|
14
|
+
`,
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
invalid: [
|
|
18
|
+
{
|
|
19
|
+
name: 'single &',
|
|
20
|
+
code: `
|
|
21
|
+
import { css } from '@compiled/react';
|
|
22
|
+
|
|
23
|
+
css({
|
|
24
|
+
'&': {},
|
|
25
|
+
});
|
|
26
|
+
`,
|
|
27
|
+
errors: [
|
|
28
|
+
{
|
|
29
|
+
messageId: 'no-increased-specificity',
|
|
30
|
+
line: 5,
|
|
31
|
+
column: 12,
|
|
32
|
+
endColumn: 13,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'double &',
|
|
38
|
+
code: `
|
|
39
|
+
import { css } from '@compiled/react';
|
|
40
|
+
|
|
41
|
+
css({
|
|
42
|
+
'&&': {},
|
|
43
|
+
});
|
|
44
|
+
`,
|
|
45
|
+
errors: [
|
|
46
|
+
{
|
|
47
|
+
messageId: 'no-increased-specificity',
|
|
48
|
+
line: 5,
|
|
49
|
+
column: 12,
|
|
50
|
+
endColumn: 14,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'longer chain of &',
|
|
56
|
+
code: `
|
|
57
|
+
import { css } from '@compiled/react';
|
|
58
|
+
|
|
59
|
+
css({
|
|
60
|
+
'&&&&&&&&&': {},
|
|
61
|
+
});
|
|
62
|
+
`,
|
|
63
|
+
errors: [
|
|
64
|
+
{
|
|
65
|
+
messageId: 'no-increased-specificity',
|
|
66
|
+
line: 5,
|
|
67
|
+
column: 12,
|
|
68
|
+
endColumn: 21,
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { tester } from '../../__tests__/utils/_tester';
|
|
2
|
+
import rule from '../index';
|
|
3
|
+
|
|
4
|
+
tester.run('no-keyframes-at-rules', rule, {
|
|
5
|
+
valid: [],
|
|
6
|
+
invalid: [
|
|
7
|
+
{
|
|
8
|
+
name: '@keyframes',
|
|
9
|
+
code: `
|
|
10
|
+
import { css } from '@compiled/react';
|
|
11
|
+
|
|
12
|
+
css({
|
|
13
|
+
'@keyframes fadeIn': {}
|
|
14
|
+
});
|
|
15
|
+
`,
|
|
16
|
+
errors: [
|
|
17
|
+
{
|
|
18
|
+
messageId: 'no-keyframes-at-rules',
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: '@keyframes in cssMap',
|
|
24
|
+
code: `
|
|
25
|
+
import { cssMap } from '@compiled/react';
|
|
26
|
+
|
|
27
|
+
cssMap({
|
|
28
|
+
success: {
|
|
29
|
+
'@keyframes fadeIn': {}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
`,
|
|
33
|
+
errors: [
|
|
34
|
+
{
|
|
35
|
+
messageId: 'no-keyframes-at-rules',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { tester } from '../../__tests__/utils/_tester';
|
|
2
|
+
import rule from '../index';
|
|
3
|
+
|
|
4
|
+
tester.run('no-legacy-pseudo-element-syntax', rule, {
|
|
5
|
+
valid: [
|
|
6
|
+
{
|
|
7
|
+
code: `
|
|
8
|
+
import { css } from '@compiled/react';
|
|
9
|
+
|
|
10
|
+
css({
|
|
11
|
+
'&::after': {},
|
|
12
|
+
'&::before': {},
|
|
13
|
+
'&::first-letter': {},
|
|
14
|
+
'&::first-line': {},
|
|
15
|
+
});
|
|
16
|
+
`,
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
invalid: [
|
|
20
|
+
{
|
|
21
|
+
name: 'single colon syntax for pseudo elements',
|
|
22
|
+
code: `
|
|
23
|
+
import { css } from '@compiled/react';
|
|
24
|
+
|
|
25
|
+
css({
|
|
26
|
+
'&:after': {},
|
|
27
|
+
'&:before': {},
|
|
28
|
+
'&:first-letter': {},
|
|
29
|
+
'&:first-line': {},
|
|
30
|
+
});
|
|
31
|
+
`,
|
|
32
|
+
output: `
|
|
33
|
+
import { css } from '@compiled/react';
|
|
34
|
+
|
|
35
|
+
css({
|
|
36
|
+
'&::after': {},
|
|
37
|
+
'&::before': {},
|
|
38
|
+
'&::first-letter': {},
|
|
39
|
+
'&::first-line': {},
|
|
40
|
+
});
|
|
41
|
+
`,
|
|
42
|
+
errors: [
|
|
43
|
+
{
|
|
44
|
+
messageId: 'no-legacy-pseudo-element-syntax',
|
|
45
|
+
line: 5,
|
|
46
|
+
column: 13,
|
|
47
|
+
endColumn: 19,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
messageId: 'no-legacy-pseudo-element-syntax',
|
|
51
|
+
line: 6,
|
|
52
|
+
column: 13,
|
|
53
|
+
endColumn: 20,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
messageId: 'no-legacy-pseudo-element-syntax',
|
|
57
|
+
line: 7,
|
|
58
|
+
column: 13,
|
|
59
|
+
endColumn: 26,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
messageId: 'no-legacy-pseudo-element-syntax',
|
|
63
|
+
line: 8,
|
|
64
|
+
column: 13,
|
|
65
|
+
endColumn: 24,
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'single colon syntax in complex selector',
|
|
71
|
+
code: `
|
|
72
|
+
import { css } from '@compiled/react';
|
|
73
|
+
|
|
74
|
+
css({
|
|
75
|
+
'&:hover:after, &:active:before': {},
|
|
76
|
+
});
|
|
77
|
+
`,
|
|
78
|
+
output: `
|
|
79
|
+
import { css } from '@compiled/react';
|
|
80
|
+
|
|
81
|
+
css({
|
|
82
|
+
'&:hover::after, &:active::before': {},
|
|
83
|
+
});
|
|
84
|
+
`,
|
|
85
|
+
errors: [
|
|
86
|
+
{
|
|
87
|
+
messageId: 'no-legacy-pseudo-element-syntax',
|
|
88
|
+
line: 5,
|
|
89
|
+
column: 19,
|
|
90
|
+
endColumn: 25,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
messageId: 'no-legacy-pseudo-element-syntax',
|
|
94
|
+
line: 5,
|
|
95
|
+
column: 35,
|
|
96
|
+
endColumn: 42,
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
});
|