eslint-plugin-vue
Advanced tools
Comparing version 7.0.0-beta.2 to 7.0.0-beta.3
@@ -27,2 +27,3 @@ /* | ||
'vue/no-use-v-if-with-v-for': 'error', | ||
'vue/no-v-for-template-key': 'error', | ||
'vue/no-v-model-argument': 'error', | ||
@@ -29,0 +30,0 @@ 'vue/require-component-is': 'error', |
@@ -44,2 +44,3 @@ /* | ||
'vue/no-use-v-if-with-v-for': 'error', | ||
'vue/no-v-for-template-key-on-child': 'error', | ||
'vue/no-watch-after-await': 'error', | ||
@@ -46,0 +47,0 @@ 'vue/require-component-is': 'error', |
@@ -112,2 +112,4 @@ /* | ||
'no-useless-v-bind': require('./rules/no-useless-v-bind'), | ||
'no-v-for-template-key-on-child': require('./rules/no-v-for-template-key-on-child'), | ||
'no-v-for-template-key': require('./rules/no-v-for-template-key'), | ||
'no-v-html': require('./rules/no-v-html'), | ||
@@ -114,0 +116,0 @@ 'no-v-model-argument': require('./rules/no-v-model-argument'), |
@@ -27,3 +27,7 @@ /** | ||
fixable: null, | ||
schema: [] | ||
schema: [], | ||
messages: { | ||
disallow: | ||
"'<template>' cannot be keyed. Place the key on real elements instead." | ||
} | ||
}, | ||
@@ -35,11 +39,16 @@ /** @param {RuleContext} context */ | ||
"VElement[name='template']"(node) { | ||
if ( | ||
utils.hasAttribute(node, 'key') || | ||
utils.hasDirective(node, 'bind', 'key') | ||
) { | ||
const keyNode = | ||
utils.getAttribute(node, 'key') || | ||
utils.getDirective(node, 'bind', 'key') | ||
if (keyNode) { | ||
if (utils.hasDirective(node, 'for')) { | ||
// It's valid for Vue.js 3.x. | ||
// <template v-for="item in list" :key="item.id"> ... </template> | ||
// see https://github.com/vuejs/vue-next/issues/1734 | ||
return | ||
} | ||
context.report({ | ||
node, | ||
loc: node.loc, | ||
message: | ||
"'<template>' cannot be keyed. Place the key on real elements instead." | ||
node: keyNode, | ||
loc: keyNode.loc, | ||
messageId: 'disallow' | ||
}) | ||
@@ -46,0 +55,0 @@ } |
@@ -36,2 +36,5 @@ /** | ||
function checkKey(element) { | ||
if (utils.hasDirective(element, 'bind', 'key')) { | ||
return | ||
} | ||
if (element.name === 'template' || element.name === 'slot') { | ||
@@ -43,6 +46,3 @@ for (const child of element.children) { | ||
} | ||
} else if ( | ||
!utils.isCustomComponent(element) && | ||
!utils.hasDirective(element, 'bind', 'key') | ||
) { | ||
} else if (!utils.isCustomComponent(element)) { | ||
context.report({ | ||
@@ -49,0 +49,0 @@ node: element.startTag, |
@@ -73,3 +73,5 @@ /** | ||
function checkKey(context, vFor, element) { | ||
if (element.name === 'template') { | ||
const vBindKey = utils.getDirective(element, 'bind', 'key') | ||
if (vBindKey == null && element.name === 'template') { | ||
for (const child of element.children) { | ||
@@ -83,4 +85,2 @@ if (child.type === 'VElement') { | ||
const vBindKey = utils.getDirective(element, 'bind', 'key') | ||
if (utils.isCustomComponent(element) && vBindKey == null) { | ||
@@ -87,0 +87,0 @@ context.report({ |
// https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values | ||
/** @type { { [key: number]: string } } */ | ||
module.exports = { | ||
'8': 'backspace', | ||
'9': 'tab', | ||
'13': 'enter', | ||
'16': 'shift', | ||
'17': 'ctrl', | ||
'18': 'alt', | ||
'19': 'pause', // windows | ||
'20': 'caps-lock', | ||
'27': 'escape', | ||
'32': 'space', // Vue.js specially key name. | ||
'33': 'page-up', | ||
'34': 'page-down', | ||
'35': 'end', | ||
'36': 'home', | ||
'37': 'arrow-left', | ||
'38': 'arrow-up', | ||
'39': 'arrow-right', | ||
'40': 'arrow-down', | ||
'45': 'insert', // windows | ||
'46': 'delete', | ||
8: 'backspace', | ||
9: 'tab', | ||
13: 'enter', | ||
16: 'shift', | ||
17: 'ctrl', | ||
18: 'alt', | ||
19: 'pause', // windows | ||
20: 'caps-lock', | ||
27: 'escape', | ||
32: 'space', // Vue.js specially key name. | ||
33: 'page-up', | ||
34: 'page-down', | ||
35: 'end', | ||
36: 'home', | ||
37: 'arrow-left', | ||
38: 'arrow-up', | ||
39: 'arrow-right', | ||
40: 'arrow-down', | ||
45: 'insert', // windows | ||
46: 'delete', | ||
@@ -37,28 +37,28 @@ // If mistakenly use it in Vue.js 2.x, it will be irreversibly broken. Therefore, it will not be autofix. | ||
'65': 'a', | ||
'66': 'b', | ||
'67': 'c', | ||
'68': 'd', | ||
'69': 'e', | ||
'70': 'f', | ||
'71': 'g', | ||
'72': 'h', | ||
'73': 'i', | ||
'74': 'j', | ||
'75': 'k', | ||
'76': 'l', | ||
'77': 'm', | ||
'78': 'n', | ||
'79': 'o', | ||
'80': 'p', | ||
'81': 'q', | ||
'82': 'r', | ||
'83': 's', | ||
'84': 't', | ||
'85': 'u', | ||
'86': 'v', | ||
'87': 'w', | ||
'88': 'x', | ||
'89': 'y', | ||
'90': 'z', | ||
65: 'a', | ||
66: 'b', | ||
67: 'c', | ||
68: 'd', | ||
69: 'e', | ||
70: 'f', | ||
71: 'g', | ||
72: 'h', | ||
73: 'i', | ||
74: 'j', | ||
75: 'k', | ||
76: 'l', | ||
77: 'm', | ||
78: 'n', | ||
79: 'o', | ||
80: 'p', | ||
81: 'q', | ||
82: 'r', | ||
83: 's', | ||
84: 't', | ||
85: 'u', | ||
86: 'v', | ||
87: 'w', | ||
88: 'x', | ||
89: 'y', | ||
90: 'z', | ||
@@ -86,16 +86,16 @@ // The key value may change depending on the OS. | ||
// '111': 'divide', | ||
'112': 'f1', | ||
'113': 'f2', | ||
'114': 'f3', | ||
'115': 'f4', | ||
'116': 'f5', | ||
'117': 'f6', | ||
'118': 'f7', | ||
'119': 'f8', | ||
'120': 'f9', | ||
'121': 'f10', | ||
'122': 'f11', | ||
'123': 'f12', | ||
'144': 'num-lock', | ||
'145': 'scroll-lock' | ||
112: 'f1', | ||
113: 'f2', | ||
114: 'f3', | ||
115: 'f4', | ||
116: 'f5', | ||
117: 'f6', | ||
118: 'f7', | ||
119: 'f8', | ||
120: 'f9', | ||
121: 'f10', | ||
122: 'f11', | ||
123: 'f12', | ||
144: 'num-lock', | ||
145: 'scroll-lock' | ||
} |
{ | ||
"name": "eslint-plugin-vue", | ||
"version": "7.0.0-beta.2", | ||
"version": "7.0.0-beta.3", | ||
"description": "Official ESLint plugin for Vue.js", | ||
@@ -79,3 +79,3 @@ "main": "lib/index.js", | ||
"nyc": "^15.0.1", | ||
"prettier": "^2.0.5", | ||
"prettier": "^2.1.1", | ||
"typescript": "^3.9.5", | ||
@@ -82,0 +82,0 @@ "vue-eslint-editor": "^1.1.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
737249
199
22648