@@ -23,38 +23,6 @@ function getPropertyFromObject(propertyName, node) {
23
23
return null
24
24
}
25
25
26
- /**
27
- * Extracts the `meta` property from the ObjectExpression that all rules export.
28
- *
29
- * @param {ASTNode } exportsNode ObjectExpression node that the rule exports.
30
- * @returns {ASTNode } The `meta` Property node or null if not found.
31
- */
32
- function getMetaPropertyFromExportsNode ( exportsNode ) {
33
- return getPropertyFromObject ( 'meta' , exportsNode )
34
- }
35
-
36
- /**
37
- * Whether this `meta` ObjectExpression has a `docs` property defined or not.
38
- *
39
- * @param {ASTNode } metaPropertyNode The `meta` ObjectExpression for this rule.
40
- * @returns {boolean } `true` if a `docs` property exists.
41
- */
42
- function hasMetaDocs ( metaPropertyNode ) {
43
- return Boolean ( getPropertyFromObject ( 'docs' , metaPropertyNode . value ) )
44
- }
45
-
46
- /**
47
- * Whether this `meta` ObjectExpression has a `docs.category` property defined or not.
48
- *
49
- * @param {ASTNode } metaPropertyNode The `meta` ObjectExpression for this rule.
50
- * @returns {boolean } `true` if a `docs.category` property exists.
51
- */
52
- function hasMetaDocsCategories ( metaPropertyNode ) {
53
- const metaDocs = getPropertyFromObject ( 'docs' , metaPropertyNode . value )
54
-
55
- return metaDocs && getPropertyFromObject ( 'categories' , metaDocs . value )
56
- }
57
-
58
26
/**
59
27
* Checks the validity of the meta definition of this rule and reports any errors found.
60
28
*
@@ -64,8 +32,7 @@ function hasMetaDocsCategories(metaPropertyNode) {
64
32
* @returns {void }
65
33
*/
66
34
function checkMetaValidity ( context , exportsNode ) {
67
- const metaProperty = getMetaPropertyFromExportsNode ( exportsNode )
68
-
35
+ const metaProperty = getPropertyFromObject ( 'meta' , exportsNode )
69
36
if ( ! metaProperty ) {
70
37
context . report ( {
71
38
node : exportsNode ,
@@ -74,15 +41,17 @@ function checkMetaValidity(context, exportsNode) {
74
41
return
75
42
}
76
43
77
- if ( ! hasMetaDocs ( metaProperty ) ) {
44
+ const metaDocs = getPropertyFromObject ( 'docs' , metaProperty . value )
45
+ if ( ! metaDocs ) {
78
46
context . report ( {
79
- node : 'metaDocs' ,
47
+ node : metaProperty ,
80
48
messageId : 'missingMetaDocs'
81
49
} )
82
50
return
83
51
}
84
52
85
- if ( ! hasMetaDocsCategories ( metaProperty ) ) {
53
+ const metaDocsCategories = getPropertyFromObject ( 'categories' , metaDocs . value )
54
+ if ( ! metaDocsCategories ) {
86
55
context . report ( {
87
56
node : metaProperty ,
88
57
messageId : 'missingMetaDocsCategories'
0 commit comments