Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2023-08-14 17:46:13 +00:00
parent 3f55ff1327
commit 6a54608e14
186 changed files with 1202 additions and 4031 deletions

View file

@ -5,6 +5,12 @@
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const { getVariableByName } = require("./utils/ast-utils");
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
@ -28,18 +34,24 @@ module.exports = {
},
create(context) {
const { sourceCode } = context;
return {
NewExpression(node) {
const wrapperObjects = ["String", "Number", "Boolean"];
const { name } = node.callee;
if (wrapperObjects.includes(node.callee.name)) {
context.report({
node,
messageId: "noConstructor",
data: { fn: node.callee.name }
});
if (wrapperObjects.includes(name)) {
const variable = getVariableByName(sourceCode.getScope(node), name);
if (variable && variable.identifiers.length === 0) {
context.report({
node,
messageId: "noConstructor",
data: { fn: name }
});
}
}
}
};

View file

@ -26,8 +26,8 @@ const {
const anyFunctionPattern = /^(?:Function(?:Declaration|Expression)|ArrowFunctionExpression)$/u;
const anyLoopPattern = /^(?:DoWhile|For|ForIn|ForOf|While)Statement$/u;
const arrayMethodWithThisArgPattern = /^(?:every|filter|find(?:Last)?(?:Index)?|flatMap|forEach|map|some)$/u;
const arrayOrTypedArrayPattern = /Array$/u;
const arrayMethodPattern = /^(?:every|filter|find|findIndex|forEach|map|some)$/u;
const bindOrCallOrApplyPattern = /^(?:bind|call|apply)$/u;
const thisTagPattern = /^[\s*]*@this/mu;
@ -467,12 +467,12 @@ function isArrayFromMethod(node) {
}
/**
* Checks whether or not a node is a method which has `thisArg`.
* Checks whether or not a node is a method which expects a function as a first argument, and `thisArg` as a second argument.
* @param {ASTNode} node A node to check.
* @returns {boolean} Whether or not the node is a method which has `thisArg`.
* @returns {boolean} Whether or not the node is a method which expects a function as a first argument, and `thisArg` as a second argument.
*/
function isMethodWhichHasThisArg(node) {
return isSpecificMemberAccess(node, null, arrayMethodPattern);
return isSpecificMemberAccess(node, null, arrayMethodWithThisArgPattern);
}
/**