demergent-labs / azle

A WebAssembly runtime for TypeScript and JavaScript on ICP
MIT License
186 stars 33 forks source link

Linting Wish List #1576

Open bdemann opened 3 months ago

bdemann commented 3 months ago

Good referenc for all of the rules

Linting philosophy

With https://github.com/demergent-labs/azle/pull/1733 we were able to add the recomended linting rules and some of the below rules. From here we are going to add new linting rules in this manner. As we are going though PRs if there is something that keeps standing out to us and something we keep needing to call out, then we will set apart some time to enable the rule and fix all of the problems for that rule.

Rules we want but will take a long time to implement

Consider the following rules

Things that might be nice but require parsing https://github.com/demergent-labs/azle/issues/1739

Things Jordan wants (from https://github.com/demergent-labs/azle/issues/1535)

I'm guessing Jordan would like

Things to look into

Help with declarative code

Probably Unrealistic

I'm not sure we need this but maybe we might as well

Formatting

Resolved with https://github.com/demergent-labs/azle/pull/1733

bdemann commented 1 month ago

Here are some rules that I tried out that didn't go so well


const proposedRules = {
    '@typescript-eslint/explicit-function-return-type': 'error', // 1413 problems // TODO https://github.com/demergent-labs/azle/issues/1576
    'consistent-return': 'off',
    '@typescript-eslint/consistent-return': 'error', // TODO this one isn't found?
    '@typescript-eslint/consistent-type-definitions': ['error', 'type'], // TODO seems nice but there are 17 places where I think we need interfaces over types
    '@typescript-eslint/strict-boolean-expressions': 'error', // TODO requires special parsing set up and more javascript heap
    '@typescript-eslint/prefer-optional-chain': 'error', // TODO same
    '@typescript-eslint/prefer-nullish-coalescing': 'error' // TODO same
};
bdemann commented 2 weeks ago

To do more complicated linting with different setting at different folders (which might enable being able to lint everything with the typescript compiler plugin) we may need to play around with the config file. It looks like they have recently updated the config file, and we are still on the new one. We may need to upgrade.

https://eslint.org/docs/latest/use/getting-started#configuration https://eslint.org/docs/latest/use/configure/migration-guide https://eslint.org/blog/2022/08/new-config-system-part-2/