-
-
Notifications
You must be signed in to change notification settings - Fork 571
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
ESLint is not working for auto-imported ref
and computed
#2678
Labels
Comments
Start a new pull request in StackBlitz Codeflow. |
This was referenced Mar 11, 2024
Example shell script to insert import statements (this is for fish shell): for i in (find . -name '*.ts')
sed -i "1 i\import { ref, computed, watch, watchEffect, shallowRef } from 'vue'" $i
end for i in (find . -name '*.vue')
sed -E -i "s/(<script setup.+)/\1\nimport { ref, computed, watch, watchEffect, shallowRef } from 'vue'/" $i
end |
/cc @antfu |
Ah, good catch. I think it would be good if auto imports supports this rule somehow, it feels important for Vue projects in general. Let's wait to see if @antfu has some ideas. |
PR's here vuejs/eslint-plugin-vue#2422 |
userquin
added
bug: upstream
and removed
s: pending triage
Pending Triage
c: bug
Something isn't working
labels
Mar 12, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Elk's ESLint config has rules for
ref
andcomputed
such as vue/return-in-computed-property and vue/no-ref-as-operand. These rules can prevent errors like missing.value
.But currently
eslint-plugin-vue
doesn't support them for auto-importedref
andcomputed
yet (ref. vuejs/eslint-plugin-vue#1969).As a workaround, we can temporarily insert the import statement like
import { ref, computed, watch, watchEffect, shallowRef } from 'vue'
to every*.vue
and*.ts
files with the following temporary config adjustment.(Note:
**/*.ts
was needed to enable vue-related rules other than*.vue
file likecomposables/masto/search.ts
. And the bottom ones fromsort-imports
tots/no-redeclare
is just to ignore temporary import statements.)To fix this issue, we'll need to wait for the upstream fix.
The text was updated successfully, but these errors were encountered: