Bump the npm group with 6 updates (#1902)
* Bump the npm group with 6 updates Bumps the npm group with 6 updates: | Package | From | To | | --- | --- | --- | | [@octokit/types](https://github.com/octokit/types.ts) | `11.1.0` | `12.0.0` | | [@types/adm-zip](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/adm-zip) | `0.5.1` | `0.5.2` | | [@types/semver](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/semver) | `7.5.2` | `7.5.3` | | [@types/sinon](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/sinon) | `10.0.16` | `10.0.17` | | [eslint](https://github.com/eslint/eslint) | `8.49.0` | `8.50.0` | | [eslint-import-resolver-typescript](https://github.com/import-js/eslint-import-resolver-typescript) | `3.6.0` | `3.6.1` | Updates `@octokit/types` from 11.1.0 to 12.0.0 - [Release notes](https://github.com/octokit/types.ts/releases) - [Commits](https://github.com/octokit/types.ts/compare/v11.1.0...v12.0.0) Updates `@types/adm-zip` from 0.5.1 to 0.5.2 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/adm-zip) Updates `@types/semver` from 7.5.2 to 7.5.3 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/semver) Updates `@types/sinon` from 10.0.16 to 10.0.17 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/sinon) Updates `eslint` from 8.49.0 to 8.50.0 - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v8.49.0...v8.50.0) Updates `eslint-import-resolver-typescript` from 3.6.0 to 3.6.1 - [Release notes](https://github.com/import-js/eslint-import-resolver-typescript/releases) - [Changelog](https://github.com/import-js/eslint-import-resolver-typescript/blob/master/CHANGELOG.md) - [Commits](https://github.com/import-js/eslint-import-resolver-typescript/compare/v3.6.0...v3.6.1) --- updated-dependencies: - dependency-name: "@octokit/types" dependency-type: direct:production update-type: version-update:semver-major dependency-group: npm - dependency-name: "@types/adm-zip" dependency-type: direct:development update-type: version-update:semver-patch dependency-group: npm - dependency-name: "@types/semver" dependency-type: direct:development update-type: version-update:semver-patch dependency-group: npm - dependency-name: "@types/sinon" dependency-type: direct:development update-type: version-update:semver-patch dependency-group: npm - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor dependency-group: npm - dependency-name: eslint-import-resolver-typescript dependency-type: direct:development update-type: version-update:semver-patch dependency-group: npm ... Signed-off-by: dependabot[bot] <support@github.com> * Update checked-in dependencies --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
4818fdd8ec
commit
27cb1e1de5
80 changed files with 117979 additions and 1193 deletions
118
node_modules/eslint/lib/rules/no-object-constructor.js
generated
vendored
Normal file
118
node_modules/eslint/lib/rules/no-object-constructor.js
generated
vendored
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
/**
|
||||
* @fileoverview Rule to disallow calls to the `Object` constructor without an argument
|
||||
* @author Francesco Trotta
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const { getVariableByName, isArrowToken } = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Tests if a node appears at the beginning of an ancestor ExpressionStatement node.
|
||||
* @param {ASTNode} node The node to check.
|
||||
* @returns {boolean} Whether the node appears at the beginning of an ancestor ExpressionStatement node.
|
||||
*/
|
||||
function isStartOfExpressionStatement(node) {
|
||||
const start = node.range[0];
|
||||
let ancestor = node;
|
||||
|
||||
while ((ancestor = ancestor.parent) && ancestor.range[0] === start) {
|
||||
if (ancestor.type === "ExpressionStatement") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description: "Disallow calls to the `Object` constructor without an argument",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/no-object-constructor"
|
||||
},
|
||||
|
||||
hasSuggestions: true,
|
||||
|
||||
schema: [],
|
||||
|
||||
messages: {
|
||||
preferLiteral: "The object literal notation {} is preferable.",
|
||||
useLiteral: "Replace with '{{replacement}}'."
|
||||
}
|
||||
},
|
||||
|
||||
create(context) {
|
||||
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Determines whether or not an object literal that replaces a specified node needs to be enclosed in parentheses.
|
||||
* @param {ASTNode} node The node to be replaced.
|
||||
* @returns {boolean} Whether or not parentheses around the object literal are required.
|
||||
*/
|
||||
function needsParentheses(node) {
|
||||
if (isStartOfExpressionStatement(node)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const prevToken = sourceCode.getTokenBefore(node);
|
||||
|
||||
if (prevToken && isArrowToken(prevToken)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports on nodes where the `Object` constructor is called without arguments.
|
||||
* @param {ASTNode} node The node to evaluate.
|
||||
* @returns {void}
|
||||
*/
|
||||
function check(node) {
|
||||
if (node.callee.type !== "Identifier" || node.callee.name !== "Object" || node.arguments.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const variable = getVariableByName(sourceCode.getScope(node), "Object");
|
||||
|
||||
if (variable && variable.identifiers.length === 0) {
|
||||
const replacement = needsParentheses(node) ? "({})" : "{}";
|
||||
|
||||
context.report({
|
||||
node,
|
||||
messageId: "preferLiteral",
|
||||
suggest: [
|
||||
{
|
||||
messageId: "useLiteral",
|
||||
data: { replacement },
|
||||
fix: fixer => fixer.replaceText(node, replacement)
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
CallExpression: check,
|
||||
NewExpression: check
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue