-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat: typescript-eslint@v6 #1476
Changes from all commits
5a24c6c
f4efe55
b9f5c96
0cc41a3
9772933
47bfca9
81b57af
8f182d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"create-t3-app": minor | ||
--- | ||
|
||
Upgraded typescript-eslint to v6, with reworked ESLint configurations |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,9 @@ import { | |
} from "~/utils/getUserPkgManager.js"; | ||
import { logger } from "~/utils/logger.js"; | ||
|
||
type Options = { | ||
interface Options { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://v6--typescript-eslint.netlify.app/rules/consistent-type-definitions is the rule to enforce which of For reference, a couple of full text regex searches on the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is one of the few that i don't feel strongly about. my personal preference is "type by default, interface only if necessary (ie need to extend)" but judging by these stats that's not actually what we're doing currently. what's the eslint team's opinion on this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We in typescript-eslint1 have I personally have leaned towards Footnotes
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I recommend using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. one big argument in favour of "type by default" is that you can't accidentally merge with globals, see https://tsplay.dev/wjanvW and i guess it also lets you know when you read a signature that what you're looking at is what you'll get as no merging can happen anywhere down the line. but i agree by far the most important thing is picking a set of rules and sticking with them. i'd like create-t3-app to use whatever can reasonably be called the "default" behaviour for this sort of stuff unless there's a very good reason not to. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to be clear - would you like me to disable the rule and revert its changes? I'm happy to, just not sure from the discussion 😅 |
||
projectDir: string; | ||
}; | ||
} | ||
|
||
/*eslint-disable @typescript-eslint/no-floating-promises*/ | ||
const runInstallCommand = async ( | ||
|
@@ -76,7 +76,7 @@ export const installDependencies = async ({ projectDir }: Options) => { | |
|
||
// If the spinner was used to show the progress, use succeed method on it | ||
// If not, use the succeed on a new spinner | ||
(installSpinner || ora()).succeed( | ||
(installSpinner ?? ora()).succeed( | ||
chalk.green("Successfully installed dependencies!\n") | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,9 @@ import { | |
} from "~/installers/index.js"; | ||
import { logger } from "~/utils/logger.js"; | ||
|
||
type InstallPackagesOptions = { | ||
type InstallPackagesOptions = InstallerOptions & { | ||
packages: PkgInstallerMap; | ||
} & InstallerOptions; | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://v6--typescript-eslint.netlify.app/rules/sort-type-constituents - is newly in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think i like it, makes it more like interface where the things you extend comes first There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great - if we end up removing it from the config, I can manually re-enable it in this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i like this a lot as well. if i'm reading an interface, i don't want to miss the fact that it extends something. |
||
// This runs the installer for all the packages that the user has selected | ||
export const installPackages = (options: InstallPackagesOptions) => { | ||
const { packages } = options; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without this, the type checked rules don't have the right compiler options: most notably |
||
"include": ["src", "template", "tsup.config.ts"] | ||
} |
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.
We right now have
no-explicit-any
moved into thestrict
config for v6. But I understand you were expecting it to be enabled. I'm now wondering if we should keep it atrecommended
?For context,
strict
is something we recommend for more confident TypeScript users. https://v6--typescript-eslint.netlify.app/linting/configs#strictThere 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.
so what's the main difference in strictness between
strict-type-checked
and the oldrecommended-requiring-type-checking
?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.
The
strict
&strict-type-checked
rulesets are a lot more opinionated. We phrase them as "Additional strict rules that can also catch bugs but are more opinionated than recommended rules.". In v6 they're supersets of the respectiverecommended
&recommended-type-checked
configs.https://v6--typescript-eslint.netlify.app/rules/?supported-rules=xrecommended-strict shows the rules that are in
strict*
and notrecommended*
.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.
after reading through the list, i would definitely want about 2/3 of the strict rules and am neutral-but-could-be-pushed-positive on the remaining 1/3.
for teams that are less experienced at typescript, i think autofixing where possible + good documentation for the errors could move quite a few of the rules into "reasonable for most teams" territory.
what is the motivation for moving
no-explicit-any
to the strict rules?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.
IIRC it was that a lot of projects end up needing to use
any
(or at least their developers think they do), and we're trying to not be in people's way as much with the recommended rulesets. In a sense this is us capitulating to how new & intermediate TypeScript developers write code (the occasionalany
, not always doing type safe things). Capitulating means less friction in turning on the recommended rulesets, at the cost of being less useful out-of-the-box.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.
Do you think educating those users to try to use
unknown
instead could help adoption?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.
Yes, definitely. A lot of these lint rules are better from user education - and can themselves act as user education!
Which reminds me, https://typescript-eslint.io/rules/no-explicit-any could do a bit better in that regard. Filed typescript-eslint/typescript-eslint#7136. Thanks! 😄
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.
Just following up, I finally got around to documenting this: typescript-eslint/typescript-eslint#8370