@murky-web/oxlint-plugin-solid 1.5.0 → 1.5.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/README.md +2 -2
- package/package.json +1 -1
- package/src/index.mjs +3 -3
- package/src/rules/components_return_once.mjs +18 -18
- package/src/rules/event_handlers.mjs +28 -28
- package/src/rules/imports.mjs +22 -22
- package/src/rules/jsx_no_duplicate_props.mjs +14 -14
- package/src/rules/jsx_no_script_url.mjs +7 -7
- package/src/rules/jsx_no_undef.mjs +29 -29
- package/src/rules/jsx_uses_vars.mjs +4 -4
- package/src/rules/no_array_handlers.mjs +6 -6
- package/src/rules/no_destructure.mjs +33 -35
- package/src/rules/no_innerhtml.mjs +22 -22
- package/src/rules/no_owned_primitives_in_ref.mjs +9 -9
- package/src/rules/no_proxy_apis.mjs +10 -10
- package/src/rules/no_react_deps.mjs +9 -9
- package/src/rules/no_react_specific_props.mjs +8 -8
- package/src/rules/no_server_import_in_client.mjs +9 -9
- package/src/rules/no_setter_in_effect.mjs +11 -11
- package/src/rules/no_unknown_namespaces.mjs +16 -16
- package/src/rules/no_untracked_effect_read.mjs +9 -9
- package/src/rules/prefer_arrow_components.mjs +17 -17
- package/src/rules/prefer_class_object.mjs +16 -16
- package/src/rules/prefer_for.mjs +11 -11
- package/src/rules/prefer_show.mjs +9 -9
- package/src/rules/reactive_async.mjs +12 -12
- package/src/rules/reactivity.mjs +83 -84
- package/src/rules/self_closing_comp.mjs +17 -17
- package/src/rules/strict_void_return.mjs +12 -12
- package/src/rules/style_prop.mjs +21 -22
- package/src/rules/validate_jsx_nesting.mjs +15 -15
- package/src/utils.mjs +14 -14
|
@@ -34,7 +34,7 @@ export default {
|
|
|
34
34
|
docs: {
|
|
35
35
|
description:
|
|
36
36
|
"Disallow extra closing tags for components without children.",
|
|
37
|
-
url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/self-closing-comp.md"
|
|
37
|
+
url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/self-closing-comp.md"
|
|
38
38
|
},
|
|
39
39
|
fixable: "code",
|
|
40
40
|
schema: [
|
|
@@ -46,23 +46,23 @@ export default {
|
|
|
46
46
|
description:
|
|
47
47
|
"which Solid components should be self-closing when possible",
|
|
48
48
|
enum: ["all", "none"],
|
|
49
|
-
default: "all"
|
|
49
|
+
default: "all"
|
|
50
50
|
},
|
|
51
51
|
html: {
|
|
52
52
|
type: "string",
|
|
53
53
|
description:
|
|
54
54
|
"which native elements should be self-closing when possible",
|
|
55
55
|
enum: ["all", "void", "none"],
|
|
56
|
-
default: "all"
|
|
57
|
-
}
|
|
56
|
+
default: "all"
|
|
57
|
+
}
|
|
58
58
|
},
|
|
59
|
-
additionalProperties: false
|
|
60
|
-
}
|
|
59
|
+
additionalProperties: false
|
|
60
|
+
}
|
|
61
61
|
],
|
|
62
62
|
messages: {
|
|
63
63
|
selfClose: "Empty components are self-closing.",
|
|
64
|
-
dontSelfClose: "This element should not be self-closing."
|
|
65
|
-
}
|
|
64
|
+
dontSelfClose: "This element should not be self-closing."
|
|
65
|
+
}
|
|
66
66
|
},
|
|
67
67
|
defaultOptions: [],
|
|
68
68
|
create(context) {
|
|
@@ -106,10 +106,10 @@ export default {
|
|
|
106
106
|
// Replace />.*<\/.*>/ with '/>'
|
|
107
107
|
const range = [
|
|
108
108
|
openingElementEnding,
|
|
109
|
-
closingElementEnding
|
|
109
|
+
closingElementEnding
|
|
110
110
|
];
|
|
111
111
|
return fixer.replaceTextRange(range, " />");
|
|
112
|
-
}
|
|
112
|
+
}
|
|
113
113
|
});
|
|
114
114
|
} else if (!shouldSelfClose && node.selfClosing) {
|
|
115
115
|
context.report({
|
|
@@ -123,28 +123,28 @@ export default {
|
|
|
123
123
|
// Replace ' />' or '/>' with '></${tagName}>'
|
|
124
124
|
const lastTokens = sourceCode.getLastTokens(
|
|
125
125
|
node,
|
|
126
|
-
{ count: 3 }
|
|
126
|
+
{ count: 3 }
|
|
127
127
|
); // JSXIdentifier, '/', '>'
|
|
128
128
|
const isSpaceBeforeSelfClose =
|
|
129
129
|
sourceCode.isSpaceBetween?.(
|
|
130
130
|
lastTokens[0],
|
|
131
|
-
lastTokens[1]
|
|
131
|
+
lastTokens[1]
|
|
132
132
|
);
|
|
133
133
|
const range = [
|
|
134
134
|
isSpaceBeforeSelfClose
|
|
135
135
|
? selfCloseEnding - 3
|
|
136
136
|
: selfCloseEnding - 2,
|
|
137
|
-
selfCloseEnding
|
|
137
|
+
selfCloseEnding
|
|
138
138
|
];
|
|
139
139
|
return fixer.replaceTextRange(
|
|
140
140
|
range,
|
|
141
|
-
`></${tagName}
|
|
141
|
+
`></${tagName}>`
|
|
142
142
|
);
|
|
143
|
-
}
|
|
143
|
+
}
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
-
}
|
|
147
|
+
}
|
|
148
148
|
};
|
|
149
|
-
}
|
|
149
|
+
}
|
|
150
150
|
};
|
|
@@ -14,7 +14,7 @@ const PLAIN_VALUE_TYPES = new Set([
|
|
|
14
14
|
"Literal",
|
|
15
15
|
"ObjectExpression",
|
|
16
16
|
"TemplateLiteral",
|
|
17
|
-
"UpdateExpression"
|
|
17
|
+
"UpdateExpression"
|
|
18
18
|
]);
|
|
19
19
|
|
|
20
20
|
function isVoidExpression(expression) {
|
|
@@ -79,7 +79,7 @@ export const strictVoidReturnRule = {
|
|
|
79
79
|
docs: {
|
|
80
80
|
description:
|
|
81
81
|
"Disallow returning a value from callbacks Solid ignores the return of (event handlers, ref callbacks, onCleanup, onSettled).",
|
|
82
|
-
url: "https://docs.solidjs.com/"
|
|
82
|
+
url: "https://docs.solidjs.com/"
|
|
83
83
|
},
|
|
84
84
|
schema: [],
|
|
85
85
|
messages: {
|
|
@@ -88,8 +88,8 @@ export const strictVoidReturnRule = {
|
|
|
88
88
|
cleanupReturnsValue:
|
|
89
89
|
"This `{{primitive}}` callback returns a value, which is ignored. Remove the `return`, or use a block body that does not return.",
|
|
90
90
|
settledReturnsValue:
|
|
91
|
-
"This `onSettled` callback returns a value that is not a function. Only a returned cleanup function is used; remove the `return` or return `() => { … }`."
|
|
92
|
-
}
|
|
91
|
+
"This `onSettled` callback returns a value that is not a function. Only a returned cleanup function is used; remove the `return` or return `() => { … }`."
|
|
92
|
+
}
|
|
93
93
|
},
|
|
94
94
|
defaultOptions: [],
|
|
95
95
|
create(context) {
|
|
@@ -109,8 +109,8 @@ export const strictVoidReturnRule = {
|
|
|
109
109
|
messageId: "handlerReturnsValue",
|
|
110
110
|
data: {
|
|
111
111
|
attribute,
|
|
112
|
-
what: describe(callback.body)
|
|
113
|
-
}
|
|
112
|
+
what: describe(callback.body)
|
|
113
|
+
}
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -128,7 +128,7 @@ export const strictVoidReturnRule = {
|
|
|
128
128
|
values.some(
|
|
129
129
|
(value) =>
|
|
130
130
|
PLAIN_VALUE_TYPES.has(value.type) &&
|
|
131
|
-
!isVoidExpression(value)
|
|
131
|
+
!isVoidExpression(value)
|
|
132
132
|
)
|
|
133
133
|
) {
|
|
134
134
|
context.report({
|
|
@@ -137,7 +137,7 @@ export const strictVoidReturnRule = {
|
|
|
137
137
|
primitive === "onSettled"
|
|
138
138
|
? "settledReturnsValue"
|
|
139
139
|
: "cleanupReturnsValue",
|
|
140
|
-
data: { primitive }
|
|
140
|
+
data: { primitive }
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
143
|
}
|
|
@@ -163,7 +163,7 @@ export const strictVoidReturnRule = {
|
|
|
163
163
|
|
|
164
164
|
if (name === "ref") {
|
|
165
165
|
for (const callback of getRefCallbacks(
|
|
166
|
-
node.value.expression
|
|
166
|
+
node.value.expression
|
|
167
167
|
)) {
|
|
168
168
|
checkHandler(callback, "ref");
|
|
169
169
|
}
|
|
@@ -190,12 +190,12 @@ export const strictVoidReturnRule = {
|
|
|
190
190
|
|
|
191
191
|
const primitive = matchImport(
|
|
192
192
|
[...CLEANUP_PRIMITIVES, ...SETTLED_PRIMITIVES],
|
|
193
|
-
node.callee.name
|
|
193
|
+
node.callee.name
|
|
194
194
|
);
|
|
195
195
|
if (primitive) {
|
|
196
196
|
checkCleanup(callback, primitive);
|
|
197
197
|
}
|
|
198
|
-
}
|
|
198
|
+
}
|
|
199
199
|
};
|
|
200
|
-
}
|
|
200
|
+
}
|
|
201
201
|
};
|
package/src/rules/style_prop.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getPropertyName,
|
|
3
|
-
getStaticValue
|
|
3
|
+
getStaticValue
|
|
4
4
|
} from "@eslint-community/eslint-utils";
|
|
5
5
|
import kebabCase from "kebab-case";
|
|
6
6
|
import { all as allCssProperties } from "known-css-properties";
|
|
@@ -17,7 +17,7 @@ export default {
|
|
|
17
17
|
description:
|
|
18
18
|
"Require CSS properties in the `style` prop to be valid and kebab-cased (ex. 'font-size'), not camel-cased (ex. 'fontSize') like in React, " +
|
|
19
19
|
"and that property values with dimensions are strings, not numbers with implicit 'px' units.",
|
|
20
|
-
url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/style-prop.md"
|
|
20
|
+
url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/style-prop.md"
|
|
21
21
|
},
|
|
22
22
|
fixable: "code",
|
|
23
23
|
schema: [
|
|
@@ -30,29 +30,28 @@ export default {
|
|
|
30
30
|
default: ["style"],
|
|
31
31
|
type: "array",
|
|
32
32
|
items: {
|
|
33
|
-
type: "string"
|
|
33
|
+
type: "string"
|
|
34
34
|
},
|
|
35
35
|
minItems: 1,
|
|
36
|
-
uniqueItems: true
|
|
36
|
+
uniqueItems: true
|
|
37
37
|
},
|
|
38
38
|
allowString: {
|
|
39
39
|
description:
|
|
40
40
|
"if allowString is set to true, this rule will not convert a style string literal into a style object (not recommended for performance)",
|
|
41
41
|
type: "boolean",
|
|
42
|
-
default: false
|
|
43
|
-
}
|
|
42
|
+
default: false
|
|
43
|
+
}
|
|
44
44
|
},
|
|
45
|
-
additionalProperties: false
|
|
46
|
-
}
|
|
45
|
+
additionalProperties: false
|
|
46
|
+
}
|
|
47
47
|
],
|
|
48
48
|
messages: {
|
|
49
49
|
kebabStyleProp: "Use {{ kebabName }} instead of {{ name }}.",
|
|
50
50
|
invalidStyleProp: "{{ name }} is not a valid CSS property.",
|
|
51
51
|
numericStyleValue:
|
|
52
52
|
'This CSS property value should be a string with a unit; Solid does not automatically append a "px" unit.',
|
|
53
|
-
stringStyle:
|
|
54
|
-
|
|
55
|
-
},
|
|
53
|
+
stringStyle: "Use an object for the style prop instead of a string."
|
|
54
|
+
}
|
|
56
55
|
},
|
|
57
56
|
defaultOptions: [],
|
|
58
57
|
create(context) {
|
|
@@ -91,22 +90,22 @@ export default {
|
|
|
91
90
|
((fixer) =>
|
|
92
91
|
fixer.replaceText(
|
|
93
92
|
node.value,
|
|
94
|
-
`{${JSON.stringify(objectStyles)}}
|
|
95
|
-
))
|
|
93
|
+
`{${JSON.stringify(objectStyles)}}`
|
|
94
|
+
))
|
|
96
95
|
});
|
|
97
96
|
} else if (style.type === "TemplateLiteral" && !allowString) {
|
|
98
97
|
context.report({
|
|
99
98
|
node: style,
|
|
100
|
-
messageId: "stringStyle"
|
|
99
|
+
messageId: "stringStyle"
|
|
101
100
|
});
|
|
102
101
|
} else if (style.type === "ObjectExpression") {
|
|
103
102
|
const properties = style.properties.filter(
|
|
104
|
-
(prop) => prop.type === "Property"
|
|
103
|
+
(prop) => prop.type === "Property"
|
|
105
104
|
);
|
|
106
105
|
properties.forEach((prop) => {
|
|
107
106
|
const name = getPropertyName(
|
|
108
107
|
prop,
|
|
109
|
-
getScope(context, prop)
|
|
108
|
+
getScope(context, prop)
|
|
110
109
|
);
|
|
111
110
|
if (
|
|
112
111
|
name &&
|
|
@@ -123,14 +122,14 @@ export default {
|
|
|
123
122
|
fix: (fixer) =>
|
|
124
123
|
fixer.replaceText(
|
|
125
124
|
prop.key,
|
|
126
|
-
`"${kebabName}"
|
|
127
|
-
)
|
|
125
|
+
`"${kebabName}"`
|
|
126
|
+
) // wrap kebab name in quotes to be a valid object key
|
|
128
127
|
});
|
|
129
128
|
} else {
|
|
130
129
|
context.report({
|
|
131
130
|
node: prop.key,
|
|
132
131
|
messageId: "invalidStyleProp",
|
|
133
|
-
data: { name }
|
|
132
|
+
data: { name }
|
|
134
133
|
});
|
|
135
134
|
}
|
|
136
135
|
} else if (
|
|
@@ -144,13 +143,13 @@ export default {
|
|
|
144
143
|
if (typeof value === "number" && value !== 0) {
|
|
145
144
|
context.report({
|
|
146
145
|
node: prop.value,
|
|
147
|
-
messageId: "numericStyleValue"
|
|
146
|
+
messageId: "numericStyleValue"
|
|
148
147
|
});
|
|
149
148
|
}
|
|
150
149
|
}
|
|
151
150
|
});
|
|
152
151
|
}
|
|
153
|
-
}
|
|
152
|
+
}
|
|
154
153
|
};
|
|
155
|
-
}
|
|
154
|
+
}
|
|
156
155
|
};
|
|
@@ -36,7 +36,7 @@ import { isDOMElementName, jsxGetProp, jsxPropName } from "../utils.mjs";
|
|
|
36
36
|
// `<body>` from a parsed document, used as the parsing context so fragments are
|
|
37
37
|
// interpreted the way `innerHTML` would interpret them.
|
|
38
38
|
const htmlElement = parse(
|
|
39
|
-
"<!DOCTYPE html><html><head></head><body></body></html>"
|
|
39
|
+
"<!DOCTYPE html><html><head></head><body></body></html>"
|
|
40
40
|
).childNodes[1];
|
|
41
41
|
const bodyContext = htmlElement.childNodes[1];
|
|
42
42
|
|
|
@@ -49,7 +49,7 @@ const tableWrappers = {
|
|
|
49
49
|
tfoot: ["table"],
|
|
50
50
|
tr: ["table", "tbody"],
|
|
51
51
|
td: ["table", "tbody", "tr"],
|
|
52
|
-
th: ["table", "tbody", "tr"]
|
|
52
|
+
th: ["table", "tbody", "tr"]
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
// Rows, row groups and the table itself keep a hidden input as a child, any
|
|
@@ -72,7 +72,7 @@ const voidElements = new Set([
|
|
|
72
72
|
"param",
|
|
73
73
|
"source",
|
|
74
74
|
"track",
|
|
75
|
-
"wbr"
|
|
75
|
+
"wbr"
|
|
76
76
|
]);
|
|
77
77
|
|
|
78
78
|
// parse5 lowercases tag names outside SVG, so `<foreignObject>` comes back as
|
|
@@ -111,7 +111,7 @@ const parserRewrites = (parent, child, namespace) => {
|
|
|
111
111
|
: `<${child}></${child}>`;
|
|
112
112
|
const markup = wrappers.reduceRight(
|
|
113
113
|
(content, tag) => `<${tag}>${content}</${tag}>`,
|
|
114
|
-
`<${parent}>${childMarkup}</${parent}
|
|
114
|
+
`<${parent}>${childMarkup}</${parent}>`
|
|
115
115
|
);
|
|
116
116
|
let fragment = documentParent
|
|
117
117
|
? parse(markup).childNodes.find((node) => node.nodeName === "html")
|
|
@@ -120,7 +120,7 @@ const parserRewrites = (parent, child, namespace) => {
|
|
|
120
120
|
fragment = fragment?.childNodes.find((node) => node.nodeName === tag);
|
|
121
121
|
}
|
|
122
122
|
const roots = (fragment?.childNodes ?? []).filter(
|
|
123
|
-
(node) => node.nodeName !== "#text"
|
|
123
|
+
(node) => node.nodeName !== "#text"
|
|
124
124
|
);
|
|
125
125
|
const root = documentParent
|
|
126
126
|
? roots.find((node) => node.nodeName === parent)
|
|
@@ -130,7 +130,7 @@ const parserRewrites = (parent, child, namespace) => {
|
|
|
130
130
|
// `<template>` parks its children in `content`, not `childNodes`.
|
|
131
131
|
const container = root && "content" in root ? root.content : root;
|
|
132
132
|
const kids = (container?.childNodes ?? []).filter(
|
|
133
|
-
(node) => node.nodeName !== "#text"
|
|
133
|
+
(node) => node.nodeName !== "#text"
|
|
134
134
|
);
|
|
135
135
|
|
|
136
136
|
// Foreign content can only clear a report the HTML reading makes, since
|
|
@@ -296,7 +296,7 @@ const foreignContentExits = new Set([
|
|
|
296
296
|
"tt",
|
|
297
297
|
"u",
|
|
298
298
|
"ul",
|
|
299
|
-
"var"
|
|
299
|
+
"var"
|
|
300
300
|
]);
|
|
301
301
|
|
|
302
302
|
// `<font>` leaves foreign content when it has one of these attributes.
|
|
@@ -319,7 +319,7 @@ const switchesToHTML = (element, tag, namespace) => {
|
|
|
319
319
|
return attributes.some(
|
|
320
320
|
(attr) =>
|
|
321
321
|
attr.type === "JSXAttribute" &&
|
|
322
|
-
fontExitAttributes.has(jsxPropName(attr).toLowerCase())
|
|
322
|
+
fontExitAttributes.has(jsxPropName(attr).toLowerCase())
|
|
323
323
|
);
|
|
324
324
|
}
|
|
325
325
|
if (namespace === "svg") {
|
|
@@ -331,7 +331,7 @@ const switchesToHTML = (element, tag, namespace) => {
|
|
|
331
331
|
const encoding = attributes.find(
|
|
332
332
|
(attr) =>
|
|
333
333
|
attr.type === "JSXAttribute" &&
|
|
334
|
-
jsxPropName(attr).toLowerCase() === "encoding"
|
|
334
|
+
jsxPropName(attr).toLowerCase() === "encoding"
|
|
335
335
|
)?.value;
|
|
336
336
|
return (
|
|
337
337
|
encoding?.type === "Literal" &&
|
|
@@ -427,15 +427,15 @@ export default {
|
|
|
427
427
|
docs: {
|
|
428
428
|
description:
|
|
429
429
|
"Disallow HTML nesting the browser refuses to keep, like `<p><div /></p>`, which silently renders a different DOM than the JSX describes.",
|
|
430
|
-
url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/validate-jsx-nesting.md"
|
|
430
|
+
url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/validate-jsx-nesting.md"
|
|
431
431
|
},
|
|
432
432
|
messages: {
|
|
433
433
|
invalidNesting:
|
|
434
434
|
"Invalid HTML nesting: `<{{child}}>` cannot be a child of `<{{parent}}>`. The HTML parser restructures this, so the rendered DOM won't match this markup.",
|
|
435
435
|
invalidNestingInserted:
|
|
436
|
-
"Invalid HTML nesting: `<{{child}}>` cannot be a child of `<{{parent}}>`. The client inserts it as written, but the HTML parser restructures it in server-rendered HTML, so hydration won't match this markup."
|
|
436
|
+
"Invalid HTML nesting: `<{{child}}>` cannot be a child of `<{{parent}}>`. The client inserts it as written, but the HTML parser restructures it in server-rendered HTML, so hydration won't match this markup."
|
|
437
437
|
},
|
|
438
|
-
schema: []
|
|
438
|
+
schema: []
|
|
439
439
|
},
|
|
440
440
|
defaultOptions: [],
|
|
441
441
|
create(context) {
|
|
@@ -468,7 +468,7 @@ export default {
|
|
|
468
468
|
messageId: isInserted(node, parentNode)
|
|
469
469
|
? "invalidNestingInserted"
|
|
470
470
|
: "invalidNesting",
|
|
471
|
-
data: { parent, child }
|
|
471
|
+
data: { parent, child }
|
|
472
472
|
});
|
|
473
473
|
};
|
|
474
474
|
|
|
@@ -483,7 +483,7 @@ export default {
|
|
|
483
483
|
if (parentNode) {
|
|
484
484
|
check(node, child, parentNode);
|
|
485
485
|
}
|
|
486
|
-
}
|
|
486
|
+
}
|
|
487
487
|
};
|
|
488
|
-
}
|
|
488
|
+
}
|
|
489
489
|
};
|
package/src/utils.mjs
CHANGED
|
@@ -5,7 +5,7 @@ const PROPS_REGEX = /[pP]rops/;
|
|
|
5
5
|
const FUNCTION_TYPES = [
|
|
6
6
|
"FunctionExpression",
|
|
7
7
|
"ArrowFunctionExpression",
|
|
8
|
-
"FunctionDeclaration"
|
|
8
|
+
"FunctionDeclaration"
|
|
9
9
|
];
|
|
10
10
|
const PROGRAM_OR_FUNCTION_TYPES = ["Program", ...FUNCTION_TYPES];
|
|
11
11
|
|
|
@@ -162,7 +162,7 @@ export function getCommentAfter(node, sourceCode) {
|
|
|
162
162
|
// the store APIs, while `@solidjs/web`, `@solidjs/h`, `@solidjs/html` and
|
|
163
163
|
// `@solidjs/universal` own the renderers. Match both layouts.
|
|
164
164
|
export function trackImports(
|
|
165
|
-
fromModule = /^(?:solid-js|@solidjs\/[a-z-]+)(?:\/|$)
|
|
165
|
+
fromModule = /^(?:solid-js|@solidjs\/[a-z-]+)(?:\/|$)/
|
|
166
166
|
) {
|
|
167
167
|
const importMap = new Map();
|
|
168
168
|
|
|
@@ -187,7 +187,7 @@ export function trackImports(
|
|
|
187
187
|
|
|
188
188
|
return {
|
|
189
189
|
handleImportDeclaration,
|
|
190
|
-
matchImport
|
|
190
|
+
matchImport
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
193
|
|
|
@@ -214,7 +214,7 @@ export function appendImports(fixer, sourceCode, importNode, identifiers) {
|
|
|
214
214
|
) {
|
|
215
215
|
return fixer.insertTextAfter(
|
|
216
216
|
importNode,
|
|
217
|
-
`\nimport ${importNode.importKind === "type" ? "type " : ""}{ ${identifiersString} } from ${sourceCode.getText(importNode.source)}
|
|
217
|
+
`\nimport ${importNode.importKind === "type" ? "type " : ""}{ ${identifiersString} } from ${sourceCode.getText(importNode.source)};`
|
|
218
218
|
);
|
|
219
219
|
}
|
|
220
220
|
|
|
@@ -225,7 +225,7 @@ export function appendImports(fixer, sourceCode, importNode, identifiers) {
|
|
|
225
225
|
if (defaultSpecifier) {
|
|
226
226
|
return fixer.insertTextAfter(
|
|
227
227
|
defaultSpecifier,
|
|
228
|
-
`, { ${identifiersString} }
|
|
228
|
+
`, { ${identifiersString} }`
|
|
229
229
|
);
|
|
230
230
|
}
|
|
231
231
|
|
|
@@ -233,8 +233,8 @@ export function appendImports(fixer, sourceCode, importNode, identifiers) {
|
|
|
233
233
|
const [importToken, maybeBrace] = sourceCode.getFirstTokens(
|
|
234
234
|
importNode,
|
|
235
235
|
{
|
|
236
|
-
count: 2
|
|
237
|
-
}
|
|
236
|
+
count: 2
|
|
237
|
+
}
|
|
238
238
|
);
|
|
239
239
|
|
|
240
240
|
if (maybeBrace?.value === "{") {
|
|
@@ -244,7 +244,7 @@ export function appendImports(fixer, sourceCode, importNode, identifiers) {
|
|
|
244
244
|
return importToken
|
|
245
245
|
? fixer.insertTextAfter(
|
|
246
246
|
importToken,
|
|
247
|
-
` { ${identifiersString} } from
|
|
247
|
+
` { ${identifiersString} } from`
|
|
248
248
|
)
|
|
249
249
|
: null;
|
|
250
250
|
}
|
|
@@ -258,7 +258,7 @@ export function insertImports(
|
|
|
258
258
|
source,
|
|
259
259
|
identifiers,
|
|
260
260
|
aboveImport,
|
|
261
|
-
isType = false
|
|
261
|
+
isType = false
|
|
262
262
|
) {
|
|
263
263
|
const identifiersString = identifiers.join(", ");
|
|
264
264
|
const programNode = sourceCode.ast;
|
|
@@ -271,7 +271,7 @@ export function insertImports(
|
|
|
271
271
|
if (firstImport) {
|
|
272
272
|
return fixer.insertTextBeforeRange(
|
|
273
273
|
(getCommentBefore(firstImport, sourceCode) ?? firstImport).range,
|
|
274
|
-
`import ${isType ? "type " : ""}{ ${identifiersString} } from "${source}";\n
|
|
274
|
+
`import ${isType ? "type " : ""}{ ${identifiersString} } from "${source}";\n`
|
|
275
275
|
);
|
|
276
276
|
}
|
|
277
277
|
|
|
@@ -286,7 +286,7 @@ export function insertImports(
|
|
|
286
286
|
return fixer.insertTextBeforeRange(
|
|
287
287
|
(getCommentBefore(firstStatement, sourceCode) ?? firstStatement)
|
|
288
288
|
.range,
|
|
289
|
-
importText
|
|
289
|
+
importText
|
|
290
290
|
);
|
|
291
291
|
}
|
|
292
292
|
|
|
@@ -308,11 +308,11 @@ export function removeSpecifier(fixer, sourceCode, specifier, pure = true) {
|
|
|
308
308
|
if (maybeComma?.value === ",") {
|
|
309
309
|
// The space after the comma goes too, or `{ a, b }` turns into `{ b }`.
|
|
310
310
|
const spaceAfter = /^\s*/u.exec(
|
|
311
|
-
sourceCode.text.slice(maybeComma.range[1])
|
|
311
|
+
sourceCode.text.slice(maybeComma.range[1])
|
|
312
312
|
);
|
|
313
313
|
return fixer.removeRange([
|
|
314
314
|
specifier.range[0],
|
|
315
|
-
maybeComma.range[1] + (spaceAfter?.[0].length ?? 0)
|
|
315
|
+
maybeComma.range[1] + (spaceAfter?.[0].length ?? 0)
|
|
316
316
|
]);
|
|
317
317
|
}
|
|
318
318
|
|
|
@@ -322,7 +322,7 @@ export function removeSpecifier(fixer, sourceCode, specifier, pure = true) {
|
|
|
322
322
|
if (maybeCommaBefore?.value === ",") {
|
|
323
323
|
return fixer.removeRange([
|
|
324
324
|
maybeCommaBefore.range[0],
|
|
325
|
-
specifier.range[1]
|
|
325
|
+
specifier.range[1]
|
|
326
326
|
]);
|
|
327
327
|
}
|
|
328
328
|
|