Skip to content

Comments

feat(vue3): add script-setup releated rules#1064

Merged
susnux merged 1 commit intomainfrom
feat/vue-2
Jun 5, 2025
Merged

feat(vue3): add script-setup releated rules#1064
susnux merged 1 commit intomainfrom
feat/vue-2

Conversation

@susnux
Copy link
Contributor

@susnux susnux commented Jun 4, 2025

When using <script setup> we should directly use the modern approach using defineOptions also we should have a defined order so its easier to navigate in components.

@ShGKme as you are probably one of the heavy script-setup users, thats also the order in talk desktop right?

@susnux susnux requested a review from ShGKme June 4, 2025 22:47
@susnux susnux added enhancement New feature or request 3. to review labels Jun 4, 2025
Comment on lines 37 to 47
'error', {
order: [
'defineOptions',
'defineModel',
'defineProps',
'defineEmits',
'defineSlots',
'defineExpose',
],
},
],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about defineExposeLast: true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a difference?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. defineExposeLast: true moves defineExpose to the end of the entire script setup:

  • Syntactically correct for exposing arrow function and variables
  • Feels like (exposing after everything is defined), like with exports

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the common way to group it yes. For me it feels easier to see everything API (props, events, slots, exposed) in the beginning and only if you are interested in the implementation scroll down to the definitions.

exposing arrow function and variables

IMHO you should just use function, but if variable can (and are) exposed sometimes it makes sense to move it down.

So no strong opinion on this, would do what you think is the common thing in Vue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would do what you think is the common thing in Vue

I thought that it was a common thing to put it to the end, but it is not defaulted in this eslint rule

Example: usage in the vue docs

When using `<script setup>` we should directly use the modern approach
using `defineOptions` also we should have a defined order so its easier
to navigate in components.

Signed-off-by: Ferdinand Thiessen <[email protected]>
@susnux susnux requested a review from ShGKme June 5, 2025 08:06
@susnux susnux merged commit 73b411d into main Jun 5, 2025
7 checks passed
@susnux susnux deleted the feat/vue-2 branch June 5, 2025 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants