/
githubmirror
/
eslint-plugin
Обзор
Документация
Войти
/
githubmirror
/
eslint-plugin
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
lib/rules/objectAssign.ts
42 строки
2 KB
saberzero1
refactor: streamline meta.docs.url for static analysis
10 июн 2026, 16:14
10 июн 2026, 16:14
13385bc
Код
Авторство
О чём код?
import { TSESTree } from "@typescript-eslint/utils"; import { docsUrl, ruleCreator } from "../ruleCreator.js"; export default ruleCreator({ meta: { type: "problem" as const, docs: { description: "Discourage using `Object.assign` with two arguments", url: docsUrl("object-assign"), }, schema: [], messages: { twoArgumentsDefault: "Using `Object.assign` with an non-empty target object can lead to unexpected behaviour as it will overwrite the target object.", }, }, defaultOptions: [], create(context) { return { CallExpression(node: TSESTree.CallExpression) { if ( node.callee && node.callee.type === TSESTree.AST_NODE_TYPES.MemberExpression && node.callee.object && node.callee.object.type === TSESTree.AST_NODE_TYPES.Identifier && node.callee.object.name === "Object" && node.callee.property && node.callee.property.type === TSESTree.AST_NODE_TYPES.Identifier && node.callee.property.name === "assign" && node.arguments.length === 2 && node.arguments[0].type === TSESTree.AST_NODE_TYPES.Identifier && node.arguments[0].name.toLowerCase().includes("default") && node.arguments[1].type !== TSESTree.AST_NODE_TYPES.ObjectExpression ) { context.report({ node, messageId: "twoArgumentsDefault", }); } }, }; }, });