import { isDefined } from "ts-extras";
const docsBaseUrl = "https://nick2bad4u.github.io/eslint-plugin-etc-misc/docs/rules";
/**
 * Create a replacement descriptor for deprecation metadata.
 */
export const createReplacementRuleInfo = (replacement) => ({
    ...(isDefined(replacement.plugin) ? { plugin: replacement.plugin } : {}),
    ...(isDefined(replacement.rule) ? { rule: replacement.rule } : {}),
});
/**
 * Create standardized deprecation metadata for this plugin.
 */
export const createDeprecatedRuleInfo = ({ message, replacedBy = [], ruleId, }) => ({
    availableUntil: "2.0.0",
    deprecatedSince: "1.0.0",
    message,
    ...(replacedBy.length === 0 ? {} : { replacedBy: [...replacedBy] }),
    url: `${docsBaseUrl}/${ruleId.replaceAll("/", "-")}`,
});
/**
 * Apply deprecated+frozen lifecycle metadata to a rule module.
 */
export const withDeprecatedRuleLifecycle = (rule, options) => ({
    ...rule,
    meta: {
        ...rule.meta,
        deprecated: createDeprecatedRuleInfo(options),
        ...(rule.meta.docs === undefined
            ? {}
            : {
                docs: {
                    ...rule.meta.docs,
                    deprecated: true,
                    frozen: true,
                },
            }),
    },
});
//# sourceMappingURL=rule-deprecation.js.map