babel / babel/minify

Simplify expression call inside falling through case

Open
#448 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
4.4k
Forks
217
PR merge metrics
No merged PRs in 30d

Description

It is a feature request.
Currently this code sample
```js
function bar(foo) {
switch (foo) {
case 'foo':
log(a);
log(b);
log(c);
case 'bar':
return 2;
default:
return 0;
}
}
```
converted to
```js
function bar(foo) {
switch (foo) {
case 'foo':
log(a), log(b), log(c);
case 'bar':
return 2;
default:
return 0;
}
}

```

that could rather be converted to

```js
function bar(foo) {
return foo === 'foo' || foo === 'bar' ? (log(a), log(b), log(c), 2) : 0;
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.