eslint-plugin-vue-scoped-css
eslint-plugin-vue-scoped-css is ESLint plugin for Scoped CSS in Vue.js.
Features
This ESLint plugin provides linting rules relate to better ways to help you avoid problems when using Scoped CSS in Vue.js.
- Provides linting rules for Scoped CSS.
- Supports CSS syntax including level 4 selectors.
- Supports
<style lang="scss">
. - Supports
<style lang="stylus">
. - Parses
<style>
,<template>
and<script>
blocks.
You can check on the Online DEMO.
Documentation
See documents.
Installation
npm install --save-dev eslint eslint-plugin-vue-scoped-css
Requirements
- ESLint v5.0.0 and above
- Node.js v8.10.0 and above
Usage
Create .eslintrc.*
file to configure rules. See also: http://eslint.org/docs/user-guide/configuring.
Example .eslintrc.js:
module.exports = {
extends: [
// add more generic rulesets here, such as:
// 'eslint:recommended',
'plugin:vue-scoped-css/recommended'
],
rules: {
// override/add rules settings here, such as:
// 'vue-scoped-css/no-unused-selector': 'error'
}
}
Configs
This plugin provides 3 predefined configs:
-
plugin:vue-scoped-css/base
- Settings and rules to enable this plugin -
plugin:vue-scoped-css/recommended
- Above, plus rules for better ways to help you avoid problems -
plugin:vue-scoped-css/all
- All rules of this plugin are included
Rules
The --fix
option on the command line automatically fixes problems reported by rules which have a wrench
Recommended
Enforce all the rules in this category with:
{
"extends": "plugin:vue-scoped-css/recommended"
}
Rule ID | Description | |
---|---|---|
vue-scoped-css/no-parsing-error | Disallow parsing errors in <style>
|
|
vue-scoped-css/no-unused-keyframes | Reports the @keyframes is not used in Scoped CSS. |
|
vue-scoped-css/no-unused-selector | Reports selectors defined in Scoped CSS not used in <template> . |
|
vue-scoped-css/require-scoped | Enforce the <style> tags to has the scoped attribute. |
Uncategorized
No preset enables the rules in this category. Please enable each rule if you want.
For example:
{
"rules": {
"vue-scoped-css/require-selector-used-inside": "error"
}
}
Rule ID | Description | |
---|---|---|
vue-scoped-css/require-selector-used-inside | Reports the defined selectors is not used inside <template> . |
Contributing
Welcome contributing!
Please use GitHub's Issues/PRs.
Development Tools
-
npm test
runs tests and measures coverage. -
npm run update
runs in order to update readme and recommended configuration.
License
See the LICENSE file for license rights and limitations (MIT).