@so1ve/eslint-plugin 0.71.5 → 0.71.7
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/dist/index.cjs +14 -4
- package/dist/index.mjs +14 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -75,8 +75,12 @@ const noInlineTypeImport = createEslintRule({
|
|
|
75
75
|
return {
|
|
76
76
|
ImportDeclaration: (node) => {
|
|
77
77
|
const specifiers = node.specifiers;
|
|
78
|
-
const typeSpecifiers = specifiers.filter(
|
|
79
|
-
|
|
78
|
+
const typeSpecifiers = specifiers.filter(
|
|
79
|
+
(s) => s.type === "ImportSpecifier" && s.importKind === "type"
|
|
80
|
+
);
|
|
81
|
+
const valueSpecifiers = specifiers.filter(
|
|
82
|
+
(s) => s.type === "ImportSpecifier" && s.importKind === "value"
|
|
83
|
+
);
|
|
80
84
|
if (typeSpecifiers.length > 0 && valueSpecifiers.length > 0) {
|
|
81
85
|
context.report({
|
|
82
86
|
loc: node.loc,
|
|
@@ -97,7 +101,10 @@ import { ${valueSpecifiersText} } from "${node.source.value}";`
|
|
|
97
101
|
messageId: "noInlineTypeImport",
|
|
98
102
|
*fix(fixer) {
|
|
99
103
|
const typeSpecifiersText = typeSpecifiers.map((s) => sourceCode.getText(s).replace("type ", "")).join(", ");
|
|
100
|
-
yield fixer.replaceText(
|
|
104
|
+
yield fixer.replaceText(
|
|
105
|
+
node,
|
|
106
|
+
`import type { ${typeSpecifiersText} } from "${node.source.value}";`
|
|
107
|
+
);
|
|
101
108
|
}
|
|
102
109
|
});
|
|
103
110
|
}
|
|
@@ -133,7 +140,10 @@ const noUselessTemplateString = createEslintRule({
|
|
|
133
140
|
fix(fixer) {
|
|
134
141
|
const s = node.range[0];
|
|
135
142
|
const e = node.range[1];
|
|
136
|
-
return fixer.replaceTextRange(
|
|
143
|
+
return fixer.replaceTextRange(
|
|
144
|
+
[s, e],
|
|
145
|
+
`"${node.quasis[0].value.raw}"`
|
|
146
|
+
);
|
|
137
147
|
}
|
|
138
148
|
});
|
|
139
149
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -73,8 +73,12 @@ const noInlineTypeImport = createEslintRule({
|
|
|
73
73
|
return {
|
|
74
74
|
ImportDeclaration: (node) => {
|
|
75
75
|
const specifiers = node.specifiers;
|
|
76
|
-
const typeSpecifiers = specifiers.filter(
|
|
77
|
-
|
|
76
|
+
const typeSpecifiers = specifiers.filter(
|
|
77
|
+
(s) => s.type === "ImportSpecifier" && s.importKind === "type"
|
|
78
|
+
);
|
|
79
|
+
const valueSpecifiers = specifiers.filter(
|
|
80
|
+
(s) => s.type === "ImportSpecifier" && s.importKind === "value"
|
|
81
|
+
);
|
|
78
82
|
if (typeSpecifiers.length > 0 && valueSpecifiers.length > 0) {
|
|
79
83
|
context.report({
|
|
80
84
|
loc: node.loc,
|
|
@@ -95,7 +99,10 @@ import { ${valueSpecifiersText} } from "${node.source.value}";`
|
|
|
95
99
|
messageId: "noInlineTypeImport",
|
|
96
100
|
*fix(fixer) {
|
|
97
101
|
const typeSpecifiersText = typeSpecifiers.map((s) => sourceCode.getText(s).replace("type ", "")).join(", ");
|
|
98
|
-
yield fixer.replaceText(
|
|
102
|
+
yield fixer.replaceText(
|
|
103
|
+
node,
|
|
104
|
+
`import type { ${typeSpecifiersText} } from "${node.source.value}";`
|
|
105
|
+
);
|
|
99
106
|
}
|
|
100
107
|
});
|
|
101
108
|
}
|
|
@@ -131,7 +138,10 @@ const noUselessTemplateString = createEslintRule({
|
|
|
131
138
|
fix(fixer) {
|
|
132
139
|
const s = node.range[0];
|
|
133
140
|
const e = node.range[1];
|
|
134
|
-
return fixer.replaceTextRange(
|
|
141
|
+
return fixer.replaceTextRange(
|
|
142
|
+
[s, e],
|
|
143
|
+
`"${node.quasis[0].value.raw}"`
|
|
144
|
+
);
|
|
135
145
|
}
|
|
136
146
|
});
|
|
137
147
|
}
|