build: enable eslint rules for arrow functions
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 807
- Avg merge
- 10h 12m
- Merged PRs (30d)
- 7
Description
# Problem
javascript arrow functions allow braces `{ ... }` to surround an expression without a `return`, which leads to bugs such as https://github.com/aws/aws-toolkit-vscode/pull/3659
Example:
```javascript
return supplementalContexts.filter(item => { item.content.trim().length !== 0 })
```
should be:
```javascript
return supplementalContexts.filter(item => item.content.trim().length !== 0)
```
# Solution
Enable these rules:
- https://eslint.style/packages/default#stylistic-eslint-plugin
- https://eslint.style/rules/default/no-confusing-arrow
- https://eslint.org/docs/latest/rules/arrow-body-style
- ✅ https://eslint.org/docs/latest/rules/no-constant-condition
- Already enabled via `'eslint:recommended'`. Confirmed with `--print-config`:
```
./node_modules/.bin/eslint --ignore-path .gitignore -c .eslintrc.js --print-config -
"no-constant-condition": [
"error",
{
"checkLoops": false
}
],
```
Evaluate other arrow-function related estlint rules and potentially enable them.
Contributor guide
Research direction
Start with .eslintrc.js and inspect the current configuration using the mentioned eslint --print-config command. Review the linked arrow-function rules and evaluate other related rules. Done means the appropriate rules are enabled and the repository's lint checks pass without introducing the described arrow-function bug.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100