-
-
Notifications
You must be signed in to change notification settings - Fork 666
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
vue/no-deprecated-vue-config-keycodes
rule (#1118)
- Loading branch information
Showing
7 changed files
with
149 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
pageClass: rule-details | ||
sidebarDepth: 0 | ||
title: vue/no-deprecated-vue-config-keycodes | ||
description: disallow using deprecated `Vue.config.keyCodes` (in Vue.js 3.0.0+) | ||
--- | ||
# vue/no-deprecated-vue-config-keycodes | ||
> disallow using deprecated `Vue.config.keyCodes` (in Vue.js 3.0.0+) | ||
- :gear: This rule is included in all of `"plugin:vue/vue3-essential"`, `"plugin:vue/vue3-strongly-recommended"` and `"plugin:vue/vue3-recommended"`. | ||
|
||
## :book: Rule Details | ||
|
||
This rule reports use of deprecated `Vue.config.keyCodes` (in Vue.js 3.0.0+) | ||
|
||
<eslint-code-block filename="a.js" language="javascript ":rules="{'vue/no-deprecated-vue-config-keycodes': ['error']}"> | ||
|
||
```js | ||
/* ✗ BAD */ | ||
Vue.config.keyCodes = { | ||
// ... | ||
} | ||
``` | ||
|
||
</eslint-code-block> | ||
|
||
## :wrench: Options | ||
|
||
Nothing. | ||
|
||
## :couple: Related rules | ||
|
||
- [vue/no-deprecated-v-on-number-modifiers] | ||
- [API - Global Config - keyCodes] | ||
|
||
[vue/no-deprecated-v-on-number-modifiers]: ./no-deprecated-v-on-number-modifiers.md | ||
[API - Global Config - keyCodes]: https://vuejs.org/v2/api/#keyCodes | ||
|
||
## :books: Further reading | ||
|
||
- [Vue RFCs - 0014-drop-keycode-support](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0014-drop-keycode-support.md) | ||
|
||
## :mag: Implementation | ||
|
||
- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/no-deprecated-vue-config-keycodes.js) | ||
- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/no-deprecated-vue-config-keycodes.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* @author Yosuke Ota | ||
* See LICENSE file in root directory for full license. | ||
*/ | ||
'use strict' | ||
|
||
// ------------------------------------------------------------------------------ | ||
// Rule Definition | ||
// ------------------------------------------------------------------------------ | ||
|
||
module.exports = { | ||
meta: { | ||
type: 'problem', | ||
docs: { | ||
description: 'disallow using deprecated `Vue.config.keyCodes` (in Vue.js 3.0.0+)', | ||
categories: ['vue3-essential'], | ||
url: 'https://eslint.vuejs.org/rules/no-deprecated-vue-config-keycodes.html' | ||
}, | ||
fixable: null, | ||
schema: [], | ||
messages: { | ||
unexpected: '`Vue.config.keyCodes` are deprecated.' | ||
} | ||
}, | ||
|
||
create: function (context) { | ||
return { | ||
"MemberExpression[property.type='Identifier'][property.name='keyCodes']" (node) { | ||
const config = node.object | ||
if (config.type !== 'MemberExpression' || | ||
config.property.type !== 'Identifier' || | ||
config.property.name !== 'config' || | ||
config.object.type !== 'Identifier' || | ||
config.object.name !== 'Vue') { | ||
return | ||
} | ||
context.report({ | ||
node, | ||
messageId: 'unexpected' | ||
}) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* @author Yosuke Ota | ||
* See LICENSE file in root directory for full license. | ||
*/ | ||
'use strict' | ||
|
||
// ------------------------------------------------------------------------------ | ||
// Requirements | ||
// ------------------------------------------------------------------------------ | ||
|
||
const rule = require('../../../lib/rules/no-deprecated-vue-config-keycodes') | ||
const RuleTester = require('eslint').RuleTester | ||
|
||
// ------------------------------------------------------------------------------ | ||
// Tests | ||
// ------------------------------------------------------------------------------ | ||
|
||
const ruleTester = new RuleTester({ | ||
parser: require.resolve('vue-eslint-parser'), | ||
parserOptions: { ecmaVersion: 2015 } | ||
}) | ||
|
||
ruleTester.run('no-deprecated-vue-config-keycodes', rule, { | ||
|
||
valid: [ | ||
{ | ||
filename: 'test.js', | ||
code: `Vue.config.silent = true` | ||
}, | ||
{ | ||
filename: 'test.js', | ||
code: 'config.keyCodes = {}' | ||
}, | ||
{ | ||
filename: 'test.js', | ||
code: 'V.config.keyCodes = {}' | ||
} | ||
], | ||
|
||
invalid: [ | ||
{ | ||
filename: 'test.js', | ||
code: 'Vue.config.keyCodes = {}', | ||
errors: [{ | ||
message: '`Vue.config.keyCodes` are deprecated.', | ||
line: 1, | ||
column: 1, | ||
type: 'MemberExpression', | ||
// messageId: 'unexpected', | ||
endLine: 1, | ||
endColumn: 20 | ||
}] | ||
} | ||
] | ||
}) |