persona-community-5/.pnpm-store/v3/files/87/586a0e6cdba3a2f9edc2da4242395548d991e8b970a4e0004e477878a9dd621cbbeda26e17936ff573f5c42d3a6489a9ed7707fc73cc205e2c389926688c2c
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

55 lines
2.0 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-unsafe-declaration-merging',
meta: {
type: 'problem',
docs: {
description: 'Disallow unsafe declaration merging',
recommended: 'recommended',
requiresTypeChecking: false,
},
messages: {
unsafeMerging: 'Unsafe declaration merging between classes and interfaces.',
},
schema: [],
},
defaultOptions: [],
create(context) {
function checkUnsafeDeclaration(scope, node, unsafeKind) {
const variable = scope.set.get(node.name);
if (!variable) {
return;
}
const defs = variable.defs;
if (defs.length <= 1) {
return;
}
if (defs.some(def => def.node.type === unsafeKind)) {
context.report({
node,
messageId: 'unsafeMerging',
});
}
}
return {
ClassDeclaration(node) {
if (node.id) {
// by default eslint returns the inner class scope for the ClassDeclaration node
// but we want the outer scope within which merged variables will sit
const currentScope = context.sourceCode.getScope(node).upper;
if (currentScope == null) {
return;
}
checkUnsafeDeclaration(currentScope, node.id, utils_1.AST_NODE_TYPES.TSInterfaceDeclaration);
}
},
TSInterfaceDeclaration(node) {
checkUnsafeDeclaration(context.sourceCode.getScope(node), node.id, utils_1.AST_NODE_TYPES.ClassDeclaration);
},
};
},
});
//# sourceMappingURL=no-unsafe-declaration-merging.js.map