@@ -13,21 +13,23 @@ const hasRule = (results, filePath, ruleId) => {
1313
1414test ( 'only accepts allowed extensions' , async t => {
1515 // Markdown files will always produce linter errors and will not be going away
16- const mdGlob = path . join ( __dirname , '..' , '*.md' ) ;
16+ const cwd = path . join ( __dirname , 'fixtures/custom-extension' ) ;
17+ const mdGlob = '*.md' ;
1718
1819 // No files should be linted = no errors
19- const noOptionsResults = await xo . lintFiles ( mdGlob , { } ) ;
20+ const noOptionsResults = await xo . lintFiles ( mdGlob , { cwd } ) ;
2021 t . is ( noOptionsResults . errorCount , 0 ) ;
2122
2223 // Markdown files linted (with no plugin for it) = errors
23- const moreExtensionsResults = await xo . lintFiles ( mdGlob , { extensions : [ 'md' ] } ) ;
24+ const moreExtensionsResults = await xo . lintFiles ( mdGlob , { extensions : [ 'md' ] , cwd } ) ;
2425 t . true ( moreExtensionsResults . errorCount > 0 ) ;
2526} ) ;
2627
2728test ( 'ignores dirs for empty extensions' , async t => {
2829 {
29- const glob = path . join ( __dirname , 'fixtures/nodir/*' ) ;
30- const results = await xo . lintFiles ( glob , { extensions : [ '' , 'js' ] } ) ;
30+ const cwd = path . join ( __dirname , 'fixtures/nodir' ) ;
31+ const glob = '*' ;
32+ const results = await xo . lintFiles ( glob , { extensions : [ '' , 'js' ] , cwd} ) ;
3133 const { results : [ fileResult ] } = results ;
3234
3335 // Only `fixtures/nodir/noextension` should be linted
@@ -38,8 +40,9 @@ test('ignores dirs for empty extensions', async t => {
3840 }
3941
4042 {
41- const glob = path . join ( __dirname , 'fixtures/nodir/nested/*' ) ;
42- const results = await xo . lintFiles ( glob ) ;
43+ const cwd = path . join ( __dirname , 'fixtures/nodir' ) ;
44+ const glob = 'nested/*' ;
45+ const results = await xo . lintFiles ( glob , { cwd} ) ;
4346 const { results : [ fileResult ] } = results ;
4447
4548 // Ensure `nodir/nested` **would** report if globbed
@@ -48,6 +51,19 @@ test('ignores dirs for empty extensions', async t => {
4851 t . is ( actual , expected ) ;
4952 t . is ( results . errorCount , 1 ) ;
5053 }
54+
55+ {
56+ const cwd = path . join ( __dirname , 'fixtures/nodir' ) ;
57+ // Check Windows-style paths are working
58+ const glob = 'nested\\*' ;
59+ const results = await xo . lintFiles ( glob , { cwd} ) ;
60+ const { results : [ fileResult ] } = results ;
61+
62+ const expected = 'fixtures/nodir/nested/index.js' . split ( '/' ) . join ( path . sep ) ;
63+ const actual = path . relative ( __dirname , fileResult . filePath ) ;
64+ t . is ( actual , expected ) ;
65+ t . is ( results . errorCount , 1 ) ;
66+ }
5167} ) ;
5268
5369test . serial ( 'cwd option' , async t => {
@@ -59,7 +75,7 @@ test.serial('cwd option', async t => {
5975
6076test ( 'do not lint gitignored files' , async t => {
6177 const cwd = path . join ( __dirname , 'fixtures/gitignore' ) ;
62- const glob = path . posix . join ( cwd , '**/*' ) ;
78+ const glob = '**/*' ;
6379 const ignored = path . resolve ( 'fixtures/gitignore/test/foo.js' ) ;
6480 const { results} = await xo . lintFiles ( glob , { cwd} ) ;
6581
@@ -68,7 +84,7 @@ test('do not lint gitignored files', async t => {
6884
6985test ( 'do not lint gitignored files in file with negative gitignores' , async t => {
7086 const cwd = path . join ( __dirname , 'fixtures/negative-gitignore' ) ;
71- const glob = path . posix . join ( cwd , '*' ) ;
87+ const glob = '*' ;
7288 const ignored = path . resolve ( 'fixtures/negative-gitignore/bar.js' ) ;
7389 const { results} = await xo . lintFiles ( glob , { cwd} ) ;
7490
@@ -77,7 +93,7 @@ test('do not lint gitignored files in file with negative gitignores', async t =>
7793
7894test ( 'lint negatively gitignored files' , async t => {
7995 const cwd = path . join ( __dirname , 'fixtures/negative-gitignore' ) ;
80- const glob = path . posix . join ( cwd , '*' ) ;
96+ const glob = '*' ;
8197 const negative = path . resolve ( 'fixtures/negative-gitignore/foo.js' ) ;
8298 const { results} = await xo . lintFiles ( glob , { cwd} ) ;
8399
@@ -86,7 +102,7 @@ test('lint negatively gitignored files', async t => {
86102
87103test ( 'do not lint inapplicable negatively gitignored files' , async t => {
88104 const cwd = path . join ( __dirname , 'fixtures/negative-gitignore' ) ;
89- const glob = path . posix . join ( cwd , 'bar.js' ) ;
105+ const glob = 'bar.js' ;
90106 const negative = path . resolve ( 'fixtures/negative-gitignore/foo.js' ) ;
91107 const { results} = await xo . lintFiles ( glob , { cwd} ) ;
92108
@@ -125,7 +141,7 @@ test('enable rules based on nodeVersion', async t => {
125141
126142test ( 'do not lint eslintignored files' , async t => {
127143 const cwd = path . join ( __dirname , 'fixtures/eslintignore' ) ;
128- const glob = path . posix . join ( cwd , '*' ) ;
144+ const glob = '*' ;
129145 const positive = path . resolve ( 'fixtures/eslintignore/foo.js' ) ;
130146 const negative = path . resolve ( 'fixtures/eslintignore/bar.js' ) ;
131147 const { results} = await xo . lintFiles ( glob , { cwd} ) ;
@@ -216,7 +232,7 @@ test('typescript no semicolon option', async t => {
216232
217233test ( 'webpack import resolver is used if webpack.config.js is found' , async t => {
218234 const cwd = 'fixtures/webpack/with-config/' ;
219- const { results} = await xo . lintFiles ( path . resolve ( cwd , 'file1.js' ) , {
235+ const { results} = await xo . lintFiles ( 'file1.js' , {
220236 cwd,
221237 rules : {
222238 'import/no-unresolved' : 2 ,
@@ -233,7 +249,7 @@ test('webpack import resolver is used if webpack.config.js is found', async t =>
233249test ( 'webpack import resolver config can be passed through webpack option' , async t => {
234250 const cwd = 'fixtures/webpack/no-config/' ;
235251
236- const { results} = await xo . lintFiles ( path . resolve ( cwd , 'file1.js' ) , {
252+ const { results} = await xo . lintFiles ( 'file1.js' , {
237253 cwd,
238254 webpack : {
239255 config : {
@@ -256,7 +272,7 @@ test('webpack import resolver config can be passed through webpack option', asyn
256272test ( 'webpack import resolver is used if {webpack: true}' , async t => {
257273 const cwd = 'fixtures/webpack/no-config/' ;
258274
259- const { results} = await xo . lintFiles ( path . resolve ( cwd , 'file3.js' ) , {
275+ const { results} = await xo . lintFiles ( 'file3.js' , {
260276 cwd,
261277 webpack : true ,
262278 rules : {
0 commit comments