-
-
Notifications
You must be signed in to change notification settings - Fork 164
/
Copy pathindex.ts
42 lines (37 loc) · 943 Bytes
/
index.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
import { createRule, isTypeImport } from '../../utils'
export default createRule<'no-vue-runtime-import', [{ prefer: string }]>({
meta: {
type: 'problem',
messages: {
'no-vue-runtime-import': 'Please consider import runtime APIs from {{prefer}}.',
},
schema: [
{
type: 'object',
properties: {
prefer: {
type: 'string',
},
},
},
],
},
create(context) {
const options = context.options[0]
return {
ImportDeclaration(node) {
const importSource = node.source.value
const shouldSkip = isTypeImport(node) || importSource !== 'vue'
if (shouldSkip)
return
context.report({
node: node.source,
messageId: 'no-vue-runtime-import',
data: {
prefer: options?.prefer ?? '<set prefer in your eslint config>',
},
})
},
}
},
})