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

Rule Proposal: vue/top-level-function-style-in-script-setup #2677

Open
ntnyq opened this issue Feb 5, 2025 · 1 comment
Open

Rule Proposal: vue/top-level-function-style-in-script-setup #2677

ntnyq opened this issue Feb 5, 2025 · 1 comment

Comments

@ntnyq
Copy link
Contributor

ntnyq commented Feb 5, 2025

Please describe what the rule should do:

Enforce a consistent style to declare functions in script setup.

What category should the rule belong to?

[x] Enforces code style (layout)
[ ] Warns about a potential error (problem)
[ ] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)

Provide 2-3 code examples that this rule should warn about:

Option declaration:

<!-- Good -->
<script setup>
function foobar () {}
</script>

<!-- Bad -->
<script setup>
const foo = () => {}
const bar = function () {}
</script>
import { defineComponent } from 'vue'

<!-- Good -->
export default defineComponent ({
  setup() {
    function foobar () {}
    return {
      foobar
    }
  }
})

<!-- Bad -->
export default defineComponent ({
  setup() {
    const foo = () => {}
    const bar = function () {}
    return {
      foo,
      bar,
    }
  }
})

Additional context

Other options:

  • arrow

Refs:

@FloEdelmann
Copy link
Member

FloEdelmann commented Feb 5, 2025

  1. Why enforce a specific function style? Just for consistency, or are there other reasons?
  2. Why only for top-level functions?
  3. Why only for Vue files, or more specifically only for <script setup> or inside the setup function?

Can the core func-style rule be used instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants