11import path from 'path' ;
22import test from 'ava' ;
3- import fn from '..' ;
3+ import xo from '..' ;
44
55process . chdir ( __dirname ) ;
66
@@ -14,18 +14,18 @@ test('only accepts allowed extensions', async t => {
1414 const mdGlob = path . join ( __dirname , '..' , '*.md' ) ;
1515
1616 // No files should be linted = no errors
17- const noOptionsResults = await fn . lintFiles ( mdGlob , { } ) ;
17+ const noOptionsResults = await xo . lintFiles ( mdGlob , { } ) ;
1818 t . is ( noOptionsResults . errorCount , 0 ) ;
1919
2020 // Markdown files linted (with no plugin for it) = errors
21- const moreExtensionsResults = await fn . lintFiles ( mdGlob , { extensions : [ 'md' ] } ) ;
21+ const moreExtensionsResults = await xo . lintFiles ( mdGlob , { extensions : [ 'md' ] } ) ;
2222 t . true ( moreExtensionsResults . errorCount > 0 ) ;
2323} ) ;
2424
2525test ( 'ignores dirs for empty extensions' , async t => {
2626 {
2727 const glob = path . join ( __dirname , 'fixtures/nodir/*' ) ;
28- const results = await fn . lintFiles ( glob , { extensions : [ '' , 'js' ] } ) ;
28+ const results = await xo . lintFiles ( glob , { extensions : [ '' , 'js' ] } ) ;
2929 const { results : [ fileResult ] } = results ;
3030
3131 // Only `fixtures/nodir/noextension` should be linted
@@ -37,7 +37,7 @@ test('ignores dirs for empty extensions', async t => {
3737
3838 {
3939 const glob = path . join ( __dirname , 'fixtures/nodir/nested/*' ) ;
40- const results = await fn . lintFiles ( glob ) ;
40+ const results = await xo . lintFiles ( glob ) ;
4141 const { results : [ fileResult ] } = results ;
4242
4343 // Ensure `nodir/nested` **would** report if globbed
@@ -49,7 +49,7 @@ test('ignores dirs for empty extensions', async t => {
4949} ) ;
5050
5151test . serial ( 'cwd option' , async t => {
52- const { results} = await fn . lintFiles ( '**/*' , { cwd : 'fixtures/cwd' } ) ;
52+ const { results} = await xo . lintFiles ( '**/*' , { cwd : 'fixtures/cwd' } ) ;
5353 const paths = results . map ( r => path . relative ( __dirname , r . filePath ) ) ;
5454 paths . sort ( ) ;
5555 t . deepEqual ( paths , [ path . join ( 'fixtures' , 'cwd' , 'unicorn.js' ) ] ) ;
@@ -59,7 +59,7 @@ test('do not lint gitignored files', async t => {
5959 const cwd = path . join ( __dirname , 'fixtures/gitignore' ) ;
6060 const glob = path . posix . join ( cwd , '**/*' ) ;
6161 const ignored = path . resolve ( 'fixtures/gitignore/test/foo.js' ) ;
62- const { results} = await fn . lintFiles ( glob , { cwd} ) ;
62+ const { results} = await xo . lintFiles ( glob , { cwd} ) ;
6363
6464 t . is ( results . some ( r => r . filePath === ignored ) , false ) ;
6565} ) ;
@@ -68,7 +68,7 @@ test('do not lint gitignored files in file with negative gitignores', async t =>
6868 const cwd = path . join ( __dirname , 'fixtures/negative-gitignore' ) ;
6969 const glob = path . posix . join ( cwd , '*' ) ;
7070 const ignored = path . resolve ( 'fixtures/negative-gitignore/bar.js' ) ;
71- const { results} = await fn . lintFiles ( glob , { cwd} ) ;
71+ const { results} = await xo . lintFiles ( glob , { cwd} ) ;
7272
7373 t . is ( results . some ( r => r . filePath === ignored ) , false ) ;
7474} ) ;
@@ -77,7 +77,7 @@ test('lint negatively gitignored files', async t => {
7777 const cwd = path . join ( __dirname , 'fixtures/negative-gitignore' ) ;
7878 const glob = path . posix . join ( cwd , '*' ) ;
7979 const negative = path . resolve ( 'fixtures/negative-gitignore/foo.js' ) ;
80- const { results} = await fn . lintFiles ( glob , { cwd} ) ;
80+ const { results} = await xo . lintFiles ( glob , { cwd} ) ;
8181
8282 t . is ( results . some ( r => r . filePath === negative ) , true ) ;
8383} ) ;
@@ -86,22 +86,22 @@ test('do not lint inapplicable negatively gitignored files', async t => {
8686 const cwd = path . join ( __dirname , 'fixtures/negative-gitignore' ) ;
8787 const glob = path . posix . join ( cwd , 'bar.js' ) ;
8888 const negative = path . resolve ( 'fixtures/negative-gitignore/foo.js' ) ;
89- const { results} = await fn . lintFiles ( glob , { cwd} ) ;
89+ const { results} = await xo . lintFiles ( glob , { cwd} ) ;
9090
9191 t . is ( results . some ( r => r . filePath === negative ) , false ) ;
9292} ) ;
9393
9494test ( 'multiple negative patterns should act as positive patterns' , async t => {
9595 const cwd = path . join ( __dirname , 'fixtures' , 'gitignore-multiple-negation' ) ;
96- const { results} = await fn . lintFiles ( '**/*' , { cwd} ) ;
96+ const { results} = await xo . lintFiles ( '**/*' , { cwd} ) ;
9797 const paths = results . map ( r => path . basename ( r . filePath ) ) ;
9898 paths . sort ( ) ;
9999
100100 t . deepEqual ( paths , [ '!!unicorn.js' , '!unicorn.js' ] ) ;
101101} ) ;
102102
103103test ( 'enable rules based on nodeVersion' , async t => {
104- const { results} = await fn . lintFiles ( '**/*' , { cwd : 'fixtures/engines-overrides' } ) ;
104+ const { results} = await xo . lintFiles ( '**/*' , { cwd : 'fixtures/engines-overrides' } ) ;
105105
106106 // The transpiled file (as specified in `overrides`) should use `await`
107107 t . true (
@@ -126,14 +126,14 @@ test('do not lint eslintignored files', async t => {
126126 const glob = path . posix . join ( cwd , '*' ) ;
127127 const positive = path . resolve ( 'fixtures/eslintignore/foo.js' ) ;
128128 const negative = path . resolve ( 'fixtures/eslintignore/bar.js' ) ;
129- const { results} = await fn . lintFiles ( glob , { cwd} ) ;
129+ const { results} = await xo . lintFiles ( glob , { cwd} ) ;
130130
131131 t . is ( results . some ( r => r . filePath === positive ) , true ) ;
132132 t . is ( results . some ( r => r . filePath === negative ) , false ) ;
133133} ) ;
134134
135135test ( 'find configurations close to linted file' , async t => {
136- const { results} = await fn . lintFiles ( '**/*' , { cwd : 'fixtures/nested-configs' } ) ;
136+ const { results} = await xo . lintFiles ( '**/*' , { cwd : 'fixtures/nested-configs' } ) ;
137137
138138 t . true (
139139 hasRule (
@@ -169,7 +169,7 @@ test('find configurations close to linted file', async t => {
169169} ) ;
170170
171171test ( 'typescript files' , async t => {
172- const { results} = await fn . lintFiles ( '**/*' , { cwd : 'fixtures/typescript' } ) ;
172+ const { results} = await xo . lintFiles ( '**/*' , { cwd : 'fixtures/typescript' } ) ;
173173
174174 t . true (
175175 hasRule (
@@ -197,23 +197,23 @@ test('typescript files', async t => {
197197} ) ;
198198
199199test ( 'typescript 2 space option' , async t => {
200- const { errorCount, results} = await fn . lintFiles ( 'two-spaces.tsx' , { cwd : 'fixtures/typescript' , space : 2 } ) ;
200+ const { errorCount, results} = await xo . lintFiles ( 'two-spaces.tsx' , { cwd : 'fixtures/typescript' , space : 2 } ) ;
201201 t . is ( errorCount , 0 , JSON . stringify ( results [ 0 ] . messages ) ) ;
202202} ) ;
203203
204204test ( 'typescript 4 space option' , async t => {
205- const { errorCount} = await fn . lintFiles ( 'child/sub-child/four-spaces.ts' , { cwd : 'fixtures/typescript' , space : 4 } ) ;
205+ const { errorCount} = await xo . lintFiles ( 'child/sub-child/four-spaces.ts' , { cwd : 'fixtures/typescript' , space : 4 } ) ;
206206 t . is ( errorCount , 0 ) ;
207207} ) ;
208208
209209test ( 'typescript no semicolon option' , async t => {
210- const { errorCount} = await fn . lintFiles ( 'child/no-semicolon.ts' , { cwd : 'fixtures/typescript' , semicolon : false } ) ;
210+ const { errorCount} = await xo . lintFiles ( 'child/no-semicolon.ts' , { cwd : 'fixtures/typescript' , semicolon : false } ) ;
211211 t . is ( errorCount , 0 ) ;
212212} ) ;
213213
214214test ( 'webpack import resolver is used if webpack.config.js is found' , async t => {
215215 const cwd = 'fixtures/webpack/with-config/' ;
216- const { results} = await fn . lintFiles ( path . resolve ( cwd , 'file1.js' ) , {
216+ const { results} = await xo . lintFiles ( path . resolve ( cwd , 'file1.js' ) , {
217217 cwd,
218218 rules : {
219219 'import/no-unresolved' : 2
@@ -229,7 +229,7 @@ test('webpack import resolver is used if webpack.config.js is found', async t =>
229229test ( 'webpack import resolver config can be passed through webpack option' , async t => {
230230 const cwd = 'fixtures/webpack/no-config/' ;
231231
232- const { results} = await fn . lintFiles ( path . resolve ( cwd , 'file1.js' ) , {
232+ const { results} = await xo . lintFiles ( path . resolve ( cwd , 'file1.js' ) , {
233233 cwd,
234234 webpack : {
235235 config : {
@@ -251,7 +251,7 @@ test('webpack import resolver config can be passed through webpack option', asyn
251251test ( 'webpack import resolver is used if {webpack: true}' , async t => {
252252 const cwd = 'fixtures/webpack/no-config/' ;
253253
254- const { results} = await fn . lintFiles ( path . resolve ( cwd , 'file3.js' ) , {
254+ const { results} = await xo . lintFiles ( path . resolve ( cwd , 'file3.js' ) , {
255255 cwd,
256256 webpack : true ,
257257 rules : {
@@ -264,7 +264,7 @@ test('webpack import resolver is used if {webpack: true}', async t => {
264264} ) ;
265265
266266async function configType ( t , { dir} ) {
267- const { results} = await fn . lintFiles ( '**/*' , { cwd : path . resolve ( 'fixtures' , 'config-files' , dir ) } ) ;
267+ const { results} = await xo . lintFiles ( '**/*' , { cwd : path . resolve ( 'fixtures' , 'config-files' , dir ) } ) ;
268268
269269 t . true (
270270 hasRule (
0 commit comments