Skip to content

Commit

Permalink
tools: fix custom eslint rule errors
Browse files Browse the repository at this point in the history
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 <luigipinca@gmail.com>
  • Loading branch information
BridgeAR authored and MylesBorins committed Aug 16, 2018
1 parent 07e2bd4 commit 8140211
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 2 additions & 7 deletions tools/eslint-rules/alphabetize-errors.js
@@ -1,19 +1,14 @@
'use strict';

const { isDefiningError } = require('./rules-utils.js');

const prefix = 'Out of ASCIIbetical order - ';
const opStr = ' >= ';

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

function isDefiningError(node) {
return node.expression &&
node.expression.type === 'CallExpression' &&
node.expression.callee &&
node.expression.callee.name === 'E';
}

module.exports = {
create: function(context) {
let previousNode;
Expand Down
8 changes: 8 additions & 0 deletions tools/eslint-rules/rules-utils.js
Expand Up @@ -3,6 +3,14 @@
*/
'use strict';

module.exports.isDefiningError = function(node) {
return node.expression &&
node.expression.type === 'CallExpression' &&
node.expression.callee &&
node.expression.callee.name === 'E' &&
node.expression.arguments.length !== 0;
};

/**
* Returns true if any of the passed in modules are used in
* require calls.
Expand Down

0 comments on commit 8140211

Please sign in to comment.