最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ESLint Rule to Warn on Typescript's erasableSyntaxOnly flag - Stack Overflow

programmeradmin3浏览0评论

Typescript is launching --erasableSyntaxOnly flag in v5.8 that will throw an error if you use things like enum or parameter properties in classes (see article for more details).

When I enable that flag, I get so many errors that I won't be able to fix it all at once.

So I wanted a ESLint rule that can warn me when using invalid syntax so I can do a incremental removal of this syntax before enabling the flag in tsconfig.

What is the ESLint rule for this? If it doesn't exist, is there a way to do it using no-restricted-syntax?

Typescript is launching --erasableSyntaxOnly flag in v5.8 that will throw an error if you use things like enum or parameter properties in classes (see article for more details).

When I enable that flag, I get so many errors that I won't be able to fix it all at once.

So I wanted a ESLint rule that can warn me when using invalid syntax so I can do a incremental removal of this syntax before enabling the flag in tsconfig.

What is the ESLint rule for this? If it doesn't exist, is there a way to do it using no-restricted-syntax?

Share Improve this question asked Feb 15 at 9:51 VencovskyVencovsky 31.7k22 gold badges130 silver badges195 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Yes, there is a plugin for this now, eslint-plugin-erasable-syntax-only. To use it, install it as a dev dependency:

npm i eslint-plugin-erasable-syntax-only -D

Then add its recommended configuration in your ESLint config file:

import erasableSyntaxOnly from "eslint-plugin-erasable-syntax-only";
import tseslint from "typescript-eslint";

export default tseslint.config(
    eslint.configs.recommended,
    tseslint.configs.recommended,
    erasableSyntaxOnly.configs.recommended, // 
发布评论

评论列表(0)

  1. 暂无评论