Skip to content

Commit c1c9dc2

Browse files
antfuota-meshi
andauthored
fix(prefer-import-from-vue): skip side-effect import in .d.ts files (#1907)
* fix(prefer-import-from-vue): skip side-effect import * fix: only skip in .d.ts * Update tests/lib/rules/prefer-import-from-vue.js Co-authored-by: Yosuke Ota <[email protected]> Co-authored-by: Yosuke Ota <[email protected]>
1 parent 35bf100 commit c1c9dc2

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/rules/prefer-import-from-vue.js

+7
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ module.exports = {
9494

9595
return {
9696
ImportDeclaration(node) {
97+
// Skip imports without specifiers in `.d.ts` files
98+
if (
99+
node.specifiers.length === 0 &&
100+
context.getFilename().endsWith('.d.ts')
101+
)
102+
return
103+
97104
verifySource(node.source, () => {
98105
if (SUBSET_AT_VUE_MODULES.has(node.source.value)) {
99106
// If the module is a subset of 'vue', we can safely change it to 'vue'.

tests/lib/rules/prefer-import-from-vue.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ tester.run('prefer-import-from-vue', rule, {
2222
`export * from 'vue'`,
2323
`import Foo from 'foo'`,
2424
`import { createApp } from 'vue'
25-
export { createApp }`
25+
export { createApp }`,
26+
{
27+
filename: 'test.d.ts',
28+
code: `import '@vue/runtime-dom'`
29+
}
2630
],
2731
invalid: [
2832
{

0 commit comments

Comments
 (0)