Skip to content

Commit 3052512

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 faf9a8b commit 3052512

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
const prefix = 'Out of ASCIIbetical order - ';
46
const opStr = ' >= ';
57

68
function errorForNode(node) {
79
return node.expression.arguments[0].value;
810
}
911

10-
function isDefiningError(node) {
11-
return node.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
let previousNode;

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+
return node.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)