aws / aws/aws-toolkit-vscode

build: enable eslint rules for arrow functions

Open
#3,662 0 comments 0 reactions 0 assignees View on GitHub
build technical-debt tests-ci-cd
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.