-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes for ESLint rule no-app-not-found-runtime (#539)
* Use correct name for export of no-app-not-found-runtime lint rule Fixes #530 * Add support for src folder to no-app-not-found-runtime lint rule Fixes #531
- Loading branch information
Showing
5 changed files
with
91 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'eslint-plugin-next-on-pages': patch | ||
--- | ||
|
||
Support for using src folder with no-app-not-found-runtime lint rule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'eslint-plugin-next-on-pages': patch | ||
--- | ||
|
||
Use correct name for export of no-app-not-found-runtime lint rule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
packages/eslint-plugin-next-on-pages/tests/rules/no-app-not-found-runtime.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import path from 'path'; | ||
import { RuleTester } from 'eslint'; | ||
|
||
import rule from '../../src/rules/no-app-not-found-runtime'; | ||
import { describe, test } from 'vitest'; | ||
|
||
const tester = new RuleTester({ | ||
parser: require.resolve('@typescript-eslint/parser'), | ||
}); | ||
|
||
const contextCwd = path.join(__dirname, '../..'); | ||
|
||
describe('no-app-not-found-runtime', () => { | ||
test('should work', () => { | ||
tester.run('no-app-not-found-runtime', rule, { | ||
valid: [ | ||
{ | ||
filename: path.join(contextCwd, '/app/not-found.tsx'), | ||
code: ` | ||
export default function Page() { | ||
return 'Not Found'; | ||
} | ||
`, | ||
}, | ||
{ | ||
filename: path.join(contextCwd, '/app/page.tsx'), | ||
code: ` | ||
export const runtime = 'edge'; | ||
export default function Page() { | ||
return 'Hello'; | ||
} | ||
`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
filename: path.join(contextCwd, '/app/not-found.tsx'), | ||
code: "export const runtime = 'edge';", | ||
errors: [ | ||
{ | ||
message: `Only static not-found pages are currently supported, please remove the runtime export in ${contextCwd}/app/not-found.tsx`, | ||
}, | ||
], | ||
output: '', | ||
}, | ||
], | ||
}); | ||
}); | ||
|
||
test('should work with src folder', () => { | ||
tester.run('no-app-not-found-runtime', rule, { | ||
valid: [ | ||
{ | ||
filename: path.join(contextCwd, '/src/app/not-found.tsx'), | ||
code: ` | ||
export default function Page() { | ||
return 'Not Found'; | ||
} | ||
`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
filename: path.join(contextCwd, '/src/app/not-found.tsx'), | ||
code: "export const runtime = 'edge';", | ||
errors: [ | ||
{ | ||
message: `Only static not-found pages are currently supported, please remove the runtime export in ${contextCwd}/src/app/not-found.tsx`, | ||
}, | ||
], | ||
output: '', | ||
}, | ||
], | ||
}); | ||
}); | ||
}); |