@@ -29,8 +29,7 @@ const dirMaxWarnings = join(__dirname, '../max-warnings')
29
29
const dirEmptyDirectory = join ( __dirname , '../empty-directory' )
30
30
const dirEslintIgnore = join ( __dirname , '../eslint-ignore' )
31
31
const dirNoEslintPlugin = join ( __dirname , '../no-eslint-plugin' )
32
- const dirPageDirNoConfig = join ( __dirname , '../no-config' )
33
- const dirAppDirNoConfig = join ( __dirname , '../app-dir/no-config' )
32
+ const dirNoConfig = join ( __dirname , '../no-config' )
34
33
const dirEslintCache = join ( __dirname , '../eslint-cache' )
35
34
const dirEslintCacheCustomDir = join ( __dirname , '../eslint-cache-custom-dir' )
36
35
const dirFileLinting = join ( __dirname , '../file-linting' )
@@ -42,7 +41,7 @@ describe('Next Lint', () => {
42
41
async function nextLintTemp ( setupCallback , isApp = false ) {
43
42
const folder = join ( os . tmpdir ( ) , Math . random ( ) . toString ( 36 ) . substring ( 2 ) )
44
43
await fs . mkdirp ( folder )
45
- await fs . copy ( isApp ? dirAppDirNoConfig : dirPageDirNoConfig , folder )
44
+ await fs . copy ( join ( dirNoConfig , isApp ? 'app' : '' ) , folder )
46
45
await setupCallback ?. ( folder )
47
46
48
47
try {
@@ -89,7 +88,7 @@ describe('Next Lint', () => {
89
88
{ packageManger : 'pnpm' , lockFile : 'pnpm-lock.yaml' } ,
90
89
{ packageManger : 'npm' , lockFile : 'package-lock.json' } ,
91
90
] ) {
92
- test ( `Page Router - installs eslint and eslint-config-next as devDependencies if missing with ${ packageManger } ` , async ( ) => {
91
+ test ( `installs eslint and eslint-config-next as devDependencies if missing with ${ packageManger } ` , async ( ) => {
93
92
const { stdout, pkgJson } = await nextLintTemp ( async ( folder ) => {
94
93
await fs . writeFile ( join ( folder , lockFile ) , '' )
95
94
} )
@@ -102,54 +101,54 @@ describe('Next Lint', () => {
102
101
expect ( stdout ) . toContain ( packageManger )
103
102
expect ( pkgJson . devDependencies ) . toHaveProperty ( 'eslint' )
104
103
expect ( pkgJson . devDependencies ) . toHaveProperty ( 'eslint-config-next' )
105
- } )
106
104
107
- test ( `App Router - installs eslint and eslint-config-next as devDependencies if missing with ${ packageManger } ` , async ( ) => {
108
- const { stdout, pkgJson } = await nextLintTemp ( async ( folder ) => {
109
- await fs . writeFile ( join ( folder , lockFile ) , '' )
110
- } , true )
105
+ // App Router
106
+ const { stdout : appStdout , pkgJson : appPkgJson } = await nextLintTemp (
107
+ async ( folder ) => {
108
+ await fs . writeFile ( join ( folder , lockFile ) , '' )
109
+ } ,
110
+ true
111
+ )
111
112
112
- expect ( stdout ) . toContain (
113
+ expect ( appStdout ) . toContain (
113
114
`Installing devDependencies (${ packageManger } ):`
114
115
)
115
- expect ( stdout ) . toContain ( 'eslint' )
116
- expect ( stdout ) . toContain ( 'eslint-config-next' )
117
- expect ( stdout ) . toContain ( packageManger )
118
- expect ( pkgJson . devDependencies ) . toHaveProperty ( 'eslint' )
119
- expect ( pkgJson . devDependencies ) . toHaveProperty ( 'eslint-config-next' )
116
+ expect ( appStdout ) . toContain ( 'eslint' )
117
+ expect ( appStdout ) . toContain ( 'eslint-config-next' )
118
+ expect ( appStdout ) . toContain ( packageManger )
119
+ expect ( appPkgJson . devDependencies ) . toHaveProperty ( 'eslint' )
120
+ expect ( appPkgJson . devDependencies ) . toHaveProperty ( 'eslint-config-next' )
120
121
} )
121
122
}
122
123
123
- test ( 'Page Router - creates .eslintrc.json file with a default configuration' , async ( ) => {
124
+ test ( 'creates .eslintrc.json file with a default configuration' , async ( ) => {
124
125
const { stdout, eslintrcJson } = await nextLintTemp ( )
125
126
126
127
expect ( stdout ) . toContain (
127
128
'We created the .eslintrc.json file for you and included your selected configuration'
128
129
)
129
130
expect ( eslintrcJson ) . toMatchObject ( { extends : 'next/core-web-vitals' } )
130
- } )
131
131
132
- test ( 'App Router - creates .eslintrc.json file with a default configuration' , async ( ) => {
133
- const { stdout, eslintrcJson } = await nextLintTemp ( undefined , true )
132
+ // App Router
133
+ const { stdout : appStdout , eslintrcJson : appEslintrcJson } =
134
+ await nextLintTemp ( null , true )
134
135
135
- expect ( stdout ) . toContain (
136
+ expect ( appStdout ) . toContain (
136
137
'We created the .eslintrc.json file for you and included your selected configuration'
137
138
)
138
- expect ( eslintrcJson ) . toMatchObject ( { extends : 'next/core-web-vitals' } )
139
+ expect ( appEslintrcJson ) . toMatchObject ( { extends : 'next/core-web-vitals' } )
139
140
} )
140
141
141
- test ( 'Page Router - shows a successful message when completed' , async ( ) => {
142
+ test ( 'shows a successful message when completed' , async ( ) => {
142
143
const { stdout } = await nextLintTemp ( )
143
144
144
145
expect ( stdout ) . toContain (
145
146
'ESLint has successfully been configured. Run next lint again to view warnings and errors'
146
147
)
147
- } )
148
148
149
- test ( 'App Router - shows a successful message when completed' , async ( ) => {
150
- const { stdout } = await nextLintTemp ( undefined , true )
151
-
152
- expect ( stdout ) . toContain (
149
+ // App Router
150
+ const { stdout : appStdout } = await nextLintTemp ( null , true )
151
+ expect ( appStdout ) . toContain (
153
152
'ESLint has successfully been configured. Run next lint again to view warnings and errors'
154
153
)
155
154
} )
0 commit comments