@cimo/environment
Version:
Environment file processor. Light, fast and secure.
37 lines • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.rules = void 0;
const utils_1 = require("@typescript-eslint/utils");
exports.rules = {
"disallow-array-for-object-type": {
meta: {
type: "problem",
docs: {
description: "Disallow array for object type.",
recommended: false
},
messages: {
disallowArrayForObjectType: "Array for object type are disallowed."
},
schema: []
},
create(context) {
const parserServices = utils_1.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: "disallowArrayForObjectType"
});
}
}
};
}
}
};
//# sourceMappingURL=eslint.customRule.js.map