Socket
Socket
Sign inDemoInstall

eslint-plugin-vue

Package Overview
Dependencies
Maintainers
4
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 5.0.0-beta.5 to 5.0.0-beta.6

1

lib/configs/recommended.js

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

'vue/attributes-order': 'warn',
'vue/html-quotes': 'warn',
'vue/no-v-html': 'warn',

@@ -13,0 +12,0 @@ 'vue/order-in-components': 'warn',

1

lib/configs/strongly-recommended.js

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

'vue/html-indent': 'warn',
'vue/html-quotes': 'warn',
'vue/html-self-closing': 'warn',

@@ -17,0 +18,0 @@ 'vue/max-attributes-per-line': 'warn',

@@ -20,3 +20,3 @@ /**

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/attribute-hyphenation.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/attribute-hyphenation.md'
},

@@ -23,0 +23,0 @@ fixable: 'code',

@@ -110,3 +110,3 @@ /**

category: 'recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/attributes-order.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/attributes-order.md'
},

@@ -113,0 +113,0 @@ fixable: 'code',

@@ -113,3 +113,3 @@ /**

category: 'base',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/comment-directive.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/comment-directive.md'
},

@@ -116,0 +116,0 @@ schema: []

@@ -27,3 +27,3 @@ /**

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/component-name-in-template-casing.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/component-name-in-template-casing.md'
},

@@ -30,0 +30,0 @@ fixable: 'code',

@@ -36,3 +36,3 @@ /**

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/html-closing-bracket-newline.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/html-closing-bracket-newline.md'
},

@@ -39,0 +39,0 @@ fixable: 'whitespace',

@@ -57,3 +57,3 @@ /**

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/html-closing-bracket-spacing.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/html-closing-bracket-spacing.md'
},

@@ -60,0 +60,0 @@ schema: [{

@@ -24,3 +24,3 @@ /**

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/html-end-tags.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/html-end-tags.md'
},

@@ -27,0 +27,0 @@ fixable: 'code',

@@ -33,3 +33,3 @@ /**

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/html-indent.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/html-indent.md'
},

@@ -48,2 +48,3 @@ fixable: 'whitespace',

'attribute': { type: 'integer', minimum: 0 },
'baseIndent': { type: 'integer', minimum: 0 },
'closeBracket': { type: 'integer', minimum: 0 },

@@ -50,0 +51,0 @@ 'switchCase': { type: 'integer', minimum: 0 },

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

description: 'enforce quotes style of HTML attributes',
category: 'recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/html-quotes.md'
category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/html-quotes.md'
},

@@ -27,0 +27,0 @@ fixable: 'code',

@@ -92,3 +92,3 @@ /**

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/html-self-closing.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/html-self-closing.md'
},

@@ -95,0 +95,0 @@ fixable: 'code',

@@ -43,3 +43,3 @@ // the following rule is based on yannickcr/eslint-plugin-react

category: 'base',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/jsx-uses-vars.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/jsx-uses-vars.md'
},

@@ -46,0 +46,0 @@ schema: []

@@ -18,3 +18,3 @@ /**

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/max-attributes-per-line.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/max-attributes-per-line.md'
},

@@ -21,0 +21,0 @@ fixable: 'whitespace', // or "code" or "whitespace"

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

return Object.assign({
ignores: ['pre', 'textarea']
ignores: ['pre', 'textarea'],
ignoreWhenEmpty: true
}, options)

@@ -58,3 +59,3 @@ }

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/multiline-html-element-content-newline.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/multiline-html-element-content-newline.md'
},

@@ -65,3 +66,6 @@ fixable: 'whitespace',

properties: {
'ignores': {
ignoreWhenEmpty: {
type: 'boolean'
},
ignores: {
type: 'array',

@@ -82,3 +86,5 @@ items: { type: 'string' },

create (context) {
const ignores = parseOptions(context.options[0]).ignores
const options = parseOptions(context.options[0])
const ignores = options.ignores
const ignoreWhenEmpty = options.ignoreWhenEmpty
const template = context.parserServices.getTemplateBodyTokenStore && context.parserServices.getTemplateBodyTokenStore()

@@ -115,2 +121,10 @@ const sourceCode = context.getSourceCode()

const getTokenOption = { includeComments: true, filter: (token) => token.type !== 'HTMLWhitespace' }
if (
ignoreWhenEmpty &&
node.children.length === 0 &&
template.getFirstTokensBetween(node.startTag, node.endTag, getTokenOption).length === 0
) {
return
}
const contentFirst = template.getTokenAfter(node.startTag, getTokenOption)

@@ -117,0 +131,0 @@ const contentLast = template.getTokenBefore(node.endTag, getTokenOption)

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

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/mustache-interpolation-spacing.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/mustache-interpolation-spacing.md'
},

@@ -26,0 +26,0 @@ fixable: 'whitespace',

@@ -21,3 +21,3 @@ /**

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/name-property-casing.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/name-property-casing.md'
},

@@ -24,0 +24,0 @@ fixable: 'code', // or "code" or "whitespace"

@@ -68,3 +68,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/no-async-in-computed-properties.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/no-async-in-computed-properties.md'
},

@@ -71,0 +71,0 @@ fixable: null,

@@ -43,3 +43,3 @@ /**

category: 'recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/no-confusing-v-for-v-if.md',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/no-confusing-v-for-v-if.md',
replacedBy: ['no-use-v-if-with-v-for']

@@ -46,0 +46,0 @@ },

@@ -21,3 +21,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/no-dupe-keys.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/no-dupe-keys.md'
},

@@ -24,0 +24,0 @@ fixable: null, // or "code" or "whitespace"

@@ -43,3 +43,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/no-duplicate-attributes.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/no-duplicate-attributes.md'
},

@@ -46,0 +46,0 @@ fixable: null,

@@ -22,3 +22,3 @@ /**

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/no-multi-spaces.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/no-multi-spaces.md'
},

@@ -25,0 +25,0 @@ fixable: 'whitespace', // or "code" or "whitespace"

@@ -62,3 +62,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/no-parsing-error.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/no-parsing-error.md'
},

@@ -65,0 +65,0 @@ fixable: null,

@@ -22,3 +22,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/no-reserved-keys.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/no-reserved-keys.md'
},

@@ -25,0 +25,0 @@ fixable: null,

@@ -44,3 +44,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/no-shared-component-data.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/no-shared-component-data.md'
},

@@ -47,0 +47,0 @@ fixable: 'code',

@@ -19,3 +19,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/no-side-effects-in-computed-properties.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/no-side-effects-in-computed-properties.md'
},

@@ -22,0 +22,0 @@ fixable: null,

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

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/no-spaces-around-equal-signs-in-attribute.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/no-spaces-around-equal-signs-in-attribute.md'
},

@@ -26,0 +26,0 @@ fixable: 'whitespace',

@@ -24,3 +24,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/no-template-key.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/no-template-key.md'
},

@@ -27,0 +27,0 @@ fixable: null,

@@ -25,3 +25,3 @@ /**

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/no-template-shadow.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/no-template-shadow.md'
},

@@ -28,0 +28,0 @@ fixable: null,

@@ -24,3 +24,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/no-textarea-mustache.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/no-textarea-mustache.md'
},

@@ -27,0 +27,0 @@ fixable: null,

@@ -24,3 +24,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/no-unused-components.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/no-unused-components.md'
},

@@ -27,0 +27,0 @@ fixable: null,

@@ -19,3 +19,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/no-unused-vars.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/no-unused-vars.md'
},

@@ -22,0 +22,0 @@ fixable: null,

@@ -56,3 +56,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/no-use-v-if-with-v-for.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/no-use-v-if-with-v-for.md'
},

@@ -59,0 +59,0 @@ fixable: null,

@@ -9,3 +9,3 @@ /**

// ------------------------------------------------------------------------------
// Rule Definitionutilu
// Rule Definition
// ------------------------------------------------------------------------------

@@ -19,3 +19,3 @@

category: 'recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/no-v-html.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/no-v-html.md'
},

@@ -22,0 +22,0 @@ fixable: null,

@@ -139,3 +139,3 @@ /**

category: 'recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/order-in-components.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/order-in-components.md'
},

@@ -142,0 +142,0 @@ fixable: 'code', // null or "code" or "whitespace"

@@ -78,3 +78,3 @@ /**

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/prop-name-casing.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/prop-name-casing.md'
},

@@ -81,0 +81,0 @@ fixable: 'code', // null or "code" or "whitespace"

@@ -24,3 +24,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/require-component-is.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/require-component-is.md'
},

@@ -27,0 +27,0 @@ fixable: null,

@@ -29,3 +29,3 @@ /**

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/require-default-prop.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/require-default-prop.md'
},

@@ -32,0 +32,0 @@ fixable: null, // or "code" or "whitespace"

@@ -30,3 +30,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/require-prop-type-constructor.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/require-prop-type-constructor.md'
},

@@ -33,0 +33,0 @@ fixable: 'code', // or "code" or "whitespace"

@@ -19,3 +19,3 @@ /**

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/require-prop-types.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/require-prop-types.md'
},

@@ -22,0 +22,0 @@ fixable: null, // or "code" or "whitespace"

@@ -19,3 +19,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/require-render-return.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/require-render-return.md'
},

@@ -22,0 +22,0 @@ fixable: null, // or "code" or "whitespace"

@@ -24,3 +24,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/require-v-for-key.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/require-v-for-key.md'
},

@@ -27,0 +27,0 @@ fixable: null,

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/require-valid-default-prop.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/require-valid-default-prop.md'
},

@@ -31,0 +31,0 @@ fixable: null,

@@ -19,3 +19,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/return-in-computed-property.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/return-in-computed-property.md'
},

@@ -22,0 +22,0 @@ fixable: null, // or "code" or "whitespace"

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

category: undefined,
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/script-indent.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/script-indent.md'
},

@@ -26,0 +26,0 @@ fixable: 'whitespace',

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

ignores: ['pre', 'textarea'],
ignoreWhenNoAttributes: true
ignoreWhenNoAttributes: true,
ignoreWhenEmpty: true
}, options)

@@ -53,3 +54,3 @@ }

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/singleline-html-element-content-newline.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/singleline-html-element-content-newline.md'
},

@@ -63,2 +64,5 @@ fixable: 'whitespace',

},
ignoreWhenEmpty: {
type: 'boolean'
},
ignores: {

@@ -83,2 +87,3 @@ type: 'array',

const ignoreWhenNoAttributes = options.ignoreWhenNoAttributes
const ignoreWhenEmpty = options.ignoreWhenEmpty
const template = context.parserServices.getTemplateBodyTokenStore && context.parserServices.getTemplateBodyTokenStore()

@@ -118,2 +123,10 @@ const sourceCode = context.getSourceCode()

const getTokenOption = { includeComments: true, filter: (token) => token.type !== 'HTMLWhitespace' }
if (
ignoreWhenEmpty &&
node.children.length === 0 &&
template.getFirstTokensBetween(node.startTag, node.endTag, getTokenOption).length === 0
) {
return
}
const contentFirst = template.getTokenAfter(node.startTag, getTokenOption)

@@ -120,0 +133,0 @@ const contentLast = template.getTokenBefore(node.endTag, getTokenOption)

/**
* @fileoverview enforce usage of `this` in template.
* @fileoverview disallow usage of `this` in template.
* @author Armano

@@ -22,5 +22,5 @@ */

docs: {
description: 'enforce usage of `this` in template',
description: 'disallow usage of `this` in template',
category: 'recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/this-in-template.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/this-in-template.md'
},

@@ -27,0 +27,0 @@ fixable: null,

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/use-v-on-exact.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/use-v-on-exact.md'
},

@@ -26,0 +26,0 @@ fixable: null,

@@ -24,3 +24,3 @@ /**

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/v-bind-style.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/v-bind-style.md'
},

@@ -27,0 +27,0 @@ fixable: 'code',

@@ -24,3 +24,3 @@ /**

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/v-on-style.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/v-on-style.md'
},

@@ -27,0 +27,0 @@ fixable: 'code',

@@ -24,3 +24,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/valid-template-root.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/valid-template-root.md'
},

@@ -27,0 +27,0 @@ fixable: null,

@@ -30,3 +30,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/valid-v-bind.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/valid-v-bind.md'
},

@@ -33,0 +33,0 @@ fixable: null,

@@ -24,3 +24,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/valid-v-cloak.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/valid-v-cloak.md'
},

@@ -27,0 +27,0 @@ fixable: null,

@@ -24,3 +24,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/valid-v-else-if.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/valid-v-else-if.md'
},

@@ -27,0 +27,0 @@ fixable: null,

@@ -24,3 +24,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/valid-v-else.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/valid-v-else.md'
},

@@ -27,0 +27,0 @@ fixable: null,

@@ -110,3 +110,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/valid-v-for.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/valid-v-for.md'
},

@@ -113,0 +113,0 @@ fixable: null,

@@ -24,3 +24,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/valid-v-html.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/valid-v-html.md'
},

@@ -27,0 +27,0 @@ fixable: null,

@@ -24,3 +24,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/valid-v-if.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/valid-v-if.md'
},

@@ -27,0 +27,0 @@ fixable: null,

@@ -86,3 +86,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/valid-v-model.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/valid-v-model.md'
},

@@ -89,0 +89,0 @@ fixable: null,

@@ -121,3 +121,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/valid-v-on.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/valid-v-on.md'
},

@@ -124,0 +124,0 @@ fixable: null,

@@ -24,3 +24,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/valid-v-once.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/valid-v-once.md'
},

@@ -27,0 +27,0 @@ fixable: null,

@@ -24,3 +24,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/valid-v-pre.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/valid-v-pre.md'
},

@@ -27,0 +27,0 @@ fixable: null,

@@ -24,3 +24,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/valid-v-show.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/valid-v-show.md'
},

@@ -27,0 +27,0 @@ fixable: null,

@@ -24,3 +24,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.5/docs/rules/valid-v-text.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.6/docs/rules/valid-v-text.md'
},

@@ -27,0 +27,0 @@ fixable: null,

@@ -17,6 +17,8 @@ /**

const KNOWN_NODES = new Set(['ArrayExpression', 'ArrayPattern', 'ArrowFunctionExpression', 'AssignmentExpression', 'AssignmentPattern', 'AwaitExpression', 'BinaryExpression', 'BlockStatement', 'BreakStatement', 'CallExpression', 'CatchClause', 'ClassBody', 'ClassDeclaration', 'ClassExpression', 'ConditionalExpression', 'ContinueStatement', 'DebuggerStatement', 'DoWhileStatement', 'EmptyStatement', 'ExperimentalRestProperty', 'ExperimentalSpreadProperty', 'ExportAllDeclaration', 'ExportDefaultDeclaration', 'ExportNamedDeclaration', 'ExportSpecifier', 'ExpressionStatement', 'ForInStatement', 'ForOfStatement', 'ForStatement', 'FunctionDeclaration', 'FunctionExpression', 'Identifier', 'IfStatement', 'ImportDeclaration', 'ImportDefaultSpecifier', 'ImportNamespaceSpecifier', 'ImportSpecifier', 'LabeledStatement', 'Literal', 'LogicalExpression', 'MemberExpression', 'MetaProperty', 'MethodDefinition', 'NewExpression', 'ObjectExpression', 'ObjectPattern', 'Program', 'Property', 'RestElement', 'ReturnStatement', 'SequenceExpression', 'SpreadElement', 'Super', 'SwitchCase', 'SwitchStatement', 'TaggedTemplateExpression', 'TemplateElement', 'TemplateLiteral', 'ThisExpression', 'ThrowStatement', 'TryStatement', 'UnaryExpression', 'UpdateExpression', 'VariableDeclaration', 'VariableDeclarator', 'WhileStatement', 'WithStatement', 'YieldExpression', 'VAttribute', 'VDirectiveKey', 'VDocumentFragment', 'VElement', 'VEndTag', 'VExpressionContainer', 'VForExpression', 'VIdentifier', 'VLiteral', 'VOnExpression', 'VSlotScopeExpression', 'VStartTag', 'VText'])
const KNOWN_NODES = new Set(['ArrayExpression', 'ArrayPattern', 'ArrowFunctionExpression', 'AssignmentExpression', 'AssignmentPattern', 'AwaitExpression', 'BinaryExpression', 'BlockStatement', 'BreakStatement', 'CallExpression', 'CatchClause', 'ClassBody', 'ClassDeclaration', 'ClassExpression', 'ConditionalExpression', 'ContinueStatement', 'DebuggerStatement', 'DoWhileStatement', 'EmptyStatement', 'ExperimentalRestProperty', 'ExperimentalSpreadProperty', 'ExportAllDeclaration', 'ExportDefaultDeclaration', 'ExportNamedDeclaration', 'ExportSpecifier', 'ExpressionStatement', 'ForInStatement', 'ForOfStatement', 'ForStatement', 'FunctionDeclaration', 'FunctionExpression', 'Identifier', 'IfStatement', 'ImportDeclaration', 'ImportDefaultSpecifier', 'ImportNamespaceSpecifier', 'ImportSpecifier', 'LabeledStatement', 'Literal', 'LogicalExpression', 'MemberExpression', 'MetaProperty', 'MethodDefinition', 'NewExpression', 'ObjectExpression', 'ObjectPattern', 'Program', 'Property', 'RestElement', 'ReturnStatement', 'SequenceExpression', 'SpreadElement', 'Super', 'SwitchCase', 'SwitchStatement', 'TaggedTemplateExpression', 'TemplateElement', 'TemplateLiteral', 'ThisExpression', 'ThrowStatement', 'TryStatement', 'UnaryExpression', 'UpdateExpression', 'VariableDeclaration', 'VariableDeclarator', 'WhileStatement', 'WithStatement', 'YieldExpression', 'VAttribute', 'VDirectiveKey', 'VDocumentFragment', 'VElement', 'VEndTag', 'VExpressionContainer', 'VFilter', 'VFilterSequenceExpression', 'VForExpression', 'VIdentifier', 'VLiteral', 'VOnExpression', 'VSlotScopeExpression', 'VStartTag', 'VText'])
const LT_CHAR = /[\r\n\u2028\u2029]/
const LINES = /[^\r\n\u2028\u2029]+(?:$|\r\n|[\r\n\u2028\u2029])/g
const BLOCK_COMMENT_PREFIX = /^\s*\*/
const ITERATION_OPTS = Object.freeze({ includeComments: true, filter: isNotWhitespace })
const PREFORMATTED_ELEMENT_NAMES = ['pre', 'textarea']

@@ -199,2 +201,20 @@ /**

/**
* Check whether the given node is not an empty text node.
* @param {Node} node The node to check.
* @returns {boolean} `false` if the token is empty text node.
*/
function isNotEmptyTextNode (node) {
return !(node.type === 'VText' && node.value.trim() === '')
}
/**
* Check whether the given token is a pipe operator.
* @param {Token} token The token to check.
* @returns {boolean} `true` if the token is a pipe operator.
*/
function isPipeOperator (token) {
return token != null && token.type === 'Punctuator' && token.value === '|'
}
/**
* Get the last element.

@@ -263,2 +283,3 @@ * @param {Array} xs The array to get the last element.

const offsets = new Map()
const preformattedTokens = new Set()

@@ -300,3 +321,3 @@ /**

*/
function setBaseline (token, hardTabAdditional) {
function setBaseline (token) {
const offsetInfo = offsets.get(token)

@@ -309,2 +330,26 @@ if (offsetInfo != null) {

/**
* Sets preformatted tokens to the given element node.
* @param {Node} node The node to set.
* @returns {void}
*/
function setPreformattedTokens (node) {
const endToken = (node.endTag && tokenStore.getFirstToken(node.endTag)) || tokenStore.getTokenAfter(node)
const option = {
includeComments: true,
filter: token => token != null && (
token.type === 'HTMLText' ||
token.type === 'HTMLRCDataText' ||
token.type === 'HTMLTagOpen' ||
token.type === 'HTMLEndTagOpen' ||
token.type === 'HTMLComment'
)
}
for (const token of tokenStore.getTokensBetween(node.startTag, endToken, option)) {
preformattedTokens.add(token)
}
preformattedTokens.add(endToken)
}
/**
* Get the first and last tokens of the given node.

@@ -337,13 +382,17 @@ * If the node is parenthesized, this gets the outermost parentheses.

* @param {Node[]} nodeList The node to process.
* @param {Node|null} leftToken The left parenthesis token.
* @param {Node|null} rightToken The right parenthesis token.
* @param {Node|Token|null} left The left parenthesis token.
* @param {Node|Token|null} right The right parenthesis token.
* @param {number} offset The offset to set.
* @param {Node} [alignVertically=true] The flag to align vertically. If `false`, this doesn't align vertically even if the first node is not at beginning of line.
* @param {boolean} [alignVertically=true] The flag to align vertically. If `false`, this doesn't align vertically even if the first node is not at beginning of line.
* @returns {void}
*/
function processNodeList (nodeList, leftToken, rightToken, offset, alignVertically) {
function processNodeList (nodeList, left, right, offset, alignVertically) {
let t
const leftToken = (left && tokenStore.getFirstToken(left)) || left
const rightToken = (right && tokenStore.getFirstToken(right)) || right
if (nodeList.length >= 1) {
let lastToken = leftToken
let baseToken = null
let lastToken = left
const alignTokensBeforeBaseToken = []
const alignTokens = []

@@ -359,21 +408,39 @@

// Collect related tokens.
// Commas between this and the previous, and the first token of this node.
// Collect comma/comment tokens between the last token of the previous node and the first token of this node.
if (lastToken != null) {
t = lastToken
while ((t = tokenStore.getTokenAfter(t)) != null && t.range[1] <= elementTokens.firstToken.range[0]) {
alignTokens.push(t)
while (
(t = tokenStore.getTokenAfter(t, ITERATION_OPTS)) != null &&
t.range[1] <= elementTokens.firstToken.range[0]
) {
if (baseToken == null) {
alignTokensBeforeBaseToken.push(t)
} else {
alignTokens.push(t)
}
}
}
alignTokens.push(elementTokens.firstToken)
// Save the last token to find tokens between the next token.
if (baseToken == null) {
baseToken = elementTokens.firstToken
} else {
alignTokens.push(elementTokens.firstToken)
}
// Save the last token to find tokens between this node and the next node.
lastToken = elementTokens.lastToken
}
// Check trailing commas.
// Check trailing commas and comments.
if (rightToken != null && lastToken != null) {
t = lastToken
while ((t = tokenStore.getTokenAfter(t)) != null && t.range[1] <= rightToken.range[0]) {
alignTokens.push(t)
while (
(t = tokenStore.getTokenAfter(t, ITERATION_OPTS)) != null &&
t.range[1] <= rightToken.range[0]
) {
if (baseToken == null) {
alignTokensBeforeBaseToken.push(t)
} else {
alignTokens.push(t)
}
}

@@ -383,3 +450,5 @@ }

// Set offsets.
const baseToken = alignTokens.shift()
if (leftToken != null) {
setOffset(alignTokensBeforeBaseToken, offset, leftToken)
}
if (baseToken != null) {

@@ -396,3 +465,3 @@ // Set offset to the first token.

if (alignVertically === false) {
if (alignVertically === false && leftToken != null) {
// Align tokens relatively to the left token.

@@ -645,6 +714,6 @@ setOffset(alignTokens, offset, leftToken)

* @param {number} expectedIndent The expected indentation.
* @param {number|undefined} optionalExpectedIndent The optional expected indentation.
* @param {number[]|undefined} optionalExpectedIndents The optional expected indentation.
* @returns {void}
*/
function validateCore (token, expectedIndent, optionalExpectedIndent) {
function validateCore (token, expectedIndent, optionalExpectedIndents) {
const line = token.loc.start.line

@@ -681,3 +750,3 @@ const indentText = getIndentText(token)

if (actualIndent !== expectedIndent && (optionalExpectedIndent === undefined || actualIndent !== optionalExpectedIndent)) {
if (actualIndent !== expectedIndent && (optionalExpectedIndents == null || !optionalExpectedIndents.includes(actualIndent))) {
context.report({

@@ -706,3 +775,3 @@ loc: {

* @param {number|undefined} lastExpectedIndent The expected indent of the last token.
* @returns {{primary:number|undefined,secondary:number|undefined}}
* @returns {number[]}
*/

@@ -716,6 +785,3 @@ function getCommentExpectedIndents (nextToken, nextExpectedIndent, lastExpectedIndent) {

// </div>
return {
primary: nextExpectedIndent + options.indentSize,
secondary: undefined
}
return [nextExpectedIndent + options.indentSize, nextExpectedIndent]
}

@@ -728,3 +794,3 @@

// </div>
return { primary: lastExpectedIndent, secondary: nextExpectedIndent }
return [lastExpectedIndent, nextExpectedIndent]
}

@@ -737,3 +803,3 @@

// </div>
return { primary: nextExpectedIndent, secondary: undefined }
return [nextExpectedIndent]
}

@@ -800,2 +866,7 @@

// It does not validate preformatted tokens.
if (preformattedTokens.has(firstToken)) {
return
}
// Calculate the expected indents for comments.

@@ -805,7 +876,13 @@ // It allows the same indent level with the previous line.

const lastExpectedIndent = lastOffsetInfo && lastOffsetInfo.expectedIndent
const commentExpectedIndents = getCommentExpectedIndents(firstToken, expectedIndent, lastExpectedIndent)
const commentOptionalExpectedIndents = getCommentExpectedIndents(firstToken, expectedIndent, lastExpectedIndent)
// Validate.
for (const comment of comments) {
validateCore(comment, commentExpectedIndents.primary, commentExpectedIndents.secondary)
const commentExpectedIndents = getExpectedIndents([comment])
const commentExpectedIndent =
commentExpectedIndents
? commentExpectedIndents.expectedIndent
: commentOptionalExpectedIndents[0]
validateCore(comment, commentExpectedIndent, commentOptionalExpectedIndents)
}

@@ -835,10 +912,12 @@ validateCore(firstToken, expectedIndent)

VElement (node) {
const startTagToken = tokenStore.getFirstToken(node)
const endTagToken = node.endTag && tokenStore.getFirstToken(node.endTag)
if (node.name !== 'pre') {
const childTokens = node.children.map(n => tokenStore.getFirstToken(n))
setOffset(childTokens, 1, startTagToken)
if (!PREFORMATTED_ELEMENT_NAMES.includes(node.name)) {
const isTopLevel = node.parent.type !== 'VElement'
const offset = isTopLevel ? options.baseIndent : 1
processNodeList(node.children.filter(isNotEmptyTextNode), node.startTag, node.endTag, offset)
} else {
const startTagToken = tokenStore.getFirstToken(node)
const endTagToken = node.endTag && tokenStore.getFirstToken(node.endTag)
setOffset(endTagToken, 0, startTagToken)
setPreformattedTokens(node)
}
setOffset(endTagToken, 0, startTagToken)
},

@@ -866,2 +945,30 @@

VFilter (node) {
const idToken = tokenStore.getFirstToken(node)
const lastToken = tokenStore.getLastToken(node)
if (isRightParen(lastToken)) {
const leftParenToken = tokenStore.getTokenAfter(node.callee)
setOffset(leftParenToken, 1, idToken)
processNodeList(node.arguments, leftParenToken, lastToken, 1)
}
},
VFilterSequenceExpression (node) {
if (node.filters.length === 0) {
return
}
const firstToken = tokenStore.getFirstToken(node)
const tokens = []
for (const filter of node.filters) {
tokens.push(
tokenStore.getTokenBefore(filter, isPipeOperator),
tokenStore.getFirstToken(filter)
)
}
setOffset(tokens, 1, firstToken)
},
VForExpression (node) {

@@ -1006,2 +1113,3 @@ const firstToken = tokenStore.getFirstToken(node)

ConditionalExpression (node) {
const prevToken = tokenStore.getTokenBefore(node)
const firstToken = tokenStore.getFirstToken(node)

@@ -1012,3 +1120,6 @@ const questionToken = tokenStore.getTokenAfter(node.test, isNotRightParen)

const alternateToken = tokenStore.getTokenAfter(colonToken)
const isFlat = (node.test.loc.end.line === node.consequent.loc.start.line)
const isFlat =
prevToken &&
prevToken.loc.end.line !== node.loc.start.line &&
node.test.loc.end.line === node.consequent.loc.start.line

@@ -1105,3 +1216,2 @@ if (isFlat) {

processNodeList([node.init, node.test, node.update], leftParenToken, rightParenToken, 1)
setOffset(rightParenToken, 0, leftParenToken)
processMaybeBlock(node.body, forToken)

@@ -1534,3 +1644,3 @@ },

// Validate indentation of tokens.
for (const token of tokenStore.getTokens(node, { includeComments: true, filter: isNotWhitespace })) {
for (const token of tokenStore.getTokens(node, ITERATION_OPTS)) {
if (tokensOnSameLine.length === 0 || tokensOnSameLine[0].loc.start.line === token.loc.start.line) {

@@ -1537,0 +1647,0 @@ // This is on the same line (or the first token).

@@ -267,3 +267,3 @@ /**

* Check whether the given name is a MathML element or not.
* @param {ASTNode} name The node to check.
* @param {ASTNode} node The node to check.
* @returns {boolean} `true` if the node is a MathML element.

@@ -311,3 +311,3 @@ */

* Check whether the given attribute node is a binding
* @param {ASTNode} name The attribute to check.
* @param {ASTNode} attribute The attribute to check.
* @returns {boolean}

@@ -332,3 +332,3 @@ */

* Parse member expression node to get array with all of its parts
* @param {ASTNode} MemberExpression
* @param {ASTNode} node MemberExpression
* @returns {Array}

@@ -611,3 +611,3 @@ */

* @param {ASTNode} node Node to check
* @param {string} groupName Name of parent group
* @param {Set} groups Name of parent group
*/

@@ -614,0 +614,0 @@ * iterateProperties (node, groups) {

{
"name": "eslint-plugin-vue",
"version": "5.0.0-beta.5",
"version": "5.0.0-beta.6",
"description": "Official ESLint plugin for Vue.js",

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

"version": "npm run lint -- --fix && git add .",
"update": "node ./tools/update.js"
"update": "node ./tools/update.js",
"docs:watch": "vuepress dev docs",
"docs:build": "vuepress build docs",
"docs:deploy": "./tools/deploy.sh"
},

@@ -48,3 +51,3 @@ "files": [

"dependencies": {
"vue-eslint-parser": "^3.2.1"
"vue-eslint-parser": "^4.0.2"
},

@@ -58,2 +61,3 @@ "devDependencies": {

"eslint-plugin-vue-libs": "^3.0.0",
"eslint4b": "^5.1.0",
"lodash": "^4.17.4",

@@ -63,4 +67,6 @@ "mocha": "^5.2.0",

"typescript": "^3.1.3",
"typescript-eslint-parser": "^20.0.0"
"typescript-eslint-parser": "^20.0.0",
"vue-eslint-editor": "^0.1.4",
"vuepress": "^0.14.5"
}
}

@@ -10,300 +10,18 @@ # eslint-plugin-vue

## :exclamation: Attention - this is documentation for version `5.x` :exclamation:
## :book: Documentation
This branch contains `eslint-plugin-vue@next` which is a pre-released `5.0`, but it's not the default version that you get with `npm install eslint-plugin-vue`. In order to install this you need to specify either `"eslint-plugin-vue": "next"` in `package.json` or do `npm install eslint-plugin-vue@next`.
See https://vuejs.github.io/eslint-plugin-vue/
Please try it and report any issues that you might have encountered.
> :exclamation: Attention - this is documentation for version `5.x` :exclamation:
>
> This branch contains `eslint-plugin-vue@next` which is a pre-released `5.0`, but it's not the default version that you get with `npm install eslint-plugin-vue`. In order to install this you need to specify either `"eslint-plugin-vue": "next"` in `package.json` or do `npm install eslint-plugin-vue@next`.
>
> Please try it and report any issues that you might have encountered.
>
> If you want to check previous releases [go here](https://github.com/vuejs/eslint-plugin-vue/releases).
If you want to check previous releases [go here](https://github.com/vuejs/eslint-plugin-vue/releases).
## :anchor: Versioning Policy
## :art: Playground on the Web
This plugin is following [Semantic Versioning](http://semver.org/) and [ESLint's Semantic Versioning Policy](https://github.com/eslint/eslint#semantic-versioning-policy).
You can try this plugin on the Web.
- https://mysticatea.github.io/vue-eslint-demo/
## :grey_exclamation: Requirements
- [ESLint](http://eslint.org/) `^5.0.0`.
- Node.js `>=6.5.0`
## :cd: Installation
```bash
npm install --save-dev eslint eslint-plugin-vue@next
```
## :rocket: Usage
Create `.eslintrc.*` file to configure rules. See also: [http://eslint.org/docs/user-guide/configuring](http://eslint.org/docs/user-guide/configuring).
Example **.eslintrc.js**:
```js
module.exports = {
extends: [
// add more generic rulesets here, such as:
// 'eslint:recommended',
'plugin:vue/essential'
],
rules: {
// override/add rules settings here, such as:
// 'vue/no-unused-vars': 'error'
}
}
```
### Single File Components
ESLint only targets `.js` files by default. You must include the `.vue` extension using [the `--ext` option](https://eslint.org/docs/user-guide/configuring#specifying-file-extensions-to-lint) or a glob pattern.
Examples:
```bash
eslint --ext .js,.vue src
eslint src/**/*.{js,vue}
```
### Attention
All component-related rules are being applied to code that passes any of the following checks:
* `Vue.component()` expression
* `Vue.extend()` expression
* `Vue.mixin()` 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)
})
```
### `eslint-disable` functionality in `<template>`
You can use `<!-- eslint-disable -->`-like HTML comments in `<template>` of `.vue` files. For example:
```html
<template>
<!-- eslint-disable-next-line vue/max-attributes-per-line -->
<div a="1" b="2" c="3" d="4">
</div>
</template>
```
If you want to disallow `eslint-disable` functionality, please disable [vue/comment-directive](./docs/rules/comment-directive.md) rule.
## :gear: Configs
This plugin provides four predefined configs:
- `plugin:vue/base` - Settings and rules to enable correct ESLint parsing
- `plugin:vue/essential` - Above, plus rules to prevent errors or unintended behavior
- `plugin:vue/strongly-recommended` - Above, plus rules to considerably improve code readability and/or dev experience
- `plugin:vue/recommended` - Above, plus rules to enforce subjective community defaults to ensure consistency
## :bulb: Rules
Rules are grouped by priority to help you understand their purpose. The `--fix` option on the command line automatically fixes problems reported by rules which have a wrench :wrench: below.
<!--RULES_TABLE_START-->
### Base Rules (Enabling Correct ESLint Parsing)
Enforce all the rules in this category, as well as all higher priority rules, with:
```json
{
"extends": "plugin:vue/base"
}
```
| | Rule ID | Description |
|:---|:--------|:------------|
| | [vue/comment-directive](./docs/rules/comment-directive.md) | support comment-directives in `<template>` |
| | [vue/jsx-uses-vars](./docs/rules/jsx-uses-vars.md) | prevent variables used in JSX to be marked as unused |
### Priority A: Essential (Error Prevention)
Enforce all the rules in this category, as well as all higher priority rules, with:
```json
{
"extends": "plugin:vue/essential"
}
```
| | Rule ID | Description |
|:---|:--------|:------------|
| | [vue/no-async-in-computed-properties](./docs/rules/no-async-in-computed-properties.md) | disallow asynchronous actions in computed properties |
| | [vue/no-dupe-keys](./docs/rules/no-dupe-keys.md) | disallow duplication of field names |
| | [vue/no-duplicate-attributes](./docs/rules/no-duplicate-attributes.md) | disallow duplication of attributes |
| | [vue/no-parsing-error](./docs/rules/no-parsing-error.md) | disallow parsing errors in `<template>` |
| | [vue/no-reserved-keys](./docs/rules/no-reserved-keys.md) | disallow overwriting reserved keys |
| :wrench: | [vue/no-shared-component-data](./docs/rules/no-shared-component-data.md) | enforce component's data property to be a function |
| | [vue/no-side-effects-in-computed-properties](./docs/rules/no-side-effects-in-computed-properties.md) | disallow side effects in computed properties |
| | [vue/no-template-key](./docs/rules/no-template-key.md) | disallow `key` attribute on `<template>` |
| | [vue/no-textarea-mustache](./docs/rules/no-textarea-mustache.md) | disallow mustaches in `<textarea>` |
| | [vue/no-unused-components](./docs/rules/no-unused-components.md) | disallow registering components that are not used inside templates |
| | [vue/no-unused-vars](./docs/rules/no-unused-vars.md) | disallow unused variable definitions of v-for directives or scope attributes |
| | [vue/no-use-v-if-with-v-for](./docs/rules/no-use-v-if-with-v-for.md) | disallow use v-if on the same element as v-for |
| | [vue/require-component-is](./docs/rules/require-component-is.md) | require `v-bind:is` of `<component>` elements |
| :wrench: | [vue/require-prop-type-constructor](./docs/rules/require-prop-type-constructor.md) | require prop type to be a constructor |
| | [vue/require-render-return](./docs/rules/require-render-return.md) | enforce render function to always return value |
| | [vue/require-v-for-key](./docs/rules/require-v-for-key.md) | require `v-bind:key` with `v-for` directives |
| | [vue/require-valid-default-prop](./docs/rules/require-valid-default-prop.md) | enforce props default values to be valid |
| | [vue/return-in-computed-property](./docs/rules/return-in-computed-property.md) | enforce that a return statement is present in computed property |
| | [vue/use-v-on-exact](./docs/rules/use-v-on-exact.md) | enforce usage of `exact` modifier on `v-on` |
| | [vue/valid-template-root](./docs/rules/valid-template-root.md) | enforce valid template root |
| | [vue/valid-v-bind](./docs/rules/valid-v-bind.md) | enforce valid `v-bind` directives |
| | [vue/valid-v-cloak](./docs/rules/valid-v-cloak.md) | enforce valid `v-cloak` directives |
| | [vue/valid-v-else-if](./docs/rules/valid-v-else-if.md) | enforce valid `v-else-if` directives |
| | [vue/valid-v-else](./docs/rules/valid-v-else.md) | enforce valid `v-else` directives |
| | [vue/valid-v-for](./docs/rules/valid-v-for.md) | enforce valid `v-for` directives |
| | [vue/valid-v-html](./docs/rules/valid-v-html.md) | enforce valid `v-html` directives |
| | [vue/valid-v-if](./docs/rules/valid-v-if.md) | enforce valid `v-if` directives |
| | [vue/valid-v-model](./docs/rules/valid-v-model.md) | enforce valid `v-model` directives |
| | [vue/valid-v-on](./docs/rules/valid-v-on.md) | enforce valid `v-on` directives |
| | [vue/valid-v-once](./docs/rules/valid-v-once.md) | enforce valid `v-once` directives |
| | [vue/valid-v-pre](./docs/rules/valid-v-pre.md) | enforce valid `v-pre` directives |
| | [vue/valid-v-show](./docs/rules/valid-v-show.md) | enforce valid `v-show` directives |
| | [vue/valid-v-text](./docs/rules/valid-v-text.md) | enforce valid `v-text` directives |
### Priority B: Strongly Recommended (Improving Readability)
Enforce all the rules in this category, as well as all higher priority rules, with:
```json
{
"extends": "plugin:vue/strongly-recommended"
}
```
| | Rule ID | Description |
|:---|:--------|:------------|
| :wrench: | [vue/attribute-hyphenation](./docs/rules/attribute-hyphenation.md) | enforce attribute naming style on custom components in template |
| :wrench: | [vue/component-name-in-template-casing](./docs/rules/component-name-in-template-casing.md) | enforce specific casing for the component naming style in template |
| :wrench: | [vue/html-closing-bracket-newline](./docs/rules/html-closing-bracket-newline.md) | require or disallow a line break before tag's closing brackets |
| :wrench: | [vue/html-closing-bracket-spacing](./docs/rules/html-closing-bracket-spacing.md) | require or disallow a space before tag's closing brackets |
| :wrench: | [vue/html-end-tags](./docs/rules/html-end-tags.md) | enforce end tag style |
| :wrench: | [vue/html-indent](./docs/rules/html-indent.md) | enforce consistent indentation in `<template>` |
| :wrench: | [vue/html-self-closing](./docs/rules/html-self-closing.md) | enforce self-closing style |
| :wrench: | [vue/max-attributes-per-line](./docs/rules/max-attributes-per-line.md) | enforce the maximum number of attributes per line |
| :wrench: | [vue/multiline-html-element-content-newline](./docs/rules/multiline-html-element-content-newline.md) | require a line break before and after the contents of a multiline element |
| :wrench: | [vue/mustache-interpolation-spacing](./docs/rules/mustache-interpolation-spacing.md) | enforce unified spacing in mustache interpolations |
| :wrench: | [vue/name-property-casing](./docs/rules/name-property-casing.md) | enforce specific casing for the name property in Vue components |
| :wrench: | [vue/no-multi-spaces](./docs/rules/no-multi-spaces.md) | disallow multiple spaces |
| :wrench: | [vue/no-spaces-around-equal-signs-in-attribute](./docs/rules/no-spaces-around-equal-signs-in-attribute.md) | disallow spaces around equal signs in attribute |
| | [vue/no-template-shadow](./docs/rules/no-template-shadow.md) | disallow variable declarations from shadowing variables declared in the outer scope |
| :wrench: | [vue/prop-name-casing](./docs/rules/prop-name-casing.md) | enforce specific casing for the Prop name in Vue components |
| | [vue/require-default-prop](./docs/rules/require-default-prop.md) | require default value for props |
| | [vue/require-prop-types](./docs/rules/require-prop-types.md) | require type definitions in props |
| :wrench: | [vue/singleline-html-element-content-newline](./docs/rules/singleline-html-element-content-newline.md) | require a line break before and after the contents of a singleline element |
| :wrench: | [vue/v-bind-style](./docs/rules/v-bind-style.md) | enforce `v-bind` directive style |
| :wrench: | [vue/v-on-style](./docs/rules/v-on-style.md) | enforce `v-on` directive style |
### Priority C: Recommended (Minimizing Arbitrary Choices and Cognitive Overhead)
Enforce all the rules in this category, as well as all higher priority rules, with:
```json
{
"extends": "plugin:vue/recommended"
}
```
| | Rule ID | Description |
|:---|:--------|:------------|
| :wrench: | [vue/attributes-order](./docs/rules/attributes-order.md) | enforce order of attributes |
| :wrench: | [vue/html-quotes](./docs/rules/html-quotes.md) | enforce quotes style of HTML attributes |
| | [vue/no-v-html](./docs/rules/no-v-html.md) | disallow use of v-html to prevent XSS attack |
| :wrench: | [vue/order-in-components](./docs/rules/order-in-components.md) | enforce order of properties in components |
| | [vue/this-in-template](./docs/rules/this-in-template.md) | enforce usage of `this` in template |
### Uncategorized
| | Rule ID | Description |
|:---|:--------|:------------|
| :wrench: | [vue/script-indent](./docs/rules/script-indent.md) | enforce consistent indentation in `<script>` |
### 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 |
|:--------|:------------|
| [vue/no-confusing-v-for-v-if](./docs/rules/no-confusing-v-for-v-if.md) | [vue/no-use-v-if-with-v-for](./docs/rules/no-use-v-if-with-v-for.md) |
<!--RULES_TABLE_END-->
## :couple: FAQ
### What is the "Use the latest vue-eslint-parser" error?
The most rules of `eslint-plugin-vue` require `vue-eslint-parser` to check `<template>` ASTs.
Make sure you have one of the following settings in your **.eslintrc**:
- `"extends": ["plugin:vue/recommended"]`
- `"extends": ["plugin:vue/base"]`
If you already use other parser (e.g. `"parser": "babel-eslint"`), please move it into `parserOptions`, so it doesn't collide with the `vue-eslint-parser` used by this plugin's configuration:
```diff
- "parser": "babel-eslint",
"parserOptions": {
+ "parser": "babel-eslint",
"ecmaVersion": 2017,
"sourceType": "module"
}
```
The `vue-eslint-parser` uses the parser which is set by `parserOptions.parser` to parse scripts.
### Why doesn't it work on .vue file?
1. Make sure you don't have `eslint-plugin-html` in your config. The `eslint-plugin-html` extracts the content from `<script>` tags, but `eslint-plugin-vue` requires `<script>` tags and `<template>` tags in order to distinguish template and script in single file components.
```diff
"plugins": [
"vue",
- "html"
]
```
2. Make sure your tool is set to lint `.vue` files.
- CLI targets only `.js` files by default. You have to specify additional extensions by `--ext` option or glob patterns. E.g. `eslint "src/**/*.{js,vue}"` or `eslint src --ext .vue`. If you use `@vue/cli-plugin-eslint` and the `vue-cli-service lint` command - you don't have to worry about it.
- VSCode targets only JavaScript or HTML files by default. You have to add `"vue"` to the `"eslint.validate"` array in vscode settings. e.g. `"eslint.validate": [ "javascript", "javascriptreact", "vue" ]`
- If you use `Vetur` plugin in VSCode - set `"vetur.validation.template": false` to avoid default Vetur template validation. Check out [vetur documentation](https://github.com/vuejs/vetur/blob/master/docs/linting-error.md) for more info.
- For Atom editor, you need to go into Settings -> Packages -> linter-eslint, under the option “List of scopes to run eslint on”, add `text.html.vue`.
- For Sublime Text, you need to open command-pallete via cmd+shift+p (cmd => ctrl for windows) and type "Preferences: SublimeLinter Settings", paste to the config on the right side:
```json
{
"linters": {
"eslint": {
"selector": "source.js, text.html.vue"
}
}
}
```
## :anchor: Semantic Versioning Policy
This plugin follows [semantic versioning](http://semver.org/) and [ESLint's Semantic Versioning Policy](https://github.com/eslint/eslint#semantic-versioning-policy).
## :newspaper: Changelog

@@ -315,14 +33,5 @@

In order to add a new rule, you should:
- Create issue on GH with description of proposed rule
- Generate a new rule using the [official yeoman generator](https://github.com/eslint/generator-eslint)
- Run `npm start`
- Write test scenarios & implement logic
- Describe the rule in the generated `docs` file
- Make sure all tests are passing
- Run `npm run lint` and fix any errors
- Run `npm run update` in order to update readme and recommended configuration
- Create PR and link created issue in description
Contributing is welcome!
We're more than happy to see potential contributions, so don't hesitate. If you have any suggestions, ideas or problems feel free to add new [issue](https://github.com/vuejs/eslint-plugin-vue/issues), but first please make sure your question does not repeat previous ones.
See https://vuejs.github.io/eslint-plugin-vue/developer-guide/

@@ -329,0 +38,0 @@ ### Working with rules

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