import { ruleCreator } from "../_internal/rule-creator.js";
const isSingleLine = (node) => node.loc.start.line === node.loc.end.line;
/**
 * Enforce object literal line format based on configured property count.
 */
const rule = ruleCreator({
    create: (context, [options]) => ({
        ObjectExpression: (node) => {
            const maxProperties = options.maxProperties ?? 1;
            if (node.properties.length <= 1) {
                return;
            }
            const shouldBeSingleLine = node.properties.length <= maxProperties;
            const singleLine = isSingleLine(node);
            if (singleLine === shouldBeSingleLine) {
                return;
            }
            context.report({
                data: {
                    expected: shouldBeSingleLine ? "single-line" : "multi-line",
                },
                messageId: "inconsistent",
                node,
            });
        },
    }),
    defaultOptions: [{ maxProperties: 1 }],
    meta: {
        defaultOptions: [{ maxProperties: 1 }],
        deprecated: false,
        docs: {
            deprecated: false,
            description: "enforce object literal line format based on property count.",
            frozen: false,
            recommended: false,
            url: "https://nick2bad4u.github.io/eslint-plugin-etc-misc/docs/rules/object-format",
        },
        hasSuggestions: false,
        messages: {
            inconsistent: "Object literal should use {{expected}} formatting for this size.",
        },
        schema: [
            {
                additionalProperties: false,
                description: "Configuration for object literal line formatting thresholds.",
                properties: {
                    maxProperties: {
                        description: "Maximum number of properties allowed on one line.",
                        minimum: 0,
                        type: "number",
                    },
                },
                type: "object",
            },
        ],
        type: "layout",
    },
    name: "object-format",
});
export default rule;
//# sourceMappingURL=object-format.js.map