Repository: eslint/eslint
File: tests/lib/source-code/source-code.js (JavaScript)

Code before:
            };

            flatLinter.verify(code, config);
            assert(spy && spy.calledOnce, "Spy was not called.");
        });
    });


    describe("getDeclaredVariables(node)", () => {

        /**
         * Assert `context.getDeclaredVariables(node)` is valid.
         * @param {string} code A code to check.
         * @param {string} type A type string of ASTNode. This method checks variables on the node of the type.
         * @param {Array<Array<string>>} expectedNamesList An array of expected variable names. The expected variable names is an array of string.
         * @returns {void}
         */
        function verify(code, type, expectedNamesList) {
            linter.defineRules({
                test: {
                    create(context) {

                        const sourceCode = context.getSourceCode();

                        /**
                         * Assert `context.getDeclaredVariables(node)` is empty.
                         * @param {ASTNode} node A node to check.
                         * @returns {void}
                         */
                        function checkEmpty(node) {
                            assert.strictEqual(0, sourceCode.getDeclaredVariables(node).length);
                        }
                        const rule = {
                            Program: checkEmpty,
                            EmptyStatement: checkEmpty,
                            BlockStatement: checkEmpty,
                            ExpressionStatement: checkEmpty,
                            LabeledStatement: checkEmpty,
                            BreakStatement: checkEmpty,
                            ContinueStatement: checkEmpty,
                            WithStatement: checkEmpty,
                            SwitchStatement: checkEmpty,
                            ReturnStatement: checkEmpty,
                            ThrowStatement: checkEmpty,
                            TryStatement: checkEmpty,
                            WhileStatement: checkEmpty,
                            DoWhileStatement: checkEmpty,
                            ForStatement: checkEmpty,
                            ForInStatement: checkEmpty,
                            DebuggerStatement: checkEmpty,
                            ThisExpression: checkEmpty,

Review comment (suggestion):
```suggestion
                         * Assert `sourceCode.getDeclaredVariables(node)` is empty.
```

Code after:
            };

            flatLinter.verify(code, config);
            assert(spy && spy.calledOnce, "Spy was not called.");
        });

        it("should throw an error when the argument is missing", () => {
            let spy;

            const config = {
                plugins: {
                    test: {
                        rules: {
                            checker: {
                                create(context) {
                                    spy = sinon.spy(() => {
                                        const sourceCode = context.getSourceCode();

                                        assert.throws(() => {
                                            sourceCode.getAncestors();
                                        }, /Missing required argument: node/u);

                                    });

                                    return { Program: spy };
                                }
                            }
                        }
                    }
                },
                rules: { "test/checker": "error" }
            };

            flatLinter.verify(code, config);
            assert(spy && spy.calledOnce, "Spy was not called.");
        });
    });


    describe("getDeclaredVariables(node)", () => {

        /**
         * Assert `sourceCode.getDeclaredVariables(node)` is valid.
         * @param {string} code A code to check.
         * @param {string} type A type string of ASTNode. This method checks variables on the node of the type.
         * @param {Array<Array<string>>} expectedNamesList An array of expected variable names. The expected variable names is an array of string.
         * @returns {void}
         */
        function verify(code, type, expectedNamesList) {
            linter.defineRules({
                test: {