Repository: eslint/eslint
File: lib/rules/no-console.js (JavaScript)

Code before:
        },

        schema: [
            {
                type: "object",
                properties: {
                    allow: {
                        type: "array",
                        items: {
                            type: "string"
                        },
                        minItems: 1,
                        uniqueItems: true
                    }
                },
                additionalProperties: false
            }
        ],

        hasSuggestions: true,

        messages: {
            unexpected: "Unexpected console statement.",
            limited: "Only these console methods are allowed: {{ allowed }}.",
            removeConsole: "Remove the console.{{ propertyName }}().",
            replaceMethod: "Replace console.{{ from }} with console.{{ to }}."
        }
    },

    create(context) {
        const [{ allow: allowed = [] }] = context.options;
        const sourceCode = context.sourceCode;

        /**
         * Checks whether the given reference is 'console' or not.
         * @param {eslint-scope.Reference} reference The reference to check.
         * @returns {boolean} `true` if the reference is 'console'.
         */
        function isConsole(reference) {
            const id = reference.identifier;

            return id && id.name === "console";
        }

        /**
         * Checks whether the property name of the given MemberExpression node
         * is allowed by options or not.
         * @param {ASTNode} node The MemberExpression node to check.
         * @returns {boolean} `true` if the property name of the node is allowed.
         */
        function isAllowed(node) {

Review comment (suggestion):
```suggestion
            replaceMethod: "Replace console.{{ from }} with console.{{ to }}."
```
We have decided not to suggest replacing `.log` with the allowed methods. 

Ref: https://github.com/eslint/eslint/issues/19229#issuecomment-2567051644

Code after:
        },

        schema: [
            {
                type: "object",
                properties: {
                    allow: {
                        type: "array",
                        items: {
                            type: "string"
                        },
                        minItems: 1,
                        uniqueItems: true
                    }
                },
                additionalProperties: false
            }
        ],

        hasSuggestions: true,

        messages: {
            unexpected: "Unexpected console statement.",
            limited: "Unexpected console statement. Only these console methods are allowed: {{ allowed }}.",
            removeConsole: "Remove the console.{{ propertyName }}()."
        }
    },

    create(context) {
        const [{ allow: allowed = [] }] = context.options;
        const sourceCode = context.sourceCode;

        /**
         * Checks whether the given reference is 'console' or not.
         * @param {eslint-scope.Reference} reference The reference to check.
         * @returns {boolean} `true` if the reference is 'console'.
         */
        function isConsole(reference) {
            const id = reference.identifier;

            return id && id.name === "console";
        }

        /**
         * Checks whether the property name of the given MemberExpression node
         * is allowed by options or not.
         * @param {ASTNode} node The MemberExpression node to check.
         * @returns {boolean} `true` if the property name of the node is allowed.
         */
        function isAllowed(node) {
            const propertyName = astUtils.getStaticPropertyName(node);