-
-
Notifications
You must be signed in to change notification settings - Fork 681
/
Copy pathno-deprecated-events-api.js
46 lines (40 loc) · 1.3 KB
/
no-deprecated-events-api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* @fileoverview disallow using deprecated events api
* @author yoyo930021
*/
'use strict'
// ------------------------------------------------------------------------------
// Requirements
// ------------------------------------------------------------------------------
const utils = require('../utils')
// ------------------------------------------------------------------------------
// Rule Definition
// ------------------------------------------------------------------------------
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'disallow using deprecated events api (in Vue.js 3.0.0+)',
categories: ['vue3-essential'],
url: 'https://eslint.vuejs.org/rules/no-deprecated-events-api.html'
},
fixable: null,
schema: [],
messages: {
noDeprecatedEventsApi: 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.'
}
},
create (context) {
return utils.defineVueVisitor(context,
{
'CallExpression > MemberExpression > ThisExpression' (node) {
if (!['$on', '$off', '$once'].includes(node.parent.property.name)) return
context.report({
node: node.parent.parent,
messageId: 'noDeprecatedEventsApi'
})
}
}
)
}
}