Repository: eslint/eslint
File: lib/rules/multiline-comment-style.js (JavaScript)

Code before:
module.exports = {
    meta: {
        type: "suggestion",

        docs: {
            description: "Enforce a particular style for multiline comments",
            recommended: false,
            url: "https://eslint.org/docs/rules/multiline-comment-style"
        },

        fixable: "whitespace",
        schema: [
            {
                enum: ["starred-block", "separate-lines", "bare-block"]
            },
            {
                type: "object",
                properties: {
                    allowJsDoc: {
                        type: "boolean",
                        default: true
                    }
                },
                additionalProperties: false
            }
        ],
        messages: {
            expectedBlock: "Expected a block comment instead of consecutive line comments.",
            expectedBareBlock: "Expected a block comment without padding stars.",
            startNewline: "Expected a linebreak after '/*'.",
            endNewline: "Expected a linebreak before '*/'.",
            missingStar: "Expected a '*' at the start of this line.",
            alignment: "Expected this line to be aligned with the start of the comment.",
            expectedLines: "Expected multiple line comments instead of a block comment."
        }
    },

    create(context) {
        const sourceCode = context.getSourceCode();
        const option = context.options[0] || "starred-block";
        const params = context.options[1] || {};
        const allowJsDoc = "allowJsDoc" in params ? params.allowJsDoc : true;

        //----------------------------------------------------------------------
        // Helpers
        //----------------------------------------------------------------------

        /**
         * Checks if a comment line is starred.
         * @param {string} line A string representing a comment line.
         * @returns {boolean} Whether or not the comment line is starred.

Review comment (suggestion):
Does the new option apply only when the string option is `"separate-lines"`? If so, to avoid confusion we should enforce in the schema that the option can be specified only with `"separate-lines"`.

Code after:
module.exports = {
    meta: {
        type: "suggestion",

        docs: {
            description: "Enforce a particular style for multiline comments",
            recommended: false,
            url: "https://eslint.org/docs/rules/multiline-comment-style"
        },

        fixable: "whitespace",
        schema: {
            anyOf: [
                {
                    type: "array",
                    items: [
                        {
                            enum: ["starred-block", "bare-block"]
                        }
                    ],
                    additionalItems: false
                },
                {
                    type: "array",
                    items: [
                        {
                            enum: ["separate-lines"]
                        },
                        {
                            type: "object",
                            properties: {
                                checkJSDoc: {
                                    type: "boolean"
                                }
                            },
                            additionalProperties: false
                        }
                    ],
                    additionalItems: false
                }
            ]
        },
        messages: {
            expectedBlock: "Expected a block comment instead of consecutive line comments.",
            expectedBareBlock: "Expected a block comment without padding stars.",
            startNewline: "Expected a linebreak after '/*'.",
            endNewline: "Expected a linebreak before '*/'.",
            missingStar: "Expected a '*' at the start of this line.",
            alignment: "Expected this line to be aligned with the start of the comment.",
            expectedLines: "Expected multiple line comments instead of a block comment."
        }