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

vue/order-in-components is not working with defineNuxtComponent() #2057

Closed
2 tasks done
vedmant opened this issue Dec 5, 2022 · 6 comments · Fixed by #2311
Closed
2 tasks done

vue/order-in-components is not working with defineNuxtComponent() #2057

vedmant opened this issue Dec 5, 2022 · 6 comments · Fixed by #2311

Comments

@vedmant
Copy link

vedmant commented Dec 5, 2022

Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have read the FAQ and my problem is not listed.

Tell us about your environment

  • ESLint version: 8.28.0
  • eslint-plugin-vue version: 9.8.0
  • Node version: 16.18.1
  • Operating System: MacOs 12.4 (21F79)

Please show your full configuration:

module.exports = {
  root: true,
  extends: ['@antfu', 'plugin:tailwindcss/recommended'],
  plugins: [
    'tailwindcss',
  ],
  rules: {
    'vue/component-tags-order': ['error', {
      order: ['template', 'script', 'style'],
    }],
    'camelcase': ['warn'],
    'import/newline-after-import': ['warn'],
    'no-unused-vars': ['warn'],
    'vue/no-unused-vars': ['warn'],
    'vue/new-line-between-multi-line-property': ['warn', { minLineOfMultilineProperty: 3 }],
    'tailwindcss/classnames-order': 'warn',
    'tailwindcss/no-custom-classname': 0,
    'tailwindcss/no-contradicting-classname': 'error',
    'vue/order-in-components': ['warn', {
      order: [
        'el',
        'name',
        'key',
        'parent',
        'functional',
        ['delimiters', 'comments'],
        ['components', 'directives', 'filters'],
        'extends',
        'mixins',
        ['provide', 'inject'],
        'ROUTER_GUARDS',
        'layout',
        'middleware',
        'validate',
        'scrollToTop',
        'transition',
        'loading',
        'inheritAttrs',
        'model',
        ['props', 'propsData'],
        'emits',
        'setup',
        'asyncData',
        'data',
        'fetch',
        'computed',
        'watch',
        'watchQuery',
        'LIFECYCLE_HOOKS',
        'methods',
        ['template', 'render'],
        'renderError',
        'head',
      ],
    }],
    '@typescript-eslint/space-before-function-paren': ['error', 'always'],
    '@typescript-eslint/brace-style': ['error', '1tbs', { allowSingleLine: true }],
    'vue/quote-props': ['error', 'as-needed'],
    'curly': ['error', 'all'],
    'no-sequences': 0,
    'max-statements-per-line': ['error', { max: 2 }],
  },
}

What did you do?

<script lang="ts">
import VueJsonPretty from 'vue-json-pretty'
import { mapState } from 'pinia'
import { defineNuxtComponent } from '#imports'
import 'vue-json-pretty/lib/styles.css'
import { useOrderStore } from '~/stores/order'
import { useAuthStore } from '~/stores/auth'

export default defineNuxtComponent({
  components: { VueJsonPretty },

  computed: {
    ...mapState(useAuthStore, ['user']),
    ...mapState(useOrderStore, { order: 'data' }),
  },

  data: () => ({
    tab: 'details',
    tabs: {
      details: {
        title: 'Details',
      },

      receipt: {
        title: 'Receipt',
      },
    },
  }),

  head () {
    return {
      title: 'Receipt',
    }
  },
})
</script>

What did you expect to happen?

It should show warning on line data: () => ({

It shows it if I replace defineNuxtComponent with defineComponent
"ESLint: The "data" property should be above the "computed" property on line 22.(vue/order-in-components)"

What actually happened?

No warning.

Repository to reproduce this issue

Reproduction:
https://stackblitz.com/edit/github-amdjq7?file=pages/should-warning-but-doesnt.vue
run yarn lint in console

@ota-meshi
Copy link
Member

What is defineNuxtComponent? Could you please explain?
Also, please share a repository that can reproduce your issue.

@vedmant
Copy link
Author

vedmant commented Dec 6, 2022

@ota-meshi defineNuxtComponent is a Nuxt 3 wrapper for defineComponent https://nuxt.com/docs/api/utils/define-nuxt-component#definenuxtcomponent, here is reproduction https://stackblitz.com/edit/github-amdjq7?file=pages/should-warning-but-doesnt.vue run yarn lint in console

@ota-meshi
Copy link
Member

ota-meshi commented Dec 6, 2022

The documentation doesn't mention import { defineNuxtComponent } from '#imports'. What is it?
Why can't you use defineComponent instead of defineNuxtComponent?

@vedmant
Copy link
Author

vedmant commented Dec 6, 2022

@ota-meshi This import is optional, I prefer more explicit imports.

@Sapphire2k
Copy link

actually, the problem maybe caused by

...mapState(useAuthStore, ['user']),
...mapState(useOrderStore, { order: 'data' }),

removed it and fix will work fine

@FloEdelmann
Copy link
Member

Will be fixed in v10.

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

Successfully merging a pull request may close this issue.

4 participants