/
githubmirror
/
eslint-plugin
Обзор
Документация
Войти
/
githubmirror
/
eslint-plugin
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
0.1.0
lib/rules/objectAssign.ts
42 строки
1 KB
Emile Bangma
Format files
04 июн 2025, 13:30
Не верифицирован
04 июн 2025, 13:30
cedc267
Код
Авторство
О чём код?
import { TSESTree, TSESLint } from "@typescript-eslint/utils"; export default { name: "object-assign", meta: { type: "problem" as const, docs: { description: "Object.assign with two parameters instead of 3.", //TODO: Add url }, schema: [], messages: { twoArgumentsDefault: "Doing this will reassign the default.", }, }, defaultOptions: [], create(context: TSESLint.RuleContext<"twoArgumentsDefault", []>) { return { CallExpression(node: TSESTree.CallExpression) { if ( node.callee && node.callee.type === "MemberExpression" && node.callee.object && node.callee.object.type === "Identifier" && node.callee.object.name === "Object" && node.callee.property && node.callee.property.type === "Identifier" && node.callee.property.name === "assign" && node.arguments.length === 2 && node.arguments[0].type === "Identifier" && node.arguments[0].name.toLowerCase().includes("default") && node.arguments[1].type !== "ObjectExpression" ) { context.report({ node, messageId: "twoArgumentsDefault", }); } }, }; }, };