PR-URL: https://github.com/nodejs/node/pull/6132 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: thefourtheye <thechargingvolcano@gmail.com>
27 lines
712 B
JavaScript
27 lines
712 B
JavaScript
/**
|
|
* @fileoverview Rule to flag when using constructor for wrapper objects
|
|
* @author Ilya Volodin
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Rule Definition
|
|
//------------------------------------------------------------------------------
|
|
|
|
module.exports = function(context) {
|
|
|
|
return {
|
|
|
|
"NewExpression": function(node) {
|
|
var wrapperObjects = ["String", "Number", "Boolean", "Math", "JSON"];
|
|
|
|
if (wrapperObjects.indexOf(node.callee.name) > -1) {
|
|
context.report(node, "Do not use {{fn}} as a constructor.", { fn: node.callee.name });
|
|
}
|
|
}
|
|
};
|
|
|
|
};
|
|
|
|
module.exports.schema = [];
|