Skip to content

Commit 8140211

Browse files
BridgeARMylesBorins
authored andcommitted
tools: fix custom eslint rule errors
This fixes a few rules by making sure the input is actually ready to be checked. Otherwise those can throw TypeErrors or result in faulty error messages. PR-URL: #18853 Reviewed-By: Luigi Pinca <[email protected]>
1 parent 07e2bd4 commit 8140211

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

‎tools/eslint-rules/alphabetize-errors.js‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
'use strict';
22

3+
const{ isDefiningError }=require('./rules-utils.js');
4+
35
constprefix='Out of ASCIIbetical order - ';
46
constopStr=' >= ';
57

68
functionerrorForNode(node){
79
returnnode.expression.arguments[0].value;
810
}
911

10-
functionisDefiningError(node){
11-
returnnode.expression&&
12-
node.expression.type==='CallExpression'&&
13-
node.expression.callee&&
14-
node.expression.callee.name==='E';
15-
}
16-
1712
module.exports={
1813
create: function(context){
1914
letpreviousNode;

‎tools/eslint-rules/rules-utils.js‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
*/
44
'use strict';
55

6+
module.exports.isDefiningError=function(node){
7+
returnnode.expression&&
8+
node.expression.type==='CallExpression'&&
9+
node.expression.callee&&
10+
node.expression.callee.name==='E'&&
11+
node.expression.arguments.length!==0;
12+
};
13+
614
/**
715
* Returns true if any of the passed in modules are used in
816
* require calls.

0 commit comments

Comments
(0)