File tree 4 files changed +7
-25
lines changed
4 files changed +7
-25
lines changed Original file line number Diff line number Diff line change 4
4
*/
5
5
'use strict' ;
6
6
7
- const { isRequireCall } = require ( './rules-utils.js' ) ;
7
+ const { isRequireCall, isString } = require ( './rules-utils.js' ) ;
8
8
9
9
//------------------------------------------------------------------------------
10
10
// Rule Definition
11
11
//------------------------------------------------------------------------------
12
12
13
13
14
- function isString ( node ) {
15
- return node && node . type === 'Literal' && typeof node . value === 'string' ;
16
- }
17
-
18
14
function isTopLevel ( node ) {
19
15
do {
20
16
if ( node . type === 'FunctionDeclaration' ||
Original file line number Diff line number Diff line change 4
4
'use strict' ;
5
5
6
6
const path = require ( 'path' ) ;
7
- const { isRequireCall } = require ( './rules-utils.js' ) ;
7
+ const { isRequireCall, isString } = require ( './rules-utils.js' ) ;
8
8
9
9
//------------------------------------------------------------------------------
10
10
// Rule Definition
@@ -15,15 +15,6 @@ module.exports = function(context) {
15
15
const isESM = context . parserOptions . sourceType === 'module' ;
16
16
const foundModules = [ ] ;
17
17
18
- /**
19
- * Function to check if a node is a string literal.
20
- * @param {ASTNode } node The node to check.
21
- * @returns {boolean } If the node is a string literal.
22
- */
23
- function isString ( node ) {
24
- return node && node . type === 'Literal' && typeof node . value === 'string' ;
25
- }
26
-
27
18
/**
28
19
* Function to check if the path is a module and return its name.
29
20
* @param {String } str The path to check
Original file line number Diff line number Diff line change 4
4
*/
5
5
'use strict' ;
6
6
7
- const { isRequireCall } = require ( './rules-utils.js' ) ;
7
+ const { isRequireCall, isString } = require ( './rules-utils.js' ) ;
8
8
9
9
//------------------------------------------------------------------------------
10
10
// Rule Definition
@@ -25,15 +25,6 @@ module.exports = function(context) {
25
25
return { } ;
26
26
}
27
27
28
- /**
29
- * Function to check if a node is a string literal.
30
- * @param {ASTNode } node The node to check.
31
- * @returns {boolean } If the node is a string literal.
32
- */
33
- function isString ( node ) {
34
- return node && node . type === 'Literal' && typeof node . value === 'string' ;
35
- }
36
-
37
28
/**
38
29
* Function to check if the path is a required module and return its name.
39
30
* @param {String } str The path to check
Original file line number Diff line number Diff line change @@ -8,6 +8,10 @@ function isRequireCall(node) {
8
8
}
9
9
module . exports . isRequireCall = isRequireCall ;
10
10
11
+ module . exports . isString = function ( node ) {
12
+ return node && node . type === 'Literal' && typeof node . value === 'string' ;
13
+ } ;
14
+
11
15
module . exports . isDefiningError = function ( node ) {
12
16
return node . expression &&
13
17
node . expression . type === 'CallExpression' &&
You can’t perform that action at this time.
0 commit comments