Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ESLint Rule to Warn on Typescript's erasableSyntaxOnly flag

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?

like image 770
Vencovsky Avatar asked Oct 26 '25 15:10

Vencovsky


2 Answers

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, // 👈
);

https://github.com/JoshuaKGoldberg/eslint-plugin-erasable-syntax-only

(disclaimer: I'm the author)

like image 59
Josh Avatar answered Oct 29 '25 05:10

Josh


go to tsconfig.app.json

you will see:

"erasableSyntaxOnly": true,

change this to:

"erasableSyntaxOnly": false,
like image 36
sultan s. alfaifi Avatar answered Oct 29 '25 05:10

sultan s. alfaifi