-
Notifications
You must be signed in to change notification settings - Fork 31.1k
feat: enable @typescript-eslint/recommended in create-next-app --typescript #52845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
eps1lon
merged 17 commits into
vercel:canary
from
JoshuaKGoldberg:enable-typescript-eslint-recommended
Jun 27, 2024
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
aab603d
feat: use @typescript-eslint/recommended-type-checked in create-next-…
JoshuaKGoldberg 6097634
Remove missing link
JoshuaKGoldberg be44617
Switch to next/typescript
JoshuaKGoldberg f2197eb
lil docs typo
JoshuaKGoldberg 2e0ae5f
Undid js config file updates
JoshuaKGoldberg aa44c6a
Reduced eslint-plugin to ^6.0.0
JoshuaKGoldberg 3aee1e9
Fix next-lint.test.js integration test
JoshuaKGoldberg 856b45d
Small refactor: extracted getESLintStrictValue
JoshuaKGoldberg 34b0b3d
Pass basedir/cwd through
JoshuaKGoldberg 6fb50cf
There was a floating Promise. Amusing
JoshuaKGoldberg 258aba9
Switch to recommended, not recommended-type-checked
JoshuaKGoldberg 4bc8cbd
fix: touchups to eslint-config-next
JoshuaKGoldberg 74b9541
Update tests
eps1lon ee438b8
Corrections: non-TS starter .json; pass cwd to findUp
JoshuaKGoldberg 141b92d
test: next-lint.test.js
JoshuaKGoldberg 7c99396
Avoid mistakes by writing simple code
eps1lon 726f533
Restore and align previous dependency version
eps1lon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| { | ||
| "extends": "next/core-web-vitals" | ||
| "extends": ["next/core-web-vitals", "next/typescript"] | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| { | ||
| "extends": "next/core-web-vitals" | ||
| "extends": ["next/core-web-vitals", "next/typescript"] | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| { | ||
| "extends": "next/core-web-vitals" | ||
| "extends": ["next/core-web-vitals", "next/typescript"] | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| { | ||
| "extends": "next/core-web-vitals" | ||
| "extends": ["next/core-web-vitals", "next/typescript"] | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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,3 @@ | ||
| module.exports = { | ||
| extends: ['plugin:@typescript-eslint/recommended'], | ||
| } |
This file contains hidden or 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 hidden or 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,32 @@ | ||
| import findUp from 'next/dist/compiled/find-up' | ||
|
|
||
| export const getESLintStrictValue = async (cwd: string) => { | ||
| const tsConfigLocation = await findUp('tsconfig.json', { cwd }) | ||
| const hasTSConfig = tsConfigLocation !== undefined | ||
|
|
||
| return { | ||
| title: 'Strict', | ||
| recommended: true, | ||
| config: { | ||
| extends: hasTSConfig | ||
| ? ['next/core-web-vitals', 'next/typescript'] | ||
|
eps1lon marked this conversation as resolved.
Outdated
|
||
| : 'next/core-web-vitals', | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| export const getESLintPromptValues = async (cwd: string) => { | ||
| return [ | ||
| await getESLintStrictValue(cwd), | ||
| { | ||
| title: 'Base', | ||
| config: { | ||
| extends: 'next', | ||
| }, | ||
| }, | ||
| { | ||
| title: 'Cancel', | ||
| config: null, | ||
| }, | ||
| ] | ||
| } | ||
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JoshuaKGoldberg It'd be also nice as a follow-up to document how one would opt-into type-aware ESLint rules.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah! Strong +1.
Since typescript-eslint v8 with the stabilized
projectServiceis coming in a few months, my suggestion would be to procrastinate until then. That way we can use the nice:{ "extends": ["next/core-web-vitals", "next/typescript", + "plugin:@typescript-eslint/recommended-type-checked" // (or similar) ], + "parserOptions": { + "projectService": true + } }