Skip to content

Commit a608bf1

Browse files
authored
Fix compatibility problem with Windows (#687)
1 parent bbf323b commit a608bf1

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

lib/options-manager.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import stringify from 'json-stable-stringify-without-jsonify';
1616
import {Legacy} from '@eslint/eslintrc';
1717
import createEsmUtils from 'esm-utils';
1818
import MurmurHash3 from 'imurmurhash';
19+
import slash from 'slash';
1920
import {
2021
DEFAULT_IGNORES,
2122
DEFAULT_EXTENSION,
@@ -683,19 +684,19 @@ const tsConfigResolvePaths = (tsConfig, tsConfigPath) => {
683684

684685
if (Array.isArray(tsConfig.files)) {
685686
tsConfig.files = tsConfig.files.map(
686-
filePath => path.resolve(tsConfigDirectory, filePath),
687+
filePath => slash(path.resolve(tsConfigDirectory, filePath)),
687688
);
688689
}
689690

690691
if (Array.isArray(tsConfig.include)) {
691692
tsConfig.include = tsConfig.include.map(
692-
globPath => path.resolve(tsConfigDirectory, globPath),
693+
globPath => slash(path.resolve(tsConfigDirectory, globPath)),
693694
);
694695
}
695696

696697
if (Array.isArray(tsConfig.exclude)) {
697698
tsConfig.exclude = tsConfig.exclude.map(
698-
globPath => path.resolve(tsConfigDirectory, globPath),
699+
globPath => slash(path.resolve(tsConfigDirectory, globPath)),
699700
);
700701
}
701702

test/options-manager.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ test('mergeWithFileConfig: correctly resolves relative tsconfigs excluded file',
603603
const excludedFilePath = path.resolve(cwd, 'excluded-file.ts');
604604
const excludeTsConfigPath = new RegExp(`${slash(cwd)}/node_modules/.cache/xo-linter/tsconfig\\..*\\.json[\\/]?$`, 'u');
605605
const {options} = await manager.mergeWithFileConfig({cwd, filePath: excludedFilePath});
606-
t.regex(options.tsConfigPath, excludeTsConfigPath);
606+
t.regex(slash(options.tsConfigPath), excludeTsConfigPath);
607607
});
608608

609609
test('mergeWithFileConfig: correctly resolves relative tsconfigs included file', async t => {
@@ -619,15 +619,15 @@ test('mergeWithFileConfig: uses generated tsconfig if specified parserOptions.pr
619619
const filePath = path.resolve(cwd, 'excluded-file.ts');
620620
const expectedTsConfigPath = new RegExp(`${slash(cwd)}/node_modules/.cache/xo-linter/tsconfig\\..*\\.json[\\/]?$`, 'u');
621621
const {options} = await manager.mergeWithFileConfig({cwd, filePath});
622-
t.regex(options.tsConfigPath, expectedTsConfigPath);
622+
t.regex(slash(options.tsConfigPath), expectedTsConfigPath);
623623
});
624624

625625
test('mergeWithFileConfig: uses generated tsconfig if specified parserOptions.project misses file', async t => {
626626
const cwd = path.resolve('fixtures', 'typescript', 'parseroptions-project');
627627
const filePath = path.resolve(cwd, 'missed-by-options-file.ts');
628628
const expectedTsConfigPath = new RegExp(`${slash(cwd)}/node_modules/.cache/xo-linter/tsconfig\\..*\\.json[\\/]?$`, 'u');
629629
const {options} = await manager.mergeWithFileConfig({cwd, filePath});
630-
t.regex(options.tsConfigPath, expectedTsConfigPath);
630+
t.regex(slash(options.tsConfigPath), expectedTsConfigPath);
631631
});
632632

633633
test('mergeWithFileConfig: auto generated ts config extends found ts config if file is not covered', async t => {
@@ -647,7 +647,7 @@ test('mergeWithFileConfig: used found ts config if file is covered', async t =>
647647
const filePath = path.resolve(cwd, 'foo.ts');
648648
const expectedConfigPath = path.resolve(cwd, 'tsconfig.json');
649649
const {options} = await manager.mergeWithFileConfig({cwd, filePath});
650-
t.is(slash(options.tsConfigPath), expectedConfigPath);
650+
t.is(options.tsConfigPath, expectedConfigPath);
651651
});
652652

653653
test('mergeWithFileConfig: auto generated ts config extends found ts config if file is explicitly excluded', async t => {

0 commit comments

Comments
 (0)