UNPKG

@cimo/pid

Version:

Process id. Light, fast and secure.

35 lines 1.29 kB
import { ESLintUtils } from "@typescript-eslint/utils"; const rules = { "no-array-assignment-for-object-type": { meta: { type: "problem", docs: { description: "Safe array assignment for object type.", recommended: false }, messages: { noArrayAssignmentForObjectType: "Array assign for object type is disallowed." }, schema: [] }, create(context) { const parserServices = ESLintUtils.getParserServices(context); return { TSArrayType(node) { const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node.elementType); const checker = parserServices.program.getTypeChecker(); const type = checker.getTypeAtLocation(tsNode); const indexType = type.getStringIndexType(); if (indexType) { context.report({ node, messageId: "noArrayAssignmentForObjectType" }); } } }; } } }; export default { rules }; //# sourceMappingURL=eslint.customRule.js.map