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

GlobalComponents + 'vue/component-name-in-template-casing' #562

Open
3 tasks done
chenyulun opened this issue Jul 23, 2024 · 5 comments
Open
3 tasks done

GlobalComponents + 'vue/component-name-in-template-casing' #562

chenyulun opened this issue Jul 23, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@chenyulun
Copy link

Clear and concise description of the problem

全局的组件,有没有办法要求使用的时候必须PascalCase
全局注入的组件是unplugin-vue-components自动注入的,但是没办法限制组件里面的写法必须是PascalCase
有生成typescript的声明文件components.d.ts

Suggested solution

unplugin-vue-components联动一下,能识别全局组件

Alternative

No response

Additional context

No response

Validations

@chenyulun chenyulun added the enhancement New feature or request label Jul 23, 2024
@chenyulun
Copy link
Author

@antfu
Copy link
Owner

antfu commented Jul 23, 2024

I don't know how much it's possible to support in ESLint, but I am up to having un plugin-vue-components to have a flag that throws errors on building based on the cases of usage.

@chenyulun
Copy link
Author

export default antfu({
rules: {
    'vue/component-name-in-template-casing': ['error', 'PascalCase', {
      registeredComponentsOnly: false,
      ignores: []
    }]
  }
})

Use this rule for now, if there are additional additions to the ignores array

@chenyulun
Copy link
Author

This approach may incorrectly recognize non-global components or webcomponents components and incorrectly format them as PascalCase
I don't think it's a big problem. I'll use it for now.

@chenyulun
Copy link
Author

It is recommended that unplugin-vue-components outputs a list of component JSON, and then vue/component-name-in-template-casing support imports the list of components that need to be inspected

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

No branches or pull requests

2 participants