green-code-initiative / ecoCode-javascript

Reduce the environmental footprint of your JS/TS software programs
https://ecocode.io
GNU General Public License v3.0
21 stars 18 forks source link

eslint-plugin: write rules in TypeScript #11

Open utarwyn opened 1 year ago

utarwyn commented 1 year ago

ESLint exports a package @types/eslint with typings of the whole linter. This can simplify the writing of rules with autocompletion and typing verification.

This idea has been proposed during the challenge, and I think it's a good idea to look into it. Maybe we should use it? What do you think of this?

AMorgaut commented 2 months ago

Well, I both like and dislike TypeScript

TypeScript adds boilerplate that can quickly become cumbersome with added necessary build time Moreover, according to a well-knowned study (which would probably need an update), TypeScript was calculated as 4 times more energy consumming than JavaScript

Comparison to C

image

I usually prefered JSDoc where necessary. Nowadays, when IDEs don't do it natively, you should be able to also use TypeScript or the lighter flow to do typechecking and get autocompletion on regular JavaScript.

Both support "type inference" (which means that they detect the type of a variable / property based on the value it was initialized with)

TypeScript also supports part of JSDoc

Of course it's not as advanced as coding in TypeScript but energy impact and code complexity are lighter

See

utarwyn commented 2 months ago

The idea was to use TypeScript for the development of the plugin, but I agree that this will come with advantages and disavantages:

I understand your position but I think that the "ecological" cost of using TypeScript is not so bad, compared to the productivity boost.