fix: migrate from deprecated tseslint.config to eslint/config#15409
fix: migrate from deprecated tseslint.config to eslint/config#15409JoshuaKGoldberg wants to merge 2 commits intomicrosoft:mainfrom
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15409Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15409" |
| export default tseslint.config( | ||
| { ignores: ['dist'] }, | ||
| export default defineConfig( | ||
| globalIgnores(['dist']), |
There was a problem hiding this comment.
[Explanation] As part of the move to eslint/config's helpers, we've seen users have a much easier time understanding configs with globalIgnores vs. the "object that just has ignores" equivalent. The two do the same thing.
| globalIgnores(['dist']), | ||
| { | ||
| extends: [js.configs.recommended, ...tseslint.configs.recommended], | ||
| extends: [js.configs.recommended, tseslint.configs.recommended], |
There was a problem hiding this comment.
...
[Explanation] This ... is unnecessary.
| extends: [js.configs.recommended, tseslint.configs.recommended], | ||
| files: ['**/*.{ts,tsx}'], | ||
| languageOptions: { | ||
| ecmaVersion: 2020, |
There was a problem hiding this comment.
[Explanation] In ESLint flat config, ecmaVersion defaults to "latest". Which is great in particular for TypeScript users: TypeScript will already catch any too-new-for-the-target-runtime syntax. There's no need to explicitly go back five ecmaVersions.
| languageOptions: { | ||
| parserOptions: { | ||
| projectService: true, | ||
| tsconfigRootDir: import.meta.dirname, |
There was a problem hiding this comment.
[Explanation] This is inferred from the ESLint config path now! A relatively recent quality-of-life improvement / simplification on the typescript-eslint side: typescript-eslint/typescript-eslint#11370
|
@dotnet-policy-service agree |
There was a problem hiding this comment.
Pull request overview
Updates Aspire’s TypeScript/React template ESLint flat configs to use ESLint core’s defineConfig() (via eslint/config) instead of the deprecated tseslint.config() helper, aligning templates with current ESLint guidance (fixes #15408).
Changes:
- Migrated multiple
eslint.config.*files fromtseslint.config()todefineConfig()and introducedglobalIgnores()for global ignore patterns. - Removed
tsconfigRootDir: import.meta.dirnamefrom TypeScript AppHost ESLint configs used by scaffolding/templates.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Aspire.ProjectTemplates/templates/aspire-ts-cs-starter/frontend/eslint.config.js | Switches to defineConfig() + globalIgnores() for the TS/React starter template. |
| src/Aspire.ProjectTemplates/templates/aspire-py-starter/frontend/eslint.config.js | Switches to defineConfig() + globalIgnores() for the Python starter’s frontend template. |
| src/Aspire.Hosting.CodeGeneration.TypeScript/TypeScriptLanguageSupport.cs | Updates scaffolded TypeScript AppHost ESLint config by removing tsconfigRootDir. |
| src/Aspire.Cli/Templating/Templates/ts-starter/frontend/eslint.config.js | Switches the CLI TS starter frontend ESLint config to defineConfig() + globalIgnores(). |
| src/Aspire.Cli/Templating/Templates/ts-starter/eslint.config.mjs | Removes tsconfigRootDir from the TS AppHost ESLint config template. |
| playground/FoundryAgentEnterprise/frontend/eslint.config.js | Switches playground frontend ESLint config to defineConfig() + globalIgnores(). |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Description
Switches from the deprecated
tseslint.config()to ESLint core'sdefineConfig(). I also threw in some little touchups here and there for fun, but I can split those out if you prefer. 😄Fixes #15408.
Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue:I know #15408 hasn't been triaged yet, but figured this was a straightforward change 🙂 apologies if I've broken some unspoken etiquette rule.