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: sfc-language #1458

Closed
gewoonwoutje opened this issue Mar 11, 2021 · 3 comments · Fixed by #1586
Closed

Rule Proposal: sfc-language #1458

gewoonwoutje opened this issue Mar 11, 2021 · 3 comments · Fixed by #1586

Comments

@gewoonwoutje
Copy link

gewoonwoutje commented Mar 11, 2021

Please describe what the rule should do:

Limit the languages used in all Vue SFC files for template, script and style blocks.

What category should the rule belong to?

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

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

{
   "script": "ts",
// "style": "scss",
// "template": "whatever",
}
// SomeComponent.vue

// Error: Missing attribute `lang="ts"`
<script>
// Error: Wrong lang attribute, expected `lang="ts"`
<script lang="js">

// Correct
<script lang="ts">

Additional context

We're using Typescript and Vue SFC files, but it is very easy to create a new component file and forget to add a lang="ts" attribute to the script tag, and missing out on some type checking.

We also use <style lang="scss">.

@mauriciabad
Copy link

mauriciabad commented Jun 14, 2021

I find it very useful, I'd definitely use it.

@gewoonwoutje
Copy link
Author

I looked around a while ago to see if it was feasible for me to implement this. It seems this would require more information from the vue parser, as there is little info of the top level tag attributes <script> <template> <style>.

@ota-meshi is that a correct finding?

@scriptcoded
Copy link

Came here looking for a solution to this very "problem". I think if this were to be implemented it could be a good idea to allow for multiple languages to be configured per block. Say for example you use both SCSS and CSS.

{
  "script": ["scss", "css"]
}

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

Successfully merging a pull request may close this issue.

3 participants