Socket
Socket
Sign inDemoInstall

eslint-plugin-vue

Package Overview
Dependencies
Maintainers
3
Versions
170
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-vue - npm Package Compare versions

Comparing version 3.10.0 to 3.11.0

lib/rules/html-self-closing.js

46

lib/recommended-rules.js

@@ -11,2 +11,3 @@ /*

"vue/html-quotes": "off",
"vue/html-self-closing": "off",
"vue/jsx-uses-vars": "error",

@@ -18,16 +19,16 @@ "vue/name-property-casing": "off",

"vue/no-duplicate-attributes": "off",
"vue/no-invalid-template-root": "error",
"vue/no-invalid-v-bind": "error",
"vue/no-invalid-v-cloak": "error",
"vue/no-invalid-v-else-if": "error",
"vue/no-invalid-v-else": "error",
"vue/no-invalid-v-for": "error",
"vue/no-invalid-v-html": "error",
"vue/no-invalid-v-if": "error",
"vue/no-invalid-v-model": "error",
"vue/no-invalid-v-on": "error",
"vue/no-invalid-v-once": "error",
"vue/no-invalid-v-pre": "error",
"vue/no-invalid-v-show": "error",
"vue/no-invalid-v-text": "error",
"vue/no-invalid-template-root": "off",
"vue/no-invalid-v-bind": "off",
"vue/no-invalid-v-cloak": "off",
"vue/no-invalid-v-else-if": "off",
"vue/no-invalid-v-else": "off",
"vue/no-invalid-v-for": "off",
"vue/no-invalid-v-html": "off",
"vue/no-invalid-v-if": "off",
"vue/no-invalid-v-model": "off",
"vue/no-invalid-v-on": "off",
"vue/no-invalid-v-once": "off",
"vue/no-invalid-v-pre": "off",
"vue/no-invalid-v-show": "off",
"vue/no-invalid-v-text": "off",
"vue/no-parsing-error": "error",

@@ -44,5 +45,20 @@ "vue/no-reservered-keys": "off",

"vue/require-v-for-key": "error",
"vue/require-valid-default-prop": "off",
"vue/return-in-computed-property": "off",
"vue/v-bind-style": "off",
"vue/v-on-style": "off"
"vue/v-on-style": "off",
"vue/valid-template-root": "error",
"vue/valid-v-bind": "error",
"vue/valid-v-cloak": "error",
"vue/valid-v-else-if": "error",
"vue/valid-v-else": "error",
"vue/valid-v-for": "error",
"vue/valid-v-html": "error",
"vue/valid-v-if": "error",
"vue/valid-v-model": "error",
"vue/valid-v-on": "error",
"vue/valid-v-once": "error",
"vue/valid-v-pre": "error",
"vue/valid-v-show": "error",
"vue/valid-v-text": "error"
}

@@ -28,3 +28,3 @@ /**

const name = node.name
const isVoid = utils.isVoidElementName(name)
const isVoid = utils.isHtmlVoidElementName(name)
const hasEndTag = node.endTag != null

@@ -31,0 +31,0 @@

@@ -60,3 +60,3 @@ /**

recommended: false,
replacedBy: []
replacedBy: ['html-self-closing-style']
},

@@ -63,0 +63,0 @@ deprecated: true,

@@ -117,4 +117,6 @@ /**

category: 'Possible Errors',
recommended: true
recommended: false,
replacedBy: ['valid-template-root']
},
deprecated: true,
fixable: false,

@@ -121,0 +123,0 @@ schema: []

@@ -63,4 +63,6 @@ /**

category: 'Possible Errors',
recommended: true
recommended: false,
replacedBy: ['valid-v-bind']
},
deprecated: true,
fixable: false,

@@ -67,0 +69,0 @@ schema: []

@@ -64,4 +64,6 @@ /**

category: 'Possible Errors',
recommended: true
recommended: false,
replacedBy: ['valid-v-cloak']
},
deprecated: true,
fixable: false,

@@ -68,0 +70,0 @@ schema: []

@@ -87,4 +87,6 @@ /**

category: 'Possible Errors',
recommended: true
recommended: false,
replacedBy: ['valid-v-else-if']
},
deprecated: true,
fixable: false,

@@ -91,0 +93,0 @@ schema: []

@@ -87,4 +87,6 @@ /**

category: 'Possible Errors',
recommended: true
recommended: false,
replacedBy: ['valid-v-else']
},
deprecated: true,
fixable: false,

@@ -91,0 +93,0 @@ schema: []

@@ -168,4 +168,6 @@ /**

category: 'Possible Errors',
recommended: true
recommended: false,
replacedBy: ['valid-v-for']
},
deprecated: true,
fixable: false,

@@ -172,0 +174,0 @@ schema: []

@@ -64,4 +64,6 @@ /**

category: 'Possible Errors',
recommended: true
recommended: false,
replacedBy: ['valid-v-html']
},
deprecated: true,
fixable: false,

@@ -68,0 +70,0 @@ schema: []

@@ -80,4 +80,6 @@ /**

category: 'Possible Errors',
recommended: true
recommended: false,
replacedBy: ['valid-v-if']
},
deprecated: true,
fixable: false,

@@ -84,0 +86,0 @@ schema: []

@@ -181,4 +181,6 @@ /**

category: 'Possible Errors',
recommended: true
recommended: false,
replacedBy: ['valid-v-model']
},
deprecated: true,
fixable: false,

@@ -185,0 +187,0 @@ schema: []

@@ -69,4 +69,6 @@ /**

category: 'Possible Errors',
recommended: true
recommended: false,
replacedBy: ['valid-v-on']
},
deprecated: true,
fixable: false,

@@ -73,0 +75,0 @@ schema: []

@@ -64,4 +64,6 @@ /**

category: 'Possible Errors',
recommended: true
recommended: false,
replacedBy: ['valid-v-once']
},
deprecated: true,
fixable: false,

@@ -68,0 +70,0 @@ schema: []

@@ -64,4 +64,6 @@ /**

category: 'Possible Errors',
recommended: true
recommended: false,
replacedBy: ['valid-v-pre']
},
deprecated: true,
fixable: false,

@@ -68,0 +70,0 @@ schema: []

@@ -64,4 +64,6 @@ /**

category: 'Possible Errors',
recommended: true
recommended: false,
replacedBy: ['valid-v-show']
},
deprecated: true,
fixable: false,

@@ -68,0 +70,0 @@ schema: []

@@ -64,4 +64,6 @@ /**

category: 'Possible Errors',
recommended: true
recommended: false,
replacedBy: ['valid-v-text']
},
deprecated: true,
fixable: false,

@@ -68,0 +70,0 @@ schema: []

@@ -23,4 +23,3 @@ /**

utils.getStaticPropertyName(item) === 'render' &&
(item.value.type === 'ArrowFunctionExpression' || item.value.type === 'FunctionExpression') &&
!item.value.expression // render: () => test
(item.value.type === 'ArrowFunctionExpression' || item.value.type === 'FunctionExpression')
)

@@ -30,6 +29,3 @@ if (!node) return

forbiddenNodes.forEach(el => {
if (
el.loc.start.line >= node.value.loc.start.line &&
el.loc.end.line <= node.value.loc.end.line
) {
if (node.value === el) {
context.report({

@@ -36,0 +32,0 @@ node: node.key,

@@ -28,7 +28,3 @@ /**

forbiddenNodes.forEach(el => {
if (
cp.value &&
el.loc.start.line >= cp.value.loc.start.line &&
el.loc.end.line <= cp.value.loc.end.line
) {
if (cp.value && cp.value.parent === el) {
context.report({

@@ -35,0 +31,0 @@ node: el,

@@ -186,3 +186,3 @@ /**

return (
!(this.isKnownHtmlElementNode(node) || this.isSvgElementNode(node) || this.isMathMLElementNode(node)) ||
(this.isHtmlElementNode(node) && !this.isHtmlWellKnownElementName(node.name)) ||
this.hasAttribute(node, 'is') ||

@@ -198,6 +198,6 @@ this.hasDirective(node, 'bind', 'is')

*/
isKnownHtmlElementNode (node) {
isHtmlElementNode (node) {
assert(node && node.type === 'VElement')
return node.namespace === vueEslintParser.AST.NS.HTML && HTML_ELEMENT_NAMES.has(node.name.toLowerCase())
return node.namespace === vueEslintParser.AST.NS.HTML
},

@@ -228,2 +228,13 @@

/**
* Check whether the given name is an well-known element or not.
* @param {string} name The name to check.
* @returns {boolean} `true` if the name is an well-known element name.
*/
isHtmlWellKnownElementName (name) {
assert(typeof name === 'string')
return HTML_ELEMENT_NAMES.has(name.toLowerCase())
},
/**
* Check whether the given name is a void element name or not.

@@ -233,3 +244,3 @@ * @param {string} name The name to check.

*/
isVoidElementName (name) {
isHtmlVoidElementName (name) {
assert(typeof name === 'string')

@@ -438,8 +449,21 @@

const filePath = context.getFilename()
const sourceCode = context.getSourceCode()
const _this = this
const componentComments = sourceCode.getAllComments().filter(comment => /@vue\/component/g.test(comment.value))
const foundNodes = []
const isDuplicateNode = (node) => {
if (foundNodes.some(el => el.loc.start.line === node.loc.start.line)) return true
foundNodes.push(node)
return false
}
return {
ObjectExpression (node) {
if (!componentComments.some(el => el.loc.end.line === node.loc.start.line - 1) || isDuplicateNode(node)) return
cb(node)
},
'ExportDefaultDeclaration:exit' (node) {
// export default {} in .vue || .jsx
if (!_this.isVueComponentFile(node, filePath)) return
if (!_this.isVueComponentFile(node, filePath) || isDuplicateNode(node.declaration)) return
cb(node.declaration)

@@ -449,3 +473,3 @@ },

// Vue.component('xxx', {}) || component('xxx', {})
if (!_this.isVueComponent(node)) return
if (!_this.isVueComponent(node) || isDuplicateNode(node.arguments.slice(-1)[0])) return
cb(node.arguments.slice(-1)[0])

@@ -562,3 +586,3 @@ }

'ArrowFunctionExpression:exit' (node) {
if (!isValidReturn()) {
if (!isValidReturn() && !node.expression) {
cb(funcInfo.node)

@@ -565,0 +589,0 @@ }

{
"name": "eslint-plugin-vue",
"version": "3.10.0",
"version": "3.11.0",
"description": "Official ESLint plugin for Vue.js",

@@ -48,3 +48,3 @@ "main": "lib/index.js",

"requireindex": "^1.1.0",
"vue-eslint-parser": "2.0.0-beta.5"
"vue-eslint-parser": "2.0.0-beta.6"
},

@@ -51,0 +51,0 @@ "devDependencies": {

@@ -34,3 +34,3 @@ # eslint-plugin-vue

```javascript
```js
module.exports = {

@@ -43,3 +43,3 @@ extends: [

// override/add rules' settings here
'vue/no-invalid-v-if': 'error'
'vue/valid-v-if': 'error'
}

@@ -49,4 +49,32 @@ }

## ⚙ Configs
### Attention
All component-related rules are being applied to code that passes any of the following checks:
* `Vue.component()` expression
* `export default {}` in `.vue` or `.jsx` file
If you however want to take advantage of our rules in any of your custom objects that are Vue components, you might need to use special comment `// @vue/component` that marks object in the next line as a Vue component in any file, e.g.:
```js
// @vue/component
const CustomComponent = {
name: 'custom-component',
template: '<div></div>'
}
```
```js
Vue.component('AsyncComponent', (resolve, reject) => {
setTimeout(() => {
// @vue/component
resolve({
name: 'async-component',
template: '<div></div>'
})
}, 500)
})
```
## :gear: Configs
This plugin provides two predefined configs:

@@ -64,15 +92,30 @@ - `plugin:vue/base` - contains necessary settings for this plugin to work properly

Deprecated rules witch should be used with caution and only enabled when you know what you are doing have a warning :warning: icon.
<!--RULES_TABLE_START-->
### Stylistic Issues
### Possible Errors
| | Rule ID | Description |
|:---|:--------|:------------|
| :wrench: | [attribute-hyphenation](./docs/rules/attribute-hyphenation.md) | Define a style for the props casing in templates. |
| | [html-quotes](./docs/rules/html-quotes.md) | enforce quotes style of HTML attributes. |
| :wrench: | [name-property-casing](./docs/rules/name-property-casing.md) | Requires specific casing for the name property in Vue components |
| :wrench: | [v-bind-style](./docs/rules/v-bind-style.md) | enforce `v-bind` directive style. |
| :wrench: | [v-on-style](./docs/rules/v-on-style.md) | enforce `v-on` directive style. |
| | [no-dupe-keys](./docs/rules/no-dupe-keys.md) | Prevents duplication of field names. |
| :white_check_mark: | [no-parsing-error](./docs/rules/no-parsing-error.md) | disallow parsing errors in `<template>`. |
| | [no-reservered-keys](./docs/rules/no-reservered-keys.md) | Prevent overwrite reserved keys. |
| | [no-shared-component-data](./docs/rules/no-shared-component-data.md) | Enforces component's data property to be a function. |
| | [no-template-key](./docs/rules/no-template-key.md) | disallow `key` attribute on `<template>`. |
| | [require-render-return](./docs/rules/require-render-return.md) | Enforces render function to always return value. |
| | [require-valid-default-prop](./docs/rules/require-valid-default-prop.md) | Enforces props default values to be valid. |
| | [return-in-computed-property](./docs/rules/return-in-computed-property.md) | Enforces that a return statement is present in computed property. |
| :white_check_mark: | [valid-template-root](./docs/rules/valid-template-root.md) | enforce valid template root. |
| :white_check_mark: | [valid-v-bind](./docs/rules/valid-v-bind.md) | enforce valid `v-bind` directives. |
| :white_check_mark: | [valid-v-cloak](./docs/rules/valid-v-cloak.md) | enforce valid `v-cloak` directives. |
| :white_check_mark: | [valid-v-else-if](./docs/rules/valid-v-else-if.md) | enforce valid `v-else-if` directives. |
| :white_check_mark: | [valid-v-else](./docs/rules/valid-v-else.md) | enforce valid `v-else` directives. |
| :white_check_mark: | [valid-v-for](./docs/rules/valid-v-for.md) | enforce valid `v-for` directives. |
| :white_check_mark: | [valid-v-html](./docs/rules/valid-v-html.md) | enforce valid `v-html` directives. |
| :white_check_mark: | [valid-v-if](./docs/rules/valid-v-if.md) | enforce valid `v-if` directives. |
| :white_check_mark: | [valid-v-model](./docs/rules/valid-v-model.md) | enforce valid `v-model` directives. |
| :white_check_mark: | [valid-v-on](./docs/rules/valid-v-on.md) | enforce valid `v-on` directives. |
| :white_check_mark: | [valid-v-once](./docs/rules/valid-v-once.md) | enforce valid `v-once` directives. |
| :white_check_mark: | [valid-v-pre](./docs/rules/valid-v-pre.md) | enforce valid `v-pre` directives. |
| :white_check_mark: | [valid-v-show](./docs/rules/valid-v-show.md) | enforce valid `v-show` directives. |
| :white_check_mark: | [valid-v-text](./docs/rules/valid-v-text.md) | enforce valid `v-text` directives. |

@@ -85,3 +128,2 @@

| :wrench: | [html-end-tags](./docs/rules/html-end-tags.md) | enforce end tag style. |
| :wrench::warning: | [html-no-self-closing](./docs/rules/html-no-self-closing.md) | disallow self-closing elements. - (deprecated) |
| | [no-async-in-computed-properties](./docs/rules/no-async-in-computed-properties.md) | Check if there are no asynchronous actions inside computed properties. |

@@ -98,35 +140,43 @@ | :white_check_mark: | [no-confusing-v-for-v-if](./docs/rules/no-confusing-v-for-v-if.md) | disallow confusing `v-for` and `v-if` on the same element. |

### Variables
### Stylistic Issues
| | Rule ID | Description |
|:---|:--------|:------------|
| :white_check_mark: | [jsx-uses-vars](./docs/rules/jsx-uses-vars.md) | Prevent variables used in JSX to be marked as unused |
| :wrench: | [attribute-hyphenation](./docs/rules/attribute-hyphenation.md) | Define a style for the props casing in templates. |
| | [html-quotes](./docs/rules/html-quotes.md) | enforce quotes style of HTML attributes. |
| :wrench: | [html-self-closing](./docs/rules/html-self-closing.md) | enforce self-closing style. |
| :wrench: | [name-property-casing](./docs/rules/name-property-casing.md) | Requires specific casing for the name property in Vue components |
| :wrench: | [v-bind-style](./docs/rules/v-bind-style.md) | enforce `v-bind` directive style. |
| :wrench: | [v-on-style](./docs/rules/v-on-style.md) | enforce `v-on` directive style. |
### Possible Errors
### Variables
| | Rule ID | Description |
|:---|:--------|:------------|
| | [no-dupe-keys](./docs/rules/no-dupe-keys.md) | Prevents duplication of field names. |
| :white_check_mark: | [no-invalid-template-root](./docs/rules/no-invalid-template-root.md) | disallow invalid template root. |
| :white_check_mark: | [no-invalid-v-bind](./docs/rules/no-invalid-v-bind.md) | disallow invalid `v-bind` directives. |
| :white_check_mark: | [no-invalid-v-cloak](./docs/rules/no-invalid-v-cloak.md) | disallow invalid `v-cloak` directives. |
| :white_check_mark: | [no-invalid-v-else-if](./docs/rules/no-invalid-v-else-if.md) | disallow invalid `v-else-if` directives. |
| :white_check_mark: | [no-invalid-v-else](./docs/rules/no-invalid-v-else.md) | disallow invalid `v-else` directives. |
| :white_check_mark: | [no-invalid-v-for](./docs/rules/no-invalid-v-for.md) | disallow invalid `v-for` directives. |
| :white_check_mark: | [no-invalid-v-html](./docs/rules/no-invalid-v-html.md) | disallow invalid `v-html` directives. |
| :white_check_mark: | [no-invalid-v-if](./docs/rules/no-invalid-v-if.md) | disallow invalid `v-if` directives. |
| :white_check_mark: | [no-invalid-v-model](./docs/rules/no-invalid-v-model.md) | disallow invalid `v-model` directives. |
| :white_check_mark: | [no-invalid-v-on](./docs/rules/no-invalid-v-on.md) | disallow invalid `v-on` directives. |
| :white_check_mark: | [no-invalid-v-once](./docs/rules/no-invalid-v-once.md) | disallow invalid `v-once` directives. |
| :white_check_mark: | [no-invalid-v-pre](./docs/rules/no-invalid-v-pre.md) | disallow invalid `v-pre` directives. |
| :white_check_mark: | [no-invalid-v-show](./docs/rules/no-invalid-v-show.md) | disallow invalid `v-show` directives. |
| :white_check_mark: | [no-invalid-v-text](./docs/rules/no-invalid-v-text.md) | disallow invalid `v-text` directives. |
| :white_check_mark: | [no-parsing-error](./docs/rules/no-parsing-error.md) | disallow parsing errors in `<template>`. |
| | [no-reservered-keys](./docs/rules/no-reservered-keys.md) | Prevent overwrite reserved keys. |
| | [no-shared-component-data](./docs/rules/no-shared-component-data.md) | Enforces component's data property to be a function. |
| | [no-template-key](./docs/rules/no-template-key.md) | disallow `key` attribute on `<template>`. |
| | [require-render-return](./docs/rules/require-render-return.md) | Enforces render function to always return value. |
| | [return-in-computed-property](./docs/rules/return-in-computed-property.md) | Enforces that a return statement is present in computed property. |
| :white_check_mark: | [jsx-uses-vars](./docs/rules/jsx-uses-vars.md) | Prevent variables used in JSX to be marked as unused |
### Deprecated
> - :warning: We're going to remove deprecated rules in the next major release. Please migrate to successor/new rules.
> - :innocent: We don't fix bugs which are in deprecated rules since we don't have enough resources.
| Rule ID | Replaced by |
|:--------|:------------|
| [html-no-self-closing](./rules/html-no-self-closing.md) | [html-self-closing-style](./rules/html-self-closing-style.md) |
| [no-invalid-template-root](./rules/no-invalid-template-root.md) | [valid-template-root](./rules/valid-template-root.md) |
| [no-invalid-v-bind](./rules/no-invalid-v-bind.md) | [valid-v-bind](./rules/valid-v-bind.md) |
| [no-invalid-v-cloak](./rules/no-invalid-v-cloak.md) | [valid-v-cloak](./rules/valid-v-cloak.md) |
| [no-invalid-v-else-if](./rules/no-invalid-v-else-if.md) | [valid-v-else-if](./rules/valid-v-else-if.md) |
| [no-invalid-v-else](./rules/no-invalid-v-else.md) | [valid-v-else](./rules/valid-v-else.md) |
| [no-invalid-v-for](./rules/no-invalid-v-for.md) | [valid-v-for](./rules/valid-v-for.md) |
| [no-invalid-v-html](./rules/no-invalid-v-html.md) | [valid-v-html](./rules/valid-v-html.md) |
| [no-invalid-v-if](./rules/no-invalid-v-if.md) | [valid-v-if](./rules/valid-v-if.md) |
| [no-invalid-v-model](./rules/no-invalid-v-model.md) | [valid-v-model](./rules/valid-v-model.md) |
| [no-invalid-v-on](./rules/no-invalid-v-on.md) | [valid-v-on](./rules/valid-v-on.md) |
| [no-invalid-v-once](./rules/no-invalid-v-once.md) | [valid-v-once](./rules/valid-v-once.md) |
| [no-invalid-v-pre](./rules/no-invalid-v-pre.md) | [valid-v-pre](./rules/valid-v-pre.md) |
| [no-invalid-v-show](./rules/no-invalid-v-show.md) | [valid-v-show](./rules/valid-v-show.md) |
| [no-invalid-v-text](./rules/no-invalid-v-text.md) | [valid-v-text](./rules/valid-v-text.md) |
<!--RULES_TABLE_END-->

@@ -133,0 +183,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc