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 4.2.2 to 4.3.0

lib/rules/attributes-order.js

1

lib/configs/recommended.js

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

rules: {
'vue/attributes-order': 'error',
'vue/html-quotes': 'error',

@@ -11,0 +12,0 @@ 'vue/no-confusing-v-for-v-if': 'error',

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

'attribute-hyphenation': require('./rules/attribute-hyphenation'),
'attributes-order': require('./rules/attributes-order'),
'comment-directive': require('./rules/comment-directive'),

@@ -36,2 +37,3 @@ 'html-closing-bracket-newline': require('./rules/html-closing-bracket-newline'),

'order-in-components': require('./rules/order-in-components'),
'prop-name-casing': require('./rules/prop-name-casing'),
'require-component-is': require('./rules/require-component-is'),

@@ -38,0 +40,0 @@ 'require-default-prop': require('./rules/require-default-prop'),

2

lib/rules/attribute-hyphenation.js

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

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/attribute-hyphenation.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/attribute-hyphenation.md'
},

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

@@ -112,3 +112,3 @@ /**

category: 'base',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/comment-directive.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/comment-directive.md'
},

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

@@ -35,3 +35,3 @@ /**

category: undefined,
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/html-closing-bracket-newline.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/html-closing-bracket-newline.md'
},

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

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

category: undefined,
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/html-closing-bracket-spacing.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/html-closing-bracket-spacing.md'
},

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

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

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/html-end-tags.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/html-end-tags.md'
},

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

@@ -32,3 +32,3 @@ /**

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/html-indent.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/html-indent.md'
},

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

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

category: 'recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/html-quotes.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/html-quotes.md'
},

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

@@ -91,3 +91,3 @@ /**

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/html-self-closing.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/html-self-closing.md'
},

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

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

category: 'base',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/jsx-uses-vars.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/jsx-uses-vars.md'
},

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

@@ -17,5 +17,5 @@ /**

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/max-attributes-per-line.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/max-attributes-per-line.md'
},
fixable: null,
fixable: 'whitespace', // or "code" or "whitespace"
schema: [

@@ -133,3 +133,3 @@ {

function showErrors (attributes, node) {
attributes.forEach((prop) => {
attributes.forEach((prop, i) => {
context.report({

@@ -141,3 +141,4 @@ node: prop,

propName: prop.key.name
}
},
fix: i === 0 ? (fixer) => fixer.insertTextBefore(prop, '\n') : undefined
})

@@ -144,0 +145,0 @@ })

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

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/mustache-interpolation-spacing.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/mustache-interpolation-spacing.md'
},

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

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

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/name-property-casing.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/name-property-casing.md'
},

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

@@ -67,3 +67,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/no-async-in-computed-properties.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/no-async-in-computed-properties.md'
},

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

@@ -42,3 +42,3 @@ /**

category: 'recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/no-confusing-v-for-v-if.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/no-confusing-v-for-v-if.md'
},

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

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/no-dupe-keys.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/no-dupe-keys.md'
},

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

@@ -42,3 +42,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/no-duplicate-attributes.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/no-duplicate-attributes.md'
},

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

@@ -16,3 +16,3 @@ /**

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/no-multi-spaces.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/no-multi-spaces.md'
},

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

@@ -61,3 +61,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/no-parsing-error.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/no-parsing-error.md'
},

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

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/no-reserved-keys.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/no-reserved-keys.md'
},

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

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/no-shared-component-data.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/no-shared-component-data.md'
},

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

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/no-side-effects-in-computed-properties.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/no-side-effects-in-computed-properties.md'
},

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

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/no-template-key.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/no-template-key.md'
},

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

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/no-textarea-mustache.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/no-textarea-mustache.md'
},

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

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/no-unused-vars.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/no-unused-vars.md'
},

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

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

const utils = require('../utils')
const Traverser = require('eslint/lib/util/traverser')

@@ -60,2 +61,71 @@ const defaultOrder = [

function isComma (node) {
return node.type === 'Punctuator' && node.value === ','
}
const ARITHMETIC_OPERATORS = ['+', '-', '*', '/', '%', '**']
const BITWISE_OPERATORS = ['&', '|', '^', '~', '<<', '>>', '>>>']
const COMPARISON_OPERATORS = ['==', '!=', '===', '!==', '>', '>=', '<', '<=']
const RELATIONAL_OPERATORS = ['in', 'instanceof']
const ALL_BINARY_OPERATORS = [].concat(
ARITHMETIC_OPERATORS,
BITWISE_OPERATORS,
COMPARISON_OPERATORS,
RELATIONAL_OPERATORS
)
const LOGICAL_OPERATORS = ['&&', '||']
/*
* Result `true` if the node is sure that there are no side effects
*
* Currently known side effects types
*
* node.type === 'CallExpression'
* node.type === 'NewExpression'
* node.type === 'UpdateExpression'
* node.type === 'AssignmentExpression'
* node.type === 'TaggedTemplateExpression'
* node.type === 'UnaryExpression' && node.operator === 'delete'
*
* @param {ASTNode} node target node
* @param {Object} visitorKeys sourceCode.visitorKey
* @returns {Boolean} no side effects
*/
function isNotSideEffectsNode (node, visitorKeys) {
let result = true
new Traverser().traverse(node, {
visitorKeys,
enter (node, parent) {
if (
node.type === 'FunctionExpression' ||
node.type === 'Identifier' ||
node.type === 'Literal' ||
// es2015
node.type === 'ArrowFunctionExpression' ||
node.type === 'TemplateElement'
) {
// no side effects node
this.skip()
} else if (
node.type !== 'Property' &&
node.type !== 'ObjectExpression' &&
node.type !== 'ArrayExpression' &&
(node.type !== 'UnaryExpression' || ['!', '~', '+', '-', 'typeof'].indexOf(node.operator) < 0) &&
(node.type !== 'BinaryExpression' || ALL_BINARY_OPERATORS.indexOf(node.operator) < 0) &&
(node.type !== 'LogicalExpression' || LOGICAL_OPERATORS.indexOf(node.operator) < 0) &&
node.type !== 'MemberExpression' &&
node.type !== 'ConditionalExpression' &&
// es2015
node.type !== 'SpreadElement' &&
node.type !== 'TemplateLiteral'
) {
// Can not be sure that a node has no side effects
result = false
this.break()
}
}
})
return result
}
// ------------------------------------------------------------------------------

@@ -70,5 +140,5 @@ // Rule Definition

category: 'recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/order-in-components.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/order-in-components.md'
},
fixable: null,
fixable: 'code', // null or "code" or "whitespace"
schema: [

@@ -92,2 +162,3 @@ {

const orderMap = getOrderMap(extendedOrder)
const sourceCode = context.getSourceCode()

@@ -116,2 +187,31 @@ function checkOrder (propertiesNodes, orderMap) {

line
},
fix (fixer) {
const propertyNode = property.parent
const firstUnorderedPropertyNode = firstUnorderedProperty.parent
const hasSideEffectsPossibility = propertiesNodes
.slice(
propertiesNodes.indexOf(firstUnorderedPropertyNode),
propertiesNodes.indexOf(propertyNode) + 1
)
.some((property) => !isNotSideEffectsNode(property, sourceCode.visitorKeys))
if (hasSideEffectsPossibility) {
return undefined
}
const comma = sourceCode.getTokenAfter(propertyNode)
const hasAfterComma = isComma(comma)
const codeStart = sourceCode.getTokenBefore(propertyNode).range[1] // to include comments
const codeEnd = hasAfterComma ? comma.range[1] : propertyNode.range[1]
const propertyCode = sourceCode.text.slice(codeStart, codeEnd) + (hasAfterComma ? '' : ',')
const insertTarget = sourceCode.getTokenBefore(firstUnorderedPropertyNode)
// If we can upgrade requirements to `eslint@>4.1.0`, this code can be replaced by:
// return [
// fixer.removeRange([codeStart, codeEnd]),
// fixer.insertTextAfter(insertTarget, propertyCode)
// ]
const insertStart = insertTarget.range[1]
const newCode = propertyCode + sourceCode.text.slice(insertStart, codeStart)
return fixer.replaceTextRange([insertStart, codeEnd], newCode)
}

@@ -118,0 +218,0 @@ })

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/require-component-is.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/require-component-is.md'
},

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

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

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/require-default-prop.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/require-default-prop.md'
},

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

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

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/require-prop-types.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/require-prop-types.md'
},

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

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/require-render-return.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/require-render-return.md'
},

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

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/require-v-for-key.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/require-v-for-key.md'
},

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

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/require-valid-default-prop.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/require-valid-default-prop.md'
},

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

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/return-in-computed-property.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/return-in-computed-property.md'
},

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

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

category: undefined,
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/script-indent.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/script-indent.md'
},

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

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

category: 'recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/this-in-template.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/this-in-template.md'
},

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

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

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/v-bind-style.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/v-bind-style.md'
},

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

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

category: 'strongly-recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/v-on-style.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/v-on-style.md'
},

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

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/valid-template-root.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/valid-template-root.md'
},

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

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/valid-v-bind.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/valid-v-bind.md'
},

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

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/valid-v-cloak.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/valid-v-cloak.md'
},

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

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/valid-v-else-if.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/valid-v-else-if.md'
},

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

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/valid-v-else.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/valid-v-else.md'
},

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

@@ -109,3 +109,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/valid-v-for.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/valid-v-for.md'
},

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

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/valid-v-html.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/valid-v-html.md'
},

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

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/valid-v-if.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/valid-v-if.md'
},

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

@@ -85,3 +85,3 @@ /**

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/valid-v-model.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/valid-v-model.md'
},

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

@@ -26,3 +26,85 @@ /**

])
// https://www.w3.org/TR/uievents-key/
const KEY_ALIASES = new Set([
'unidentified', 'alt', 'alt-graph', 'caps-lock', 'control', 'fn', 'fn-lock',
'meta', 'num-lock', 'scroll-lock', 'shift', 'symbol', 'symbol-lock', 'hyper',
'super', 'enter', 'tab', 'arrow-down', 'arrow-left', 'arrow-right',
'arrow-up', 'end', 'home', 'page-down', 'page-up', 'backspace', 'clear',
'copy', 'cr-sel', 'cut', 'delete', 'erase-eof', 'ex-sel', 'insert', 'paste',
'redo', 'undo', 'accept', 'again', 'attn', 'cancel', 'context-menu', 'escape',
'execute', 'find', 'help', 'pause', 'select', 'zoom-in', 'zoom-out',
'brightness-down', 'brightness-up', 'eject', 'log-off', 'power',
'print-screen', 'hibernate', 'standby', 'wake-up', 'all-candidates',
'alphanumeric', 'code-input', 'compose', 'convert', 'dead', 'final-mode',
'group-first', 'group-last', 'group-next', 'group-previous', 'mode-change',
'next-candidate', 'non-convert', 'previous-candidate', 'process',
'single-candidate', 'hangul-mode', 'hanja-mode', 'junja-mode', 'eisu',
'hankaku', 'hiragana', 'hiragana-katakana', 'kana-mode', 'kanji-mode',
'katakana', 'romaji', 'zenkaku', 'zenkaku-hankaku', 'f1', 'f2', 'f3', 'f4',
'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12', 'soft1', 'soft2', 'soft3',
'soft4', 'channel-down', 'channel-up', 'close', 'mail-forward', 'mail-reply',
'mail-send', 'media-close', 'media-fast-forward', 'media-pause',
'media-play-pause', 'media-record', 'media-rewind', 'media-stop',
'media-track-next', 'media-track-previous', 'new', 'open', 'print', 'save',
'spell-check', 'key11', 'key12', 'audio-balance-left', 'audio-balance-right',
'audio-bass-boost-down', 'audio-bass-boost-toggle', 'audio-bass-boost-up',
'audio-fader-front', 'audio-fader-rear', 'audio-surround-mode-next',
'audio-treble-down', 'audio-treble-up', 'audio-volume-down',
'audio-volume-up', 'audio-volume-mute', 'microphone-toggle',
'microphone-volume-down', 'microphone-volume-up', 'microphone-volume-mute',
'speech-correction-list', 'speech-input-toggle', 'launch-application1',
'launch-application2', 'launch-calendar', 'launch-contacts', 'launch-mail',
'launch-media-player', 'launch-music-player', 'launch-phone',
'launch-screen-saver', 'launch-spreadsheet', 'launch-web-browser',
'launch-web-cam', 'launch-word-processor', 'browser-back',
'browser-favorites', 'browser-forward', 'browser-home', 'browser-refresh',
'browser-search', 'browser-stop', 'app-switch', 'call', 'camera',
'camera-focus', 'end-call', 'go-back', 'go-home', 'headset-hook',
'last-number-redial', 'notification', 'manner-mode', 'voice-dial', 't-v',
't-v3-d-mode', 't-v-antenna-cable', 't-v-audio-description',
't-v-audio-description-mix-down', 't-v-audio-description-mix-up',
't-v-contents-menu', 't-v-data-service', 't-v-input', 't-v-input-component1',
't-v-input-component2', 't-v-input-composite1', 't-v-input-composite2',
't-v-input-h-d-m-i1', 't-v-input-h-d-m-i2', 't-v-input-h-d-m-i3',
't-v-input-h-d-m-i4', 't-v-input-v-g-a1', 't-v-media-context', 't-v-network',
't-v-number-entry', 't-v-power', 't-v-radio-service', 't-v-satellite',
't-v-satellite-b-s', 't-v-satellite-c-s', 't-v-satellite-toggle',
't-v-terrestrial-analog', 't-v-terrestrial-digital', 't-v-timer',
'a-v-r-input', 'a-v-r-power', 'color-f0-red', 'color-f1-green',
'color-f2-yellow', 'color-f3-blue', 'color-f4-grey', 'color-f5-brown',
'closed-caption-toggle', 'dimmer', 'display-swap', 'd-v-r', 'exit',
'favorite-clear0', 'favorite-clear1', 'favorite-clear2', 'favorite-clear3',
'favorite-recall0', 'favorite-recall1', 'favorite-recall2',
'favorite-recall3', 'favorite-store0', 'favorite-store1', 'favorite-store2',
'favorite-store3', 'guide', 'guide-next-day', 'guide-previous-day', 'info',
'instant-replay', 'link', 'list-program', 'live-content', 'lock',
'media-apps', 'media-last', 'media-skip-backward', 'media-skip-forward',
'media-step-backward', 'media-step-forward', 'media-top-menu', 'navigate-in',
'navigate-next', 'navigate-out', 'navigate-previous', 'next-favorite-channel',
'next-user-profile', 'on-demand', 'pairing', 'pin-p-down', 'pin-p-move',
'pin-p-toggle', 'pin-p-up', 'play-speed-down', 'play-speed-reset',
'play-speed-up', 'random-toggle', 'rc-low-battery', 'record-speed-next',
'rf-bypass', 'scan-channels-toggle', 'screen-mode-next', 'settings',
'split-screen-toggle', 's-t-b-input', 's-t-b-power', 'subtitle', 'teletext',
'video-mode-next', 'wink', 'zoom-toggle', 'audio-volume-down',
'audio-volume-up', 'audio-volume-mute', 'browser-back', 'browser-forward',
'channel-down', 'channel-up', 'context-menu', 'eject', 'end', 'enter', 'home',
'media-fast-forward', 'media-play', 'media-play-pause', 'media-record',
'media-rewind', 'media-stop', 'media-next-track', 'media-pause',
'media-previous-track', 'power', 'unidentified'
])
function isValidModifier (modifier) {
return (
// built-in aliases
VALID_MODIFIERS.has(modifier) ||
// keyCode
Number.isInteger(parseInt(modifier, 10)) ||
// keyAlias (an Unicode character)
Array.from(modifier).length === 1 ||
// keyAlias (special keys)
KEY_ALIASES.has(modifier)
)
}
// ------------------------------------------------------------------------------

@@ -37,3 +119,3 @@ // Rule Definition

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/valid-v-on.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/valid-v-on.md'
},

@@ -48,3 +130,3 @@ fixable: null,

for (const modifier of node.key.modifiers) {
if (!VALID_MODIFIERS.has(modifier) && !Number.isInteger(parseInt(modifier, 10))) {
if (!isValidModifier(modifier)) {
context.report({

@@ -51,0 +133,0 @@ node,

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/valid-v-once.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/valid-v-once.md'
},

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

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/valid-v-pre.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/valid-v-pre.md'
},

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

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/valid-v-show.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/valid-v-show.md'
},

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

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

category: 'essential',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.2.2/docs/rules/valid-v-text.md'
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.3.0/docs/rules/valid-v-text.md'
},

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

@@ -18,2 +18,14 @@ const assert = require('assert')

/**
* Convert text to snake_case
* @param {string} str Text to be converted
* @return {string}
*/
function snakeCase (str) {
return str
.replace(/([a-z])([A-Z])/g, match => match[0] + '_' + match[1])
.replace(invalidChars, '_')
.toLowerCase()
}
/**
* Convert text to camelCase

@@ -46,2 +58,3 @@ * @param {string} str Text to be converted

'kebab-case': kebabCase,
'snake_case': snakeCase,
'camelCase': camelCase,

@@ -48,0 +61,0 @@ 'PascalCase': pascalCase

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

const BLOCK_COMMENT_PREFIX = /^\s*\*/
const TRIVIAL_PUNCTUATOR = /^[(){}[\],;]$/

@@ -249,2 +250,17 @@ /**

/**
* Check whether a given token is trivial or not.
* @param {Token} token The token to check.
* @returns {boolean} `true` if the token is trivial.
*/
function isTrivialToken (token) {
return token != null && (
(token.type === 'Punctuator' && TRIVIAL_PUNCTUATOR.test(token.value)) ||
token.type === 'HTMLTagOpen' ||
token.type === 'HTMLEndTagOpen' ||
token.type === 'HTMLTagClose' ||
token.type === 'HTMLSelfClosingTagClose'
)
}
/**
* Creates AST event handlers for html-indent.

@@ -267,2 +283,3 @@ *

* @param {Token} baseToken The token of the base offset.
* @param {boolean} [trivial=false] The flag for trivial tokens.
* @returns {void}

@@ -358,5 +375,3 @@ */

while ((t = tokenStore.getTokenAfter(t)) != null && t.range[1] <= elementTokens.firstToken.range[0]) {
if (lastToken.loc.end.line !== t.loc.start.line) {
alignTokens.push(t)
}
alignTokens.push(t)
}

@@ -557,2 +572,3 @@ }

function getExpectedIndent (tokens) {
const trivial = isTrivialToken(tokens[0])
let expectedIndent = Number.MAX_SAFE_INTEGER

@@ -564,3 +580,4 @@

if (offsetInfo != null) {
// If the first token is not trivial then ignore trivial following tokens.
if (offsetInfo != null && (trivial || !isTrivialToken(token))) {
if (offsetInfo.expectedIndent != null) {

@@ -640,4 +657,12 @@ expectedIndent = Math.min(expectedIndent, offsetInfo.expectedIndent)

const line = token.loc.start.line
const indentText = getIndentText(token)
// If there is no line terminator after the `<script>` start tag,
// `indentText` contains non-whitespace characters.
// In that case, do nothing in order to prevent removing the `<script>` tag.
if (indentText.trim() !== '') {
return
}
const actualIndent = token.loc.start.column
const indentText = getIndentText(token)
const unit = (options.indentChar === '\t' ? 'tab' : 'space')

@@ -1431,5 +1456,9 @@

const info = offsets.get(tokenStore.getFirstToken(node))
const lastToken = tokenStore.getLastToken(node)
if (info == null) {
return
}
if (isSemicolon(lastToken)) {
offsets.set(lastToken, info)
}

@@ -1440,12 +1469,7 @@ // Set to the semicolon of the previous token for semicolon-free style.

// ;[1,2,3].forEach(f)
const tokens = [
tokenStore.getTokenBefore(node),
tokenStore.getLastToken(node)
].filter(isSemicolon)
// Set offsets if the semicolon is at beginning of line.
for (const token of tokens) {
const prevToken = tokenStore.getTokenBefore(token)
if (prevToken == null || token.loc.end.line !== prevToken.loc.start.line) {
offsets.set(token, info)
const prevToken = tokenStore.getTokenBefore(node)
if (isSemicolon(prevToken)) {
const prevPrevToken = tokenStore.getTokenBefore(prevToken)
if (prevPrevToken == null || prevToken.loc.end.line !== prevPrevToken.loc.start.line) {
offsets.set(prevToken, info)
}

@@ -1452,0 +1476,0 @@ }

@@ -387,8 +387,11 @@ /**

callee.property.type === 'Identifier' &&
(callee.property.name === 'component' || callee.property.name === 'mixin') &&
node.arguments.length &&
['component', 'mixin', 'extend'].indexOf(callee.property.name) > -1 &&
node.arguments.length >= 1 &&
node.arguments.slice(-1)[0].type === 'ObjectExpression'
const isDestructedVueComponent = callee.type === 'Identifier' &&
callee.name === 'component'
const isDestructedVueComponent = node.type === 'CallExpression' &&
callee.type === 'Identifier' &&
callee.name === 'component' &&
node.arguments.length >= 1 &&
node.arguments.slice(-1)[0].type === 'ObjectExpression'

@@ -395,0 +398,0 @@ return isFullVueComponent || isDestructedVueComponent

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

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

"dependencies": {
"vue-eslint-parser": "^2.0.1"
"vue-eslint-parser": "^2.0.3"
},

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

@@ -18,2 +18,4 @@ # eslint-plugin-vue

- [ESLint](http://eslint.org/) `>=3.18.0`.
- `>=4.7.0` to use `eslint --fix`.
- `>=4.14.0` to use with `babel-eslint`.
- Node.js `>=4.0.0`

@@ -52,2 +54,4 @@

* `Vue.component()` expression
* `Vue.extend()` expression
* `Vue.mixin()` expression
* `export default {}` in `.vue` or `.jsx` file

@@ -177,3 +181,3 @@

| :wrench: | [vue/html-self-closing](./docs/rules/html-self-closing.md) | enforce self-closing style |
| | [vue/max-attributes-per-line](./docs/rules/max-attributes-per-line.md) | enforce the maximum number of attributes per line |
| :wrench: | [vue/max-attributes-per-line](./docs/rules/max-attributes-per-line.md) | enforce the maximum number of attributes per line |
| :wrench: | [vue/mustache-interpolation-spacing](./docs/rules/mustache-interpolation-spacing.md) | enforce unified spacing in mustache interpolations |

@@ -199,5 +203,6 @@ | :wrench: | [vue/name-property-casing](./docs/rules/name-property-casing.md) | enforce specific casing for the name property in Vue components |

|:---|:--------|:------------|
| | [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-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 |
| | [vue/order-in-components](./docs/rules/order-in-components.md) | enforce order of properties in components |
| :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 |

@@ -211,2 +216,3 @@

| :wrench: | [vue/html-closing-bracket-spacing](./docs/rules/html-closing-bracket-spacing.md) | require or disallow a space before tag's closing brackets |
| | [vue/prop-name-casing](./docs/rules/prop-name-casing.md) | enforce specific casing for the Prop name in Vue components |
| :wrench: | [vue/script-indent](./docs/rules/script-indent.md) | enforce consistent indentation in `<script>` |

@@ -240,10 +246,16 @@

### Can my javascript code have increased indentation?
### Why doesn't it work on .vue file?
It depends on the version of eslint you're using.
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-vue-plugin` requires `<script>` tags and `<template>` tags in order to distinguish template and script in single file components.
[indent](https://eslint.org/docs/rules/indent) rule in `eslint@3.x` makes it possible, but if you use `eslint@4.x` be aware that this rule has been rewritten and is more strict now, thus it doesn't allow to have increased initial indentation.
```diff
"plugins": [
"vue",
- "html"
]
```
You can however use [indent-legacy](https://eslint.org/docs/rules/indent-legacy) rule instead.
More informations [here](https://eslint.org/docs/user-guide/migrating-to-4.0.0#indent-rewrite).
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`.
- VSCode targets only JavaScript or HTML files by default. You have to add `{"autoFix": true, "language": "vue"}` into `eslint.validate` entry.

@@ -250,0 +262,0 @@ ## :anchor: Semantic Versioning Policy

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