@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.
- package/CHANGELOG.md +17 -0
- package/constellation/index/migration-guide.mdx +309 -0
- package/constellation/index/overview.mdx +4 -0
- package/constellation/index/props.mdx +9 -5
- package/dist/cjs/rules/no-nested-selectors/index.js +68 -49
- package/dist/es2019/rules/no-nested-selectors/index.js +63 -45
- package/dist/esm/rules/no-nested-selectors/index.js +64 -49
- package/dist/types/rules/no-unsafe-selectors/constants.d.ts +1 -4
- package/index.js +9 -9
- package/package.json +3 -3
- package/scripts/codegen.tsx +223 -284
- package/src/rules/__tests__/utils/_tester.tsx +24 -24
- package/src/rules/atlaskit-theme/README.md +21 -19
- package/src/rules/atlaskit-theme/__tests__/test.ts +53 -53
- package/src/rules/atlaskit-theme/index.ts +107 -115
- package/src/rules/convert-props-syntax/README.md +32 -22
- package/src/rules/convert-props-syntax/__tests__/invalid.test.tsx +46 -46
- package/src/rules/convert-props-syntax/__tests__/rule.test.tsx +175 -175
- package/src/rules/convert-props-syntax/__tests__/type-annotations.test.tsx +52 -52
- package/src/rules/convert-props-syntax/__tests__/unusual-properties.test.tsx +33 -33
- package/src/rules/convert-props-syntax/index.tsx +356 -386
- package/src/rules/enforce-style-prop/README.md +21 -18
- package/src/rules/enforce-style-prop/__tests__/rule.test.tsx +90 -96
- package/src/rules/enforce-style-prop/index.tsx +144 -160
- package/src/rules/external-rules.tsx +163 -164
- package/src/rules/local-cx-xcss/README.md +10 -6
- package/src/rules/local-cx-xcss/__tests__/rule.test.tsx +26 -26
- package/src/rules/local-cx-xcss/index.tsx +46 -56
- package/src/rules/no-array-arguments/README.md +2 -1
- package/src/rules/no-array-arguments/__tests__/rule.test.tsx +37 -46
- package/src/rules/no-array-arguments/index.tsx +68 -69
- package/src/rules/no-classname-prop/README.md +7 -4
- package/src/rules/no-classname-prop/__tests__/rule.test.tsx +22 -22
- package/src/rules/no-classname-prop/index.tsx +25 -25
- package/src/rules/no-container-queries/README.md +11 -9
- package/src/rules/no-container-queries/__tests__/rule.test.tsx +47 -50
- package/src/rules/no-container-queries/index.tsx +75 -81
- package/src/rules/no-dynamic-styles/README.md +16 -19
- package/src/rules/no-dynamic-styles/__tests__/rule.test.tsx +58 -67
- package/src/rules/no-dynamic-styles/index.tsx +45 -48
- package/src/rules/no-exported-styles/README.md +17 -12
- package/src/rules/no-exported-styles/__tests__/rule.test.tsx +102 -111
- package/src/rules/no-exported-styles/index.tsx +36 -36
- package/src/rules/no-global-styles/README.md +15 -14
- package/src/rules/no-global-styles/__tests__/no-css-modules.test.tsx +28 -28
- package/src/rules/no-global-styles/__tests__/no-global-styles.test.tsx +37 -37
- package/src/rules/no-global-styles/index.tsx +59 -62
- package/src/rules/no-important-styles/README.md +5 -3
- package/src/rules/no-important-styles/__tests__/rule.test.tsx +66 -66
- package/src/rules/no-important-styles/index.tsx +49 -49
- package/src/rules/no-imported-style-values/README.md +23 -15
- package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +123 -123
- package/src/rules/no-imported-style-values/index.tsx +116 -120
- package/src/rules/no-nested-selectors/README.md +15 -13
- package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +186 -149
- package/src/rules/no-nested-selectors/index.tsx +92 -105
- package/src/rules/no-styled/README.md +14 -9
- package/src/rules/no-styled/__tests__/rule.test.tsx +31 -31
- package/src/rules/no-styled/index.tsx +34 -41
- package/src/rules/no-unsafe-selectors/README.md +103 -93
- package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +21 -24
- package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +44 -44
- package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +21 -21
- package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +57 -57
- package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +58 -58
- package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +85 -85
- package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +12 -12
- package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +23 -23
- package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +114 -114
- package/src/rules/no-unsafe-selectors/constants.tsx +69 -77
- package/src/rules/no-unsafe-selectors/source-position-utils.tsx +38 -38
- package/src/rules/no-unsafe-selectors/walk-css-map.tsx +178 -184
- package/src/rules/no-unsafe-values/README.md +34 -40
- package/src/rules/no-unsafe-values/__tests__/no-array-values.test.tsx +13 -13
- package/src/rules/no-unsafe-values/__tests__/no-conditional-values.test.tsx +18 -18
- package/src/rules/no-unsafe-values/__tests__/no-dynamic-keys.test.tsx +104 -104
- package/src/rules/no-unsafe-values/__tests__/no-function-calls.test.tsx +128 -128
- package/src/rules/no-unsafe-values/__tests__/no-identifier-arguments.test.tsx +23 -23
- package/src/rules/no-unsafe-values/__tests__/no-object-access.test.tsx +38 -38
- package/src/rules/no-unsafe-values/__tests__/no-object-references.test.tsx +18 -18
- package/src/rules/no-unsafe-values/__tests__/no-spread-elements.test.tsx +18 -18
- package/src/rules/no-unsafe-values/__tests__/no-unsafe-values.test.tsx +28 -28
- package/src/rules/no-unsafe-values/__tests__/no-variables.test.tsx +47 -47
- package/src/rules/no-unsafe-values/index.tsx +76 -78
- package/src/rules/no-unsafe-values/messages.tsx +12 -12
- package/src/rules/no-unsafe-values/utils.tsx +370 -382
- package/src/rules/use-compiled/README.md +11 -8
- package/src/rules/use-compiled/__tests__/can-auto-fix.test.tsx +32 -32
- package/src/rules/use-compiled/__tests__/css.test.tsx +53 -53
- package/src/rules/use-compiled/__tests__/imports.test.tsx +90 -95
- package/src/rules/use-compiled/__tests__/keyframes.test.tsx +47 -47
- package/src/rules/use-compiled/__tests__/pragma.test.tsx +64 -64
- package/src/rules/use-compiled/__tests__/styled.test.tsx +53 -53
- package/src/rules/use-compiled/__tests__/use-compiled.test.tsx +10 -10
- package/src/rules/use-compiled/index.tsx +203 -226
- package/src/rules/use-compiled/is-safe.tsx +113 -117
- package/src/rules/use-compiled/utils.tsx +14 -18
- package/src/rules/utils/create-rule-with-typed-config.tsx +62 -63
- package/src/rules/utils/create-rule.tsx +3 -6
|
@@ -3,10 +3,10 @@ import { tester } from '../../__tests__/utils/_tester';
|
|
|
3
3
|
import rule from '../index';
|
|
4
4
|
|
|
5
5
|
tester.run('no-unsafe-selectors', rule, {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
valid: [
|
|
7
|
+
{
|
|
8
|
+
name: 'css API valid usage',
|
|
9
|
+
code: `
|
|
10
10
|
import { css } from '@compiled/react';
|
|
11
11
|
|
|
12
12
|
css({
|
|
@@ -14,10 +14,10 @@ tester.run('no-unsafe-selectors', rule, {
|
|
|
14
14
|
'&:focus, &:active': {},
|
|
15
15
|
});
|
|
16
16
|
`,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'styled API valid usage',
|
|
20
|
+
code: `
|
|
21
21
|
import { styled } from '@compiled/react';
|
|
22
22
|
|
|
23
23
|
styled.div({
|
|
@@ -25,10 +25,10 @@ tester.run('no-unsafe-selectors', rule, {
|
|
|
25
25
|
'&:focus, &:active': {},
|
|
26
26
|
});
|
|
27
27
|
`,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'keyframes API valid usage',
|
|
31
|
+
code: `
|
|
32
32
|
import { keyframes } from '@compiled/react';
|
|
33
33
|
|
|
34
34
|
keyframes({
|
|
@@ -42,20 +42,20 @@ tester.run('no-unsafe-selectors', rule, {
|
|
|
42
42
|
},
|
|
43
43
|
});
|
|
44
44
|
`,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'xcss API valid usage',
|
|
48
|
+
code: `
|
|
49
49
|
import { xcss } from '@atlaskit/primitives';
|
|
50
50
|
|
|
51
51
|
xcss({
|
|
52
52
|
'&:hover': {},
|
|
53
53
|
});
|
|
54
54
|
`,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'cssMap API valid usage',
|
|
58
|
+
code: `
|
|
59
59
|
import { cssMap } from '@atlaskit/primitives';
|
|
60
60
|
|
|
61
61
|
cssMap({
|
|
@@ -64,12 +64,12 @@ tester.run('no-unsafe-selectors', rule, {
|
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
`,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
invalid: [
|
|
70
|
+
{
|
|
71
|
+
name: 'css API invalid usage',
|
|
72
|
+
code: outdent`
|
|
73
73
|
import { css } from '@compiled/react';
|
|
74
74
|
|
|
75
75
|
css({
|
|
@@ -77,7 +77,7 @@ tester.run('no-unsafe-selectors', rule, {
|
|
|
77
77
|
'&:after': {},
|
|
78
78
|
});
|
|
79
79
|
`,
|
|
80
|
-
|
|
80
|
+
output: outdent`
|
|
81
81
|
import { css } from '@compiled/react';
|
|
82
82
|
|
|
83
83
|
css({
|
|
@@ -85,24 +85,24 @@ tester.run('no-unsafe-selectors', rule, {
|
|
|
85
85
|
'&::after': {},
|
|
86
86
|
});
|
|
87
87
|
`,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
88
|
+
errors: [
|
|
89
|
+
{
|
|
90
|
+
messageId: 'no-ambiguous-pseudos',
|
|
91
|
+
line: 4,
|
|
92
|
+
column: 4,
|
|
93
|
+
endColumn: 10,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
messageId: 'no-legacy-pseudo-element-syntax',
|
|
97
|
+
line: 5,
|
|
98
|
+
column: 5,
|
|
99
|
+
endColumn: 11,
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: 'styled API invalid usage',
|
|
105
|
+
code: `
|
|
106
106
|
import { styled } from '@compiled/react';
|
|
107
107
|
|
|
108
108
|
styled.div({
|
|
@@ -112,24 +112,24 @@ tester.run('no-unsafe-selectors', rule, {
|
|
|
112
112
|
'@scope (article) to (figure)': {},
|
|
113
113
|
});
|
|
114
114
|
`,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
115
|
+
errors: [
|
|
116
|
+
{
|
|
117
|
+
messageId: 'no-keyframes-at-rules',
|
|
118
|
+
line: 5,
|
|
119
|
+
column: 11,
|
|
120
|
+
endColumn: 30,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
messageId: 'no-restricted-at-rules',
|
|
124
|
+
line: 8,
|
|
125
|
+
column: 11,
|
|
126
|
+
endColumn: 41,
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: 'keyframes API invalid usage',
|
|
132
|
+
code: outdent`
|
|
133
133
|
import { keyframes } from '@emotion/react';
|
|
134
134
|
|
|
135
135
|
keyframes({
|
|
@@ -142,7 +142,7 @@ tester.run('no-unsafe-selectors', rule, {
|
|
|
142
142
|
':hover': {}, // Not valid but shouldn't be picked up by this rule
|
|
143
143
|
});
|
|
144
144
|
`,
|
|
145
|
-
|
|
145
|
+
output: outdent`
|
|
146
146
|
import { keyframes } from '@emotion/react';
|
|
147
147
|
|
|
148
148
|
keyframes({
|
|
@@ -155,42 +155,42 @@ tester.run('no-unsafe-selectors', rule, {
|
|
|
155
155
|
':hover': {}, // Not valid but shouldn't be picked up by this rule
|
|
156
156
|
});
|
|
157
157
|
`,
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
158
|
+
errors: [
|
|
159
|
+
{
|
|
160
|
+
messageId: 'no-ambiguous-pseudos',
|
|
161
|
+
line: 5,
|
|
162
|
+
column: 6,
|
|
163
|
+
endColumn: 12,
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
messageId: 'no-restricted-pseudos',
|
|
167
|
+
line: 8,
|
|
168
|
+
column: 7,
|
|
169
|
+
endColumn: 12,
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: 'xcss API invalid usage',
|
|
175
|
+
code: `
|
|
176
176
|
import { xcss } from '@atlaskit/primitives';
|
|
177
177
|
|
|
178
178
|
xcss({
|
|
179
179
|
'&&&&&&': {},
|
|
180
180
|
});
|
|
181
181
|
`,
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
182
|
+
errors: [
|
|
183
|
+
{
|
|
184
|
+
messageId: 'no-increased-specificity',
|
|
185
|
+
line: 5,
|
|
186
|
+
column: 12,
|
|
187
|
+
endColumn: 18,
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: 'cssMap API invalid usage',
|
|
193
|
+
code: outdent`
|
|
194
194
|
import { cssMap } from '@atlaskit/primitives';
|
|
195
195
|
|
|
196
196
|
cssMap({
|
|
@@ -203,7 +203,7 @@ tester.run('no-unsafe-selectors', rule, {
|
|
|
203
203
|
},
|
|
204
204
|
});
|
|
205
205
|
`,
|
|
206
|
-
|
|
206
|
+
output: outdent`
|
|
207
207
|
import { cssMap } from '@atlaskit/primitives';
|
|
208
208
|
|
|
209
209
|
cssMap({
|
|
@@ -216,23 +216,23 @@ tester.run('no-unsafe-selectors', rule, {
|
|
|
216
216
|
},
|
|
217
217
|
});
|
|
218
218
|
`,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
219
|
+
errors: [
|
|
220
|
+
{
|
|
221
|
+
messageId: 'no-ambiguous-pseudos',
|
|
222
|
+
line: 5,
|
|
223
|
+
column: 6,
|
|
224
|
+
endColumn: 12,
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
messageId: 'no-restricted-pseudos',
|
|
228
|
+
data: {
|
|
229
|
+
pseudo: ':first-child',
|
|
230
|
+
},
|
|
231
|
+
line: 9,
|
|
232
|
+
column: 7,
|
|
233
|
+
endColumn: 19,
|
|
234
|
+
},
|
|
235
|
+
],
|
|
236
|
+
},
|
|
237
|
+
],
|
|
238
238
|
});
|
|
@@ -5,18 +5,15 @@ import type { CSSPseudos } from '@compiled/react';
|
|
|
5
5
|
* https://stackoverflow.com/a/71236280
|
|
6
6
|
*/
|
|
7
7
|
type Validate<T extends true> = T;
|
|
8
|
-
type HasAllUnique<Tuple, Union, Seen = never> = Tuple extends readonly [
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
]
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
: [Union] extends [never]
|
|
18
|
-
? true
|
|
19
|
-
: { ERROR: ['Some keys are missing from the tuple:', Union] };
|
|
8
|
+
type HasAllUnique<Tuple, Union, Seen = never> = Tuple extends readonly [infer Head, ...infer Tail]
|
|
9
|
+
? Head extends Seen
|
|
10
|
+
? {
|
|
11
|
+
ERROR: ['The following key appears more than once in the tuple:', Head];
|
|
12
|
+
}
|
|
13
|
+
: HasAllUnique<Tail, Exclude<Union, Head>, Head | Seen>
|
|
14
|
+
: [Union] extends [never]
|
|
15
|
+
? true
|
|
16
|
+
: { ERROR: ['Some keys are missing from the tuple:', Union] };
|
|
20
17
|
|
|
21
18
|
/**
|
|
22
19
|
* Exporting this so it isn't considered unused.
|
|
@@ -24,76 +21,71 @@ type HasAllUnique<Tuple, Union, Seen = never> = Tuple extends readonly [
|
|
|
24
21
|
export type _ = Validate<HasAllUnique<typeof cssPseudos, CSSPseudos>>;
|
|
25
22
|
|
|
26
23
|
const cssPseudos = [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
24
|
+
'&:active',
|
|
25
|
+
'&:autofill',
|
|
26
|
+
'&:blank',
|
|
27
|
+
'&:checked',
|
|
28
|
+
'&:default',
|
|
29
|
+
'&:defined',
|
|
30
|
+
'&:disabled',
|
|
31
|
+
'&:empty',
|
|
32
|
+
'&:enabled',
|
|
33
|
+
'&:first',
|
|
34
|
+
'&:focus',
|
|
35
|
+
'&:focus-visible',
|
|
36
|
+
'&:focus-within',
|
|
37
|
+
'&:fullscreen',
|
|
38
|
+
'&:hover',
|
|
39
|
+
'&:in-range',
|
|
40
|
+
'&:indeterminate',
|
|
41
|
+
'&:invalid',
|
|
42
|
+
'&:left',
|
|
43
|
+
'&:link',
|
|
44
|
+
'&:local-link',
|
|
45
|
+
'&:optional',
|
|
46
|
+
'&:out-of-range',
|
|
47
|
+
'&:paused',
|
|
48
|
+
'&:picture-in-picture',
|
|
49
|
+
'&:placeholder-shown',
|
|
50
|
+
'&:playing',
|
|
51
|
+
'&:read-only',
|
|
52
|
+
'&:read-write',
|
|
53
|
+
'&:required',
|
|
54
|
+
'&:right',
|
|
55
|
+
'&:target',
|
|
56
|
+
'&:user-invalid',
|
|
57
|
+
'&:user-valid',
|
|
58
|
+
'&:valid',
|
|
59
|
+
'&:visited',
|
|
60
|
+
'&::after',
|
|
61
|
+
'&::backdrop',
|
|
62
|
+
'&::before',
|
|
63
|
+
'&::cue',
|
|
64
|
+
'&::cue-region',
|
|
65
|
+
'&::first-letter',
|
|
66
|
+
'&::first-line',
|
|
67
|
+
'&::grammar-error',
|
|
68
|
+
'&::marker',
|
|
69
|
+
'&::placeholder',
|
|
70
|
+
'&::selection',
|
|
71
|
+
'&::spelling-error',
|
|
72
|
+
'&::target-text',
|
|
73
|
+
'&::view-transition',
|
|
77
74
|
] as const;
|
|
78
75
|
|
|
79
76
|
export const allowedPseudos = new Set(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
77
|
+
/**
|
|
78
|
+
* The `&` is included above for type checking reasons,
|
|
79
|
+
* but we don't actually want it when consuming the values.
|
|
80
|
+
*/
|
|
81
|
+
cssPseudos.map((pseudo) => pseudo.slice(1)),
|
|
85
82
|
);
|
|
86
83
|
|
|
87
|
-
export const legacyPseudoElements = new Set([
|
|
88
|
-
':after',
|
|
89
|
-
':before',
|
|
90
|
-
':first-letter',
|
|
91
|
-
':first-line',
|
|
92
|
-
]);
|
|
84
|
+
export const legacyPseudoElements = new Set([':after', ':before', ':first-letter', ':first-line']);
|
|
93
85
|
|
|
94
86
|
export const ignoredAtRules = new Set([
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
87
|
+
'@container', // ignored because it's covered by `no-container-queries`
|
|
88
|
+
'@media', // ignored because it's covered by `no-nested-styles`
|
|
89
|
+
'@supports',
|
|
90
|
+
'@property',
|
|
99
91
|
]);
|
|
@@ -6,50 +6,50 @@ import { type Node as SelectorNode } from 'postcss-selector-parser';
|
|
|
6
6
|
type Range = [number, number];
|
|
7
7
|
|
|
8
8
|
export function getRangeFromNode({
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
node,
|
|
10
|
+
sourceNode,
|
|
11
11
|
}: {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The selector AST node to get the range of.
|
|
14
|
+
*/
|
|
15
|
+
node: SelectorNode & { value: string };
|
|
16
|
+
/**
|
|
17
|
+
* The source ESTree node whose value was parsed to obtain the selector AST.
|
|
18
|
+
*
|
|
19
|
+
* The range is calculated relative to this node's range.
|
|
20
|
+
*/
|
|
21
|
+
sourceNode: ESTree.Node;
|
|
22
22
|
}): Range {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
23
|
+
/**
|
|
24
|
+
* The adjustment required to align the selector AST source position
|
|
25
|
+
* with the ESTree source position.
|
|
26
|
+
*/
|
|
27
|
+
const adjustment =
|
|
28
|
+
/**
|
|
29
|
+
* Using a non-null `!` is safe here because ESLint requires the parser to
|
|
30
|
+
* include a range value on nodes.
|
|
31
|
+
*
|
|
32
|
+
* https://eslint.org/docs/latest/extend/custom-parsers#all-nodes
|
|
33
|
+
*/
|
|
34
|
+
sourceNode.range![0] +
|
|
35
|
+
/**
|
|
36
|
+
* We add +1 if it's a literal to account for the opening `'` or `"` character.
|
|
37
|
+
*/
|
|
38
|
+
(sourceNode.type === 'Literal' ? 1 : 0);
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
const start = adjustment + node.sourceIndex;
|
|
41
|
+
const end = start + node.value.length;
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
return [start, end];
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export function getSourceLocationFromRange(
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
context: Rule.RuleContext,
|
|
48
|
+
[start, end]: Range,
|
|
49
49
|
): AST.SourceLocation {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
const sourceCode = context.getSourceCode();
|
|
51
|
+
return {
|
|
52
|
+
start: sourceCode.getLocFromIndex(start),
|
|
53
|
+
end: sourceCode.getLocFromIndex(end),
|
|
54
|
+
};
|
|
55
55
|
}
|