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

Code before:
        },

        schema: [
            {
                enum: ["functions", "both"]
            },
            {
                type: "object",
                properties: {
                    blockScopedFunctions: {
                        enum: ["allow", "disallow"]
                    }
                },
                additionalProperties: false
            }
        ],

        messages: {
            moveDeclToRoot: "Move {{type}} declaration to {{body}} root."
        }
    },

    create(context) {

        const sourceCode = context.sourceCode;
        const ecmaVersion = context.languageOptions.ecmaVersion ?? 6;
        const blockScopedFunctions = context.options[1]?.blockScopedFunctions ?? "allow";

        /**
         * Ensure that a given node is at a program or function body's root.
         * @param {ASTNode} node Declaration node to check.
         * @returns {void}
         */
        function check(node) {
            const parent = node.parent;

            if (
                parent.type === "BlockStatement" && validBlockStatementParent.has(parent.parent.type)
            ) {
                return;
            }

            if (validParent.has(parent.type)) {
                return;
            }

            context.report({
                node,
                messageId: "moveDeclToRoot",
                data: {
                    type: (node.type === "FunctionDeclaration" ? "function" : "variable"),

Review comment (suggestion):
```suggestion
        const ecmaVersion = context.languageOptions.ecmaVersion;
```

`context.languageOptions.ecmaVersion` is always a number: 3, 5, 2015, 2016...

Code after:

        schema: [
            {
                enum: ["functions", "both"]
            },
            {
                type: "object",
                properties: {
                    blockScopedFunctions: {
                        enum: ["allow", "disallow"]
                    }
                },
                additionalProperties: false
            }
        ],

        messages: {
            moveDeclToRoot: "Move {{type}} declaration to {{body}} root."
        }
    },

    create(context) {

        const sourceCode = context.sourceCode;
        const ecmaVersion = context.languageOptions.ecmaVersion;
        const blockScopedFunctions = context.options[1]?.blockScopedFunctions ?? "allow";

        /**
         * Ensure that a given node is at a program or function body's root.
         * @param {ASTNode} node Declaration node to check.
         * @returns {void}
         */
        function check(node) {
            const parent = node.parent;

            if (
                parent.type === "BlockStatement" && validBlockStatementParent.has(parent.parent.type)
            ) {
                return;
            }

            if (validParent.has(parent.type)) {
                return;
            }

            context.report({
                node,
                messageId: "moveDeclToRoot",
                data: {
                    type: (node.type === "FunctionDeclaration" ? "function" : "variable"),
                    body: getAllowedBodyDescription(node)