forked from vuejs/eslint-plugin-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequire-component-name.js
36 lines (33 loc) · 960 Bytes
/
require-component-name.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
/**
* @fileoverview Require components to have names
* @author Hiroki Osame <[email protected]>
*/
'use strict'
// ------------------------------------------------------------------------------
// Rule Definition
// ------------------------------------------------------------------------------
const utils = require('../utils')
module.exports = {
meta: {
docs: {
description: 'require components to have names',
category: 'recommended',
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.3/docs/rules/require-component-name.md'
},
fixable: null,
schema: [
]
},
create (context) {
return utils.executeOnVueComponent(context, (obj) => {
const hasName = obj.properties.find(prop => prop.key.name === 'name')
if (!hasName) {
context.report({
obj,
loc: obj.loc,
message: 'Expected component to have a name.'
})
}
})
}
}