JoshuaKGoldberg / JoshuaKGoldberg/TypeStat
Tooling: Adopt or run once good lints from eslint unicorn
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 47
- Avg merge
- 15h 55m
- Merged PRs (30d)
- 21
Description
### 🚀 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](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v51.0.1/docs/rules/no-empty-file.md) - there is one empty file `src/mutators/builtIn/fixIncompleteTypes/fixIncompleteReactTypes/reactFiltering/reactUsageFiltering.ts`. I think it could be just removed separately.
- [no-instanceof-array](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v51.0.1/docs/rules/no-instanceof-array.md) - I think this is no-brainer and should be fixed.
- [no-lonely-if](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v51.0.1/docs/rules/no-lonely-if.md) - makes code easier to read
- [no-negated-condition](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v51.0.1/docs/rules/no-negated-condition.md) - I think there were just few issues with this. But the code is easier to read after.
- [prefer-at](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v51.0.1/docs/rules/prefer-at.md) - This has few nice fixes
- [prefer-node-protocol](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v51.0.1/docs/rules/prefer-node-protocol.md) - a lot imports already use `node:`, this could unify them. This kind of rule will be in next major version of `eslint-plugin-n` too, I think.
- [prefer-string-replace-all](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v51.0.1/docs/rules/prefer-string-replace-all.md) - fixed some things, where regex was unnecessary actually.
On the fence:
- [no-array-reduce](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v51.0.1/docs/rules/no-array-reduce.md) - 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](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v51.0.1/docs/rules/no-for-loop.md) - 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](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v51.0.1/docs/rules/prefer-spread.md) 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`).
```json
"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",
```
Contributor guide
Assessment
This issue has not been assessed yet.