TypeStat
TypeStat copied to clipboard
Tooling: Adopt or run once good lints from eslint unicorn
🚀 Feature Request
This should be done only after #1435 (#1318) has been merged.
I see that some of the code in the repo is older and does not follow some practices that are used nowadays. Eslint unicorn has some helpful lints to find these.
Run at least once:
- no-empty-file - there is one empty file
src/mutators/builtIn/fixIncompleteTypes/fixIncompleteReactTypes/reactFiltering/reactUsageFiltering.ts. I think it could be just removed separately. - no-instanceof-array - I think this is no-brainer and should be fixed.
- no-lonely-if - makes code easier to read
- no-negated-condition - I think there were just few issues with this. But the code is easier to read after.
- prefer-at - This has few nice fixes
- prefer-node-protocol - a lot imports already use
node:, this could unify them. This kind of rule will be in next major version ofeslint-plugin-ntoo, I think. - prefer-string-replace-all - fixed some things, where regex was unnecessary actually.
On the fence:
- no-array-reduce - there are some reduces in the code and I think they are fine. Or they need more thinking, how they could be removed, if wanted.
- no-for-loop - I'm not sure, will this help in this code base. Since performance is pretty critical in tool like this, it should be checked will this affect performance in any meaningful way.
- prefer-spread this is more stylistics thing.
If recommended set is adopted, these are the rules I had to disable locally while testing. Some of them are duplicate what ts-eslint has (e.g., prefer-module), some are just opposite what the repo uses (e.g., filename-case), and some of them can be dangerous (e.g., better-regex).
"unicorn/better-regex": "off",
"unicorn/explicit-length-check": "off",
"unicorn/filename-case": "off",
"unicorn/no-array-callback-reference": "off",
"unicorn/no-array-for-each": "off",
"unicorn/no-await-expression-member": "off",
"unicorn/no-nested-ternary": "off",
"unicorn/no-useless-undefined": "off",
"unicorn/prefer-module": "off",
"unicorn/prevent-abbreviations": "off",
"unicorn/switch-case-braces": "off",
I like it! This is related to the upstream (in CTA) issue: https://github.com/JoshuaKGoldberg/create-typescript-app/issues/1116.
@rubiesonthesky this could be a fun opportunity for you to contribute to a few libraries:
- Add the "unopinionated" config to
eslint-plugin-unicorn - Add usage of it to
create-typescript-app - Pull in those changes here
WDYT?
Yeah that makes sense :)
Great! In that case marking as blocked on eslint-plugin-unicorn providing that "unopinionated" config.