4
4
*/
5
5
'use strict' ;
6
6
7
- var has = require ( 'has' ) ;
8
- var Components = require ( '../util/Components' ) ;
7
+ const has = require ( 'has' ) ;
8
+ const Components = require ( '../util/Components' ) ;
9
9
10
10
// ------------------------------------------------------------------------------
11
11
// Rule Definition
@@ -31,11 +31,11 @@ module.exports = {
31
31
} ,
32
32
33
33
create : Components . detect ( function ( context , components , utils ) {
34
- var sourceCode = context . getSourceCode ( ) ;
35
- var config = context . options [ 0 ] || { } ;
36
- var ignoreTranspilerName = config . ignoreTranspilerName || false ;
34
+ const sourceCode = context . getSourceCode ( ) ;
35
+ const config = context . options [ 0 ] || { } ;
36
+ const ignoreTranspilerName = config . ignoreTranspilerName || false ;
37
37
38
- var MISSING_MESSAGE = 'Component definition is missing display name' ;
38
+ const MISSING_MESSAGE = 'Component definition is missing display name' ;
39
39
40
40
/**
41
41
* Checks if we are declaring a display name
@@ -47,7 +47,7 @@ module.exports = {
47
47
// Special case for class properties
48
48
// (babel-eslint does not expose property name so we have to rely on tokens)
49
49
case 'ClassProperty' :
50
- var tokens = sourceCode . getFirstTokens ( node , 2 ) ;
50
+ const tokens = sourceCode . getFirstTokens ( node , 2 ) ;
51
51
if (
52
52
tokens [ 0 ] . value === 'displayName' ||
53
53
( tokens [ 1 ] && tokens [ 1 ] . value === 'displayName' )
@@ -94,7 +94,7 @@ module.exports = {
94
94
* @returns {Boolean } True if component has a name, false if not.
95
95
*/
96
96
function hasTranspilerName ( node ) {
97
- var namedObjectAssignment = (
97
+ const namedObjectAssignment = (
98
98
node . type === 'ObjectExpression' &&
99
99
node . parent &&
100
100
node . parent . parent &&
@@ -105,25 +105,25 @@ module.exports = {
105
105
node . parent . parent . left . property . name !== 'exports'
106
106
)
107
107
) ;
108
- var namedObjectDeclaration = (
108
+ const namedObjectDeclaration = (
109
109
node . type === 'ObjectExpression' &&
110
110
node . parent &&
111
111
node . parent . parent &&
112
112
node . parent . parent . type === 'VariableDeclarator'
113
113
) ;
114
- var namedClass = (
114
+ const namedClass = (
115
115
( node . type === 'ClassDeclaration' || node . type === 'ClassExpression' ) &&
116
116
node . id &&
117
117
node . id . name
118
118
) ;
119
119
120
- var namedFunctionDeclaration = (
120
+ const namedFunctionDeclaration = (
121
121
( node . type === 'FunctionDeclaration' || node . type === 'FunctionExpression' ) &&
122
122
node . id &&
123
123
node . id . name
124
124
) ;
125
125
126
- var namedFunctionExpression = (
126
+ const namedFunctionExpression = (
127
127
( node . type === 'FunctionExpression' || node . type === 'ArrowFunctionExpression' ) &&
128
128
node . parent &&
129
129
( node . parent . type === 'VariableDeclarator' || node . parent . method === true ) &&
@@ -157,7 +157,7 @@ module.exports = {
157
157
if ( ! isDisplayNameDeclaration ( node . property ) ) {
158
158
return ;
159
159
}
160
- var component = utils . getRelatedComponent ( node ) ;
160
+ const component = utils . getRelatedComponent ( node ) ;
161
161
if ( ! component ) {
162
162
return ;
163
163
}
@@ -221,9 +221,9 @@ module.exports = {
221
221
} ,
222
222
223
223
'Program:exit' : function ( ) {
224
- var list = components . list ( ) ;
224
+ const list = components . list ( ) ;
225
225
// Report missing display name for all components
226
- for ( var component in list ) {
226
+ for ( const component in list ) {
227
227
if ( ! has ( list , component ) || list [ component ] . hasDisplayName ) {
228
228
continue ;
229
229
}
0 commit comments