8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 38797b5 commit fc6ee39Copy full SHA for fc6ee39
tools/eslint-rules/alphabetize-errors.js
@@ -1,19 +1,14 @@
1
'use strict';
2
3
+const { isDefiningError } = require('./rules-utils.js');
4
+
5
const prefix = 'Out of ASCIIbetical order - ';
6
const opStr = ' >= ';
7
8
function errorForNode(node) {
9
return node.expression.arguments[0].value;
10
}
11
-function isDefiningError(node) {
- return node.expression &&
12
- node.expression.type === 'CallExpression' &&
13
- node.expression.callee &&
14
- node.expression.callee.name === 'E';
15
-}
16
-
17
module.exports = {
18
create: function(context) {
19
let previousNode;
tools/eslint-rules/documented-errors.js
@@ -2,6 +2,7 @@
const fs = require('fs');
const path = require('path');
const doc = fs.readFileSync(path.resolve(__dirname, '../../doc/api/errors.md'),
'utf8');
@@ -18,18 +19,11 @@ function errorForNode(node) {
20
21
22
23
24
25
26
27
28
29
30
return {
31
ExpressionStatement: function(node) {
32
- if (!isDefiningError(node)) return;
+ if (!isDefiningError(node) || !errorForNode(node)) return;
33
const code = errorForNode(node);
34
if (!isInDoc(code)) {
35
const message = `"${code}" is not documented in doc/api/errors.md`;
tools/eslint-rules/prefer-util-format-errors.js
@@ -1,5 +1,7 @@
const errMsg = 'Please use a printf-like formatted string that util.format' +
' can consume.';
@@ -8,18 +10,11 @@ function isArrowFunctionWithTemplateLiteral(node) {
node.body.type === 'TemplateLiteral';
- if (!isDefiningError(node))
+ if (!isDefiningError(node) || node.expression.arguments.length < 2)
return;
const msg = node.expression.arguments[1];
tools/eslint-rules/rules-utils.js
@@ -3,6 +3,14 @@
*/
+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.