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

Unsupported CSS preprocessors are interpreted as raw CSS #284

Open
neillrobson opened this issue Jun 29, 2023 · 0 comments
Open

Unsupported CSS preprocessors are interpreted as raw CSS #284

neillrobson opened this issue Jun 29, 2023 · 0 comments

Comments

@neillrobson
Copy link

Summary

When using an unsupported CSS preprocessor, such as LESS CSS, the plugin defaults to interpreting the stylesheet as raw CSS. This configuration can lead to false positives with misleading error messages in ESLint violation reports.

Example

Given the following template:

<template>
    <div class="foo"><div class="foo-bar" /></div>
</template>
<style scoped lang="less">
.foo {
  &-bar {
  }
}
</style>

A warning against vue-scoped-css/no-unused-selectors will pop up, with the message "The selector .foo-bar is unused."

Although it appears that the plugin is interpreting the stylesheet properly, it is in fact treating .foo and -bar as two distinct VCSSClassSelector nodes. They have no whitespace (" ") VCSSSelectorCombinator in between them, creating the misleading warning message.

The correct LESS interpretation of the above template would be .foo-bar as a single VCSSClassSelector node.

Recommendation

Rather than defaulting to the raw CSSSelectorResolver when any unrecognized stylesheet format is encountered (link to relevant code), the plugin should refrain from parsing those stylesheets altogether. Potentially, it should also log the presence of the problematic stylesheets for debugging purposes, outside of any ESLint warning/error infrastructure.

The raw CSSSelectorResolver should only be used when the lang="" attribute is not specified at all on a given <style> block.

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

1 participant