-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathno-deprecated-v-t.ts
43 lines (38 loc) · 1.19 KB
/
no-deprecated-v-t.ts
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
/**
* @author kazuya kawaguchi (a.k.a. kazupon)
*/
import { defineTemplateBodyVisitor } from '../utils/index'
import { createRule } from '../utils/rule'
import type { RuleContext, RuleListener } from '../types'
import type { AST as VAST } from 'vue-eslint-parser'
function checkDirective(context: RuleContext, node: VAST.VDirective) {
context.report({
node,
message: `'v-t' custom directive is used, but it is deprecated. Use 't' or '$t' instead.`
})
}
function create(context: RuleContext): RuleListener {
return defineTemplateBodyVisitor(context, {
"VAttribute[directive=true][key.name='t']"(node: VAST.VDirective) {
checkDirective(context, node)
},
"VAttribute[directive=true][key.name.name='t']"(node: VAST.VDirective) {
checkDirective(context, node)
}
})
}
export = createRule({
meta: {
type: 'problem',
docs: {
description:
'disallow using deprecated `v-t` custom directive (Deprecated in Vue I18n 11.0.0, removed fully in Vue I18n 12.0.0)',
category: 'Recommended',
url: 'https://eslint-plugin-vue-i18n.intlify.dev/rules/no-deprecated-v-t.html',
recommended: true
},
fixable: null,
schema: []
},
create
})