mirror of
https://github.com/nodejs/node.git
synced 2024-11-24 20:29:23 +01:00
3ce4cef4e6
PR-URL: https://github.com/nodejs/node/pull/45889 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
33 lines
771 B
JavaScript
33 lines
771 B
JavaScript
'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;
|
|
}
|
|
|
|
module.exports = {
|
|
create: function(context) {
|
|
let previousNode;
|
|
return {
|
|
ExpressionStatement: function(node) {
|
|
if (!isDefiningError(node)) return;
|
|
if (!previousNode) {
|
|
previousNode = node;
|
|
return;
|
|
}
|
|
const prev = errorForNode(previousNode);
|
|
const curr = errorForNode(node);
|
|
previousNode = node;
|
|
if (prev >= curr) {
|
|
const message = [prefix, prev, opStr, curr].join('');
|
|
context.report({ node, message });
|
|
}
|
|
},
|
|
};
|
|
},
|
|
};
|