@@ -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 , '..' ) ;
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
@@ -59,7 +62,7 @@ test.serial('cwd option', async t => {
5962
6063test ( 'do not lint gitignored files' , async t => {
6164 const cwd = path . join ( __dirname , 'fixtures/gitignore' ) ;
62- const glob = path . posix . join ( cwd , '**/*' ) ;
65+ const glob = '**/*' ;
6366 const ignored = path . resolve ( 'fixtures/gitignore/test/foo.js' ) ;
6467 const { results} = await xo . lintFiles ( glob , { cwd} ) ;
6568
@@ -68,7 +71,7 @@ test('do not lint gitignored files', async t => {
6871
6972test ( 'do not lint gitignored files in file with negative gitignores' , async t => {
7073 const cwd = path . join ( __dirname , 'fixtures/negative-gitignore' ) ;
71- const glob = path . posix . join ( cwd , '*' ) ;
74+ const glob = '*' ;
7275 const ignored = path . resolve ( 'fixtures/negative-gitignore/bar.js' ) ;
7376 const { results} = await xo . lintFiles ( glob , { cwd} ) ;
7477
@@ -77,7 +80,7 @@ test('do not lint gitignored files in file with negative gitignores', async t =>
7780
7881test ( 'lint negatively gitignored files' , async t => {
7982 const cwd = path . join ( __dirname , 'fixtures/negative-gitignore' ) ;
80- const glob = path . posix . join ( cwd , '*' ) ;
83+ const glob = '*' ;
8184 const negative = path . resolve ( 'fixtures/negative-gitignore/foo.js' ) ;
8285 const { results} = await xo . lintFiles ( glob , { cwd} ) ;
8386
@@ -86,7 +89,7 @@ test('lint negatively gitignored files', async t => {
8689
8790test ( 'do not lint inapplicable negatively gitignored files' , async t => {
8891 const cwd = path . join ( __dirname , 'fixtures/negative-gitignore' ) ;
89- const glob = path . posix . join ( cwd , 'bar.js' ) ;
92+ const glob = 'bar.js' ;
9093 const negative = path . resolve ( 'fixtures/negative-gitignore/foo.js' ) ;
9194 const { results} = await xo . lintFiles ( glob , { cwd} ) ;
9295
@@ -125,7 +128,7 @@ test('enable rules based on nodeVersion', async t => {
125128
126129test ( 'do not lint eslintignored files' , async t => {
127130 const cwd = path . join ( __dirname , 'fixtures/eslintignore' ) ;
128- const glob = path . posix . join ( cwd , '*' ) ;
131+ const glob = '*' ;
129132 const positive = path . resolve ( 'fixtures/eslintignore/foo.js' ) ;
130133 const negative = path . resolve ( 'fixtures/eslintignore/bar.js' ) ;
131134 const { results} = await xo . lintFiles ( glob , { cwd} ) ;
@@ -216,7 +219,7 @@ test('typescript no semicolon option', async t => {
216219
217220test ( 'webpack import resolver is used if webpack.config.js is found' , async t => {
218221 const cwd = 'fixtures/webpack/with-config/' ;
219- const { results} = await xo . lintFiles ( path . resolve ( cwd , 'file1.js' ) , {
222+ const { results} = await xo . lintFiles ( 'file1.js' , {
220223 cwd,
221224 rules : {
222225 'import/no-unresolved' : 2 ,
@@ -233,7 +236,7 @@ test('webpack import resolver is used if webpack.config.js is found', async t =>
233236test ( 'webpack import resolver config can be passed through webpack option' , async t => {
234237 const cwd = 'fixtures/webpack/no-config/' ;
235238
236- const { results} = await xo . lintFiles ( path . resolve ( cwd , 'file1.js' ) , {
239+ const { results} = await xo . lintFiles ( 'file1.js' , {
237240 cwd,
238241 webpack : {
239242 config : {
@@ -256,7 +259,7 @@ test('webpack import resolver config can be passed through webpack option', asyn
256259test ( 'webpack import resolver is used if {webpack: true}' , async t => {
257260 const cwd = 'fixtures/webpack/no-config/' ;
258261
259- const { results} = await xo . lintFiles ( path . resolve ( cwd , 'file3.js' ) , {
262+ const { results} = await xo . lintFiles ( 'file3.js' , {
260263 cwd,
261264 webpack : true ,
262265 rules : {
0 commit comments