Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(prefer-import-from-vue): skip side-effect import in .d.ts files #1907

Merged
merged 3 commits into from May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/rules/prefer-import-from-vue.js
Expand Up @@ -94,6 +94,13 @@ module.exports = {

return {
ImportDeclaration(node) {
// Skip imports without specifiers in `.d.ts` files
if (
node.specifiers.length === 0 &&
context.getFilename().endsWith('.d.ts')
)
return

verifySource(node.source, () => {
if (SUBSET_AT_VUE_MODULES.has(node.source.value)) {
// If the module is a subset of 'vue', we can safely change it to 'vue'.
Expand Down
6 changes: 5 additions & 1 deletion tests/lib/rules/prefer-import-from-vue.js
Expand Up @@ -22,7 +22,11 @@ tester.run('prefer-import-from-vue', rule, {
`export * from 'vue'`,
`import Foo from 'foo'`,
`import { createApp } from 'vue'
export { createApp }`
export { createApp }`,
{
filename: 'test.d.ts',
code: `import '@vue/runtime-dom'`
}
],
invalid: [
{
Expand Down