@so1ve/eslint-plugin 0.36.0 → 0.36.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/dist/index.cjs +10 -1
- package/dist/index.mjs +10 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -429,6 +429,7 @@ const noInlineTypeImport = createEslintRule({
|
|
|
429
429
|
},
|
|
430
430
|
defaultOptions: [],
|
|
431
431
|
create: (context) => {
|
|
432
|
+
const sourceCode = context.getSourceCode();
|
|
432
433
|
return {
|
|
433
434
|
ImportDeclaration: (node) => {
|
|
434
435
|
const specifiers = node.specifiers;
|
|
@@ -439,13 +440,21 @@ const noInlineTypeImport = createEslintRule({
|
|
|
439
440
|
loc: node.loc,
|
|
440
441
|
messageId: "noInlineTypeImport",
|
|
441
442
|
*fix(fixer) {
|
|
442
|
-
const sourceCode = context.getSourceCode();
|
|
443
443
|
const typeSpecifiersText = typeSpecifiers.map((s) => sourceCode.getText(s).replace("type ", "")).join(", ");
|
|
444
444
|
const valueSpecifiersText = valueSpecifiers.map((s) => sourceCode.getText(s)).join(", ");
|
|
445
445
|
yield fixer.replaceText(node, `import type { ${typeSpecifiersText} } from "${node.source.value}";
|
|
446
446
|
import { ${valueSpecifiersText} } from "${node.source.value}";`);
|
|
447
447
|
}
|
|
448
448
|
});
|
|
449
|
+
} else if (typeSpecifiers.length) {
|
|
450
|
+
context.report({
|
|
451
|
+
loc: node.loc,
|
|
452
|
+
messageId: "noInlineTypeImport",
|
|
453
|
+
*fix(fixer) {
|
|
454
|
+
const typeSpecifiersText = typeSpecifiers.map((s) => sourceCode.getText(s).replace("type ", "")).join(", ");
|
|
455
|
+
yield fixer.replaceText(node, `import type { ${typeSpecifiersText} } from "${node.source.value}";`);
|
|
456
|
+
}
|
|
457
|
+
});
|
|
449
458
|
}
|
|
450
459
|
}
|
|
451
460
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -427,6 +427,7 @@ const noInlineTypeImport = createEslintRule({
|
|
|
427
427
|
},
|
|
428
428
|
defaultOptions: [],
|
|
429
429
|
create: (context) => {
|
|
430
|
+
const sourceCode = context.getSourceCode();
|
|
430
431
|
return {
|
|
431
432
|
ImportDeclaration: (node) => {
|
|
432
433
|
const specifiers = node.specifiers;
|
|
@@ -437,13 +438,21 @@ const noInlineTypeImport = createEslintRule({
|
|
|
437
438
|
loc: node.loc,
|
|
438
439
|
messageId: "noInlineTypeImport",
|
|
439
440
|
*fix(fixer) {
|
|
440
|
-
const sourceCode = context.getSourceCode();
|
|
441
441
|
const typeSpecifiersText = typeSpecifiers.map((s) => sourceCode.getText(s).replace("type ", "")).join(", ");
|
|
442
442
|
const valueSpecifiersText = valueSpecifiers.map((s) => sourceCode.getText(s)).join(", ");
|
|
443
443
|
yield fixer.replaceText(node, `import type { ${typeSpecifiersText} } from "${node.source.value}";
|
|
444
444
|
import { ${valueSpecifiersText} } from "${node.source.value}";`);
|
|
445
445
|
}
|
|
446
446
|
});
|
|
447
|
+
} else if (typeSpecifiers.length) {
|
|
448
|
+
context.report({
|
|
449
|
+
loc: node.loc,
|
|
450
|
+
messageId: "noInlineTypeImport",
|
|
451
|
+
*fix(fixer) {
|
|
452
|
+
const typeSpecifiersText = typeSpecifiers.map((s) => sourceCode.getText(s).replace("type ", "")).join(", ");
|
|
453
|
+
yield fixer.replaceText(node, `import type { ${typeSpecifiersText} } from "${node.source.value}";`);
|
|
454
|
+
}
|
|
455
|
+
});
|
|
447
456
|
}
|
|
448
457
|
}
|
|
449
458
|
};
|