We have been stalled on ESLint 3.8.0 for some time. Current ESLint is 3.13.0. We have been unable to upgrade because of more aggressive reporting on some rules, including indentation. ESLint configuration options and bugfixes are now such that we can reasonably upgrade. PR-URL: https://github.com/nodejs/node/pull/10561 Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
39 lines
1 KiB
JavaScript
39 lines
1 KiB
JavaScript
/**
|
|
* @fileoverview Rule to flag use of an object property of the global object (Math and JSON) as a function
|
|
* @author James Allardice
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Rule Definition
|
|
//------------------------------------------------------------------------------
|
|
|
|
module.exports = {
|
|
meta: {
|
|
docs: {
|
|
description: "disallow calling global object properties as functions",
|
|
category: "Possible Errors",
|
|
recommended: true
|
|
},
|
|
|
|
schema: []
|
|
},
|
|
|
|
create(context) {
|
|
|
|
return {
|
|
CallExpression(node) {
|
|
|
|
if (node.callee.type === "Identifier") {
|
|
const name = node.callee.name;
|
|
|
|
if (name === "Math" || name === "JSON" || name === "Reflect") {
|
|
context.report({ node, message: "'{{name}}' is not a function.", data: { name } });
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
}
|
|
};
|