File tree Expand file tree Collapse file tree 4 files changed +7
-25
lines changed Expand file tree Collapse file tree 4 files changed +7
-25
lines changed Original file line number Diff line number Diff line change 44 */
55'use strict' ;
66
7- const { isRequireCall } = require ( './rules-utils.js' ) ;
7+ const { isRequireCall, isString } = require ( './rules-utils.js' ) ;
88
99//------------------------------------------------------------------------------
1010// Rule Definition
1111//------------------------------------------------------------------------------
1212
1313
14- function isString ( node ) {
15- return node && node . type === 'Literal' && typeof node . value === 'string' ;
16- }
17-
1814function isTopLevel ( node ) {
1915 do {
2016 if ( node . type === 'FunctionDeclaration' ||
Original file line number Diff line number Diff line change 44'use strict' ;
55
66const path = require ( 'path' ) ;
7- const { isRequireCall } = require ( './rules-utils.js' ) ;
7+ const { isRequireCall, isString } = require ( './rules-utils.js' ) ;
88
99//------------------------------------------------------------------------------
1010// Rule Definition
@@ -15,15 +15,6 @@ module.exports = function(context) {
1515 const isESM = context . parserOptions . sourceType === 'module' ;
1616 const foundModules = [ ] ;
1717
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-
2718 /**
2819 * Function to check if the path is a module and return its name.
2920 * @param {String } str The path to check
Original file line number Diff line number Diff line change 44 */
55'use strict' ;
66
7- const { isRequireCall } = require ( './rules-utils.js' ) ;
7+ const { isRequireCall, isString } = require ( './rules-utils.js' ) ;
88
99//------------------------------------------------------------------------------
1010// Rule Definition
@@ -25,15 +25,6 @@ module.exports = function(context) {
2525 return { } ;
2626 }
2727
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-
3728 /**
3829 * Function to check if the path is a required module and return its name.
3930 * @param {String } str The path to check
Original file line number Diff line number Diff line change @@ -8,6 +8,10 @@ function isRequireCall(node) {
88}
99module . exports . isRequireCall = isRequireCall ;
1010
11+ module . exports . isString = function ( node ) {
12+ return node && node . type === 'Literal' && typeof node . value === 'string' ;
13+ } ;
14+
1115module . exports . isDefiningError = function ( node ) {
1216 return node . expression &&
1317 node . expression . type === 'CallExpression' &&
You can’t perform that action at this time.
0 commit comments