mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
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: https://github.com/nodejs/node/pull/18853 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
1 parent
07e2bd4b73
commit
814021182e
2 files changed
+10
-7
No files matched your search
@@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { isDefiningError } = require('./rules-utils.js');
|
||||
|
||||
const prefix = 'Out of ASCIIbetical order - ';
|
||||
const opStr = ' >= ';
|
||||
|
||||
@@ -7,13 +9,6 @@ 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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user