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

Code before:

            [
                ["an empty string", ""],
                ["an empty array", []],
                ["a string with a single space", " "],
                ["an array with one empty string", [""]],
                ["an array with two empty strings", ["", ""]]

            ].forEach(([name, value]) => {

                it(`should throw an error when passed ${name}`, async () => {
                    eslint = new ESLint({
                        useEslintrc: false
                    });

                    await assert.rejects(async () => await eslint.lintFiles(value), /'patterns' must be a non-empty string or an array of non-empty strings/u);
                });

                if (value === "" || Array.isArray(value) && value.length === 0) {
                    it(`should not throw an error when passed ${name} and passOnNoPatterns: true`, async () => {
                        eslint = new ESLint({
                            useEslintrc: false,
                            passOnNoPatterns: true
                        });

                        await assert.doesNotReject(async () => await eslint.lintFiles(value));
                    });
                }

            });


        });

        it("should report zero messages when given a directory with a .js2 file", async () => {
            eslint = new ESLint({
                cwd: path.join(fixtureDir, ".."),
                extensions: [".js2"]
            });
            const results = await eslint.lintFiles([getFixturePath("files/foo.js2")]);

            assert.strictEqual(results.length, 1);
            assert.strictEqual(results[0].messages.length, 0);
        });

        it("should fall back to defaults when extensions is set to an empty array", async () => {
            eslint = new ESLint({
                cwd: getFixturePath("configurations"),
                overrideConfigFile: getFixturePath("configurations", "quotes-error.json"),
                extensions: []
            });

Review comment (suggestion):
```suggestion
                        const results = await eslint.lintFiles(value);

                        assert.strictEqual(results.length, 0);
```

It would be good to also check the return value, to ensure that no files were linted in these cases.

Code after:
                },
                useEslintrc: false
            });

            await assert.rejects(async () => await eslint.lintFiles(["lib/cli.js"]), /Cannot find module 'test11'/u);
        });

        describe("Invalid inputs", () => {

            [
                ["an empty string", ""],
                ["an empty array", []],
                ["a string with a single space", " "],
                ["an array with one empty string", [""]],
                ["an array with two empty strings", ["", ""]]

            ].forEach(([name, value]) => {

                it(`should throw an error when passed ${name}`, async () => {
                    eslint = new ESLint({
                        useEslintrc: false
                    });

                    await assert.rejects(async () => await eslint.lintFiles(value), /'patterns' must be a non-empty string or an array of non-empty strings/u);
                });

                if (value === "" || Array.isArray(value) && value.length === 0) {
                    it(`should not throw an error when passed ${name} and passOnNoPatterns: true`, async () => {
                        eslint = new ESLint({
                            useEslintrc: false,
                            passOnNoPatterns: true
                        });

                        const results = await eslint.lintFiles(value);

                        assert.strictEqual(results.length, 0);
                    });
                }

            });


        });

        it("should report zero messages when given a directory with a .js2 file", async () => {
            eslint = new ESLint({
                cwd: path.join(fixtureDir, ".."),
                extensions: [".js2"]
            });
            const results = await eslint.lintFiles([getFixturePath("files/foo.js2")]);