@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
@@ -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
- valid: [
7
- {
8
- name: 'css API valid usage',
9
- code: `
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
- name: 'styled API valid usage',
20
- code: `
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
- name: 'keyframes API valid usage',
31
- code: `
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
- name: 'xcss API valid usage',
48
- code: `
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
- name: 'cssMap API valid usage',
58
- code: `
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
- invalid: [
70
- {
71
- name: 'css API invalid usage',
72
- code: outdent`
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
- output: outdent`
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
- 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: `
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
- 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`
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
- output: outdent`
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
- 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: `
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
- 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`
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
- output: outdent`
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
- 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
- ],
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
- infer Head,
10
- ...infer Tail,
11
- ]
12
- ? Head extends Seen
13
- ? {
14
- ERROR: ['The following key appears more than once in the tuple:', Head];
15
- }
16
- : HasAllUnique<Tail, Exclude<Union, Head>, Head | Seen>
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
- '&:active',
28
- '&:autofill',
29
- '&:blank',
30
- '&:checked',
31
- '&:default',
32
- '&:defined',
33
- '&:disabled',
34
- '&:empty',
35
- '&:enabled',
36
- '&:first',
37
- '&:focus',
38
- '&:focus-visible',
39
- '&:focus-within',
40
- '&:fullscreen',
41
- '&:hover',
42
- '&:in-range',
43
- '&:indeterminate',
44
- '&:invalid',
45
- '&:left',
46
- '&:link',
47
- '&:local-link',
48
- '&:optional',
49
- '&:out-of-range',
50
- '&:paused',
51
- '&:picture-in-picture',
52
- '&:placeholder-shown',
53
- '&:playing',
54
- '&:read-only',
55
- '&:read-write',
56
- '&:required',
57
- '&:right',
58
- '&:target',
59
- '&:user-invalid',
60
- '&:user-valid',
61
- '&:valid',
62
- '&:visited',
63
- '&::after',
64
- '&::backdrop',
65
- '&::before',
66
- '&::cue',
67
- '&::cue-region',
68
- '&::first-letter',
69
- '&::first-line',
70
- '&::grammar-error',
71
- '&::marker',
72
- '&::placeholder',
73
- '&::selection',
74
- '&::spelling-error',
75
- '&::target-text',
76
- '&::view-transition',
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
- * The `&` is included above for type checking reasons,
82
- * but we don't actually want it when consuming the values.
83
- */
84
- cssPseudos.map((pseudo) => pseudo.slice(1)),
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
- '@container', // ignored because it's covered by `no-container-queries`
96
- '@media', // ignored because it's covered by `no-nested-styles`
97
- '@supports',
98
- '@property',
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
- node,
10
- sourceNode,
9
+ node,
10
+ sourceNode,
11
11
  }: {
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;
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
- * 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);
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
- const start = adjustment + node.sourceIndex;
41
- const end = start + node.value.length;
40
+ const start = adjustment + node.sourceIndex;
41
+ const end = start + node.value.length;
42
42
 
43
- return [start, end];
43
+ return [start, end];
44
44
  }
45
45
 
46
46
  export function getSourceLocationFromRange(
47
- context: Rule.RuleContext,
48
- [start, end]: Range,
47
+ context: Rule.RuleContext,
48
+ [start, end]: Range,
49
49
  ): AST.SourceLocation {
50
- const sourceCode = context.getSourceCode();
51
- return {
52
- start: sourceCode.getLocFromIndex(start),
53
- end: sourceCode.getLocFromIndex(end),
54
- };
50
+ const sourceCode = context.getSourceCode();
51
+ return {
52
+ start: sourceCode.getLocFromIndex(start),
53
+ end: sourceCode.getLocFromIndex(end),
54
+ };
55
55
  }