import { isDefined } from "ts-extras";
import { ruleCreator } from "../_internal/rule-creator.js";
const selector = "PropertyDefinition[typeAnnotation=undefined][value=null]";
/**
 * Require explicit type annotations for uninitialized class properties.
 */
const rule = ruleCreator({
    create: (context) => ({
        [selector]: (node) => {
            if (node.type !== "PropertyDefinition") {
                return;
            }
            const canProvideSafeSuggestion = !node.computed &&
                node.key.type === "Identifier" &&
                !node.optional &&
                !node.definite;
            const fix = canProvideSafeSuggestion
                ? (fixer) => fixer.insertTextAfter(node.key, ": unknown")
                : undefined;
            context.report({
                messageId: "forbidden",
                node,
                ...(isDefined(fix)
                    ? {
                        fix,
                        suggest: [
                            {
                                fix,
                                messageId: "suggestAnnotateUnknown",
                            },
                        ],
                    }
                    : {}),
            });
        },
    }),
    defaultOptions: [],
    meta: {
        deprecated: false,
        docs: {
            deprecated: false,
            description: "require explicit type annotations for class properties without initializers.",
            frozen: false,
            recommended: false,
            url: "https://nick2bad4u.github.io/eslint-plugin-etc-misc/docs/rules/typescript-require-prop-type-annotation",
        },
        fixable: "code",
        hasSuggestions: true,
        messages: {
            forbidden: "Expecting a type annotation for this property.",
            suggestAnnotateUnknown: "Add an explicit ': unknown' type annotation.",
        },
        schema: [],
        type: "problem",
    },
    name: "typescript/require-prop-type-annotation",
});
export default rule;
//# sourceMappingURL=typescript-require-prop-type-annotation.js.map