-
-
Notifications
You must be signed in to change notification settings - Fork 696
fix(no-import-compiler-macros): check only in <script setup>
#2938
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
base: master
Are you sure you want to change the base?
fix(no-import-compiler-macros): check only in <script setup>
#2938
Conversation
🦋 Changeset detectedLatest commit: f1e1ddb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
<script setup>
<script setup>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's true that Vue emits the runtime warning only in <script setup>
, but I think that is because the compiler macros are only available in <script setup>
. So while it would be more correct for the ESLint rule to only report compiler macro imports in <script setup>
, it would not really make sense to import them outside <script setup>
, too, would it?
That was my guess too. But they can be wrongly imported by the user. Updated the tests 👍 |
But the Do you agree? If so, feel free to update the PR to only improve test coverage for the non- |
I would prefer an own error/diagnostic message for using compiler macros outside Vue files.
|
waiting for the PR result of vuejs/eslint-plugin-vue#2938 related #11440 https://eslint.vuejs.org/rules/no-import-compiler-macros
After reading #2437, I found out that the compiler warnings are only reported at
<script setup>
:https://github.com/vuejs/core/blob/c16f8a94c7eda79f51f44b7b3c64c72343df0d38/packages/compiler-sfc/src/compileScript.ts#L321-L355
Changed the rule to only look inside
<script setup>
and not other files likesomeMacro.ts
.Copied the logic from
eslint-plugin-vue/lib/rules/valid-define-emits.js
Lines 31 to 46 in 553abe6