Skip to content

Commit 3033fcd

Browse files
futpibsindresorhus
authored andcommitted
Turn all paths cwd-relative before linting (#372)
1 parent ec51d18 commit 3033fcd

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ module.exports.lintFiles = (patterns, options) => {
9898
cwd: options.cwd
9999
}
100100
).then(paths => {
101+
paths = paths.map(x => path.relative(options.cwd, path.resolve(options.cwd, x)));
102+
101103
// Filter out unwanted file extensions
102104
// For silly users that don't specify an extension in the glob pattern
103105
if (!isEmptyPatterns) {

test/cli-main.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,24 @@ test('overrides fixture', async t => {
4545
await t.notThrowsAsync(main([], {cwd}));
4646
});
4747

48+
test('overrides work with relative path', async t => {
49+
const cwd = path.join(__dirname, 'fixtures/overrides');
50+
const file = path.join('test', 'bar.js');
51+
await t.notThrowsAsync(main([file], {cwd}));
52+
});
53+
54+
test('overrides work with relative path starting with `./`', async t => {
55+
const cwd = path.join(__dirname, 'fixtures/overrides');
56+
const file = '.' + path.sep + path.join('test', 'bar.js');
57+
await t.notThrowsAsync(main([file], {cwd}));
58+
});
59+
60+
test('overrides work with absolute path', async t => {
61+
const cwd = path.join(__dirname, 'fixtures/overrides');
62+
const file = path.join(cwd, 'test', 'bar.js');
63+
await t.notThrowsAsync(main([file], {cwd}));
64+
});
65+
4866
// #65
4967
test.failing('ignores fixture', async t => {
5068
const cwd = path.join(__dirname, 'fixtures/ignores');

0 commit comments

Comments
 (0)