Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Ensure that glob patterns are normalized #16287

Merged
merged 3 commits into from Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/eslint/eslint-helpers.js
Expand Up @@ -133,7 +133,7 @@ async function findFiles({
stats.forEach((stat, index) => {

const filePath = filePaths[index];
const pattern = patterns[index];
const pattern = normalizeToPosix(patterns[index]);

if (stat) {

Expand Down
13 changes: 10 additions & 3 deletions tests/lib/cli.js
Expand Up @@ -171,11 +171,18 @@ describe("cli", () => {
});
});

describe("when there is a local config file", () => {
const code = "lib/cli.js";
describe.only("when there is a local config file", () => {
aladdin-add marked this conversation as resolved.
Show resolved Hide resolved

it(`should load the local config file with configType:${configType}`, async () => {
await cli.execute(code, null, useFlatConfig);
await cli.execute("lib/cli.js", null, useFlatConfig);
});

it(`should load the local config file with glob pattern and configType:${configType}`, async () => {
await cli.execute("lib/cli*.js", null, useFlatConfig);
});

it(`should load the local config file with Windows slashes glob pattern and configType:${configType}`, async () => {
await cli.execute("lib\\cli*.js", null, useFlatConfig);
});
});

Expand Down
17 changes: 17 additions & 0 deletions tests/lib/eslint/flat-eslint.js
Expand Up @@ -818,6 +818,23 @@ describe("FlatESLint", () => {
assert.strictEqual(results[1].suppressedMessages.length, 0);
});

it("should resolve globs with Windows slashes when 'globInputPaths' option is true", async () => {
eslint = new FlatESLint({
ignore: false,
cwd: getFixturePath(".."),
overrideConfig: { files: ["**/*.js", "**/*.js2"] },
overrideConfigFile: getFixturePath("eslint.config.js")

});
const results = await eslint.lintFiles(["fixtures\\files\\*"]);

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

it("should not resolve globs when 'globInputPaths' option is false", async () => {
eslint = new FlatESLint({
ignore: false,
Expand Down