Recently we broke Safari in production because code I'd written that looked
like this:
```javascript
if (true) {
function test() {
}
test();
}
```
In Chrome and Firefox the above works well, but in Safari you get an error:
`SyntaxError: Strict mode does not allow function declarations in a
lexically nested statement.`
This can be fixed by changing the code to this:
```javascript
if (true) {
const test = function() {
}
test();
}
```
I looked for a rule in ESLint to prevent the first (bad) code from running
but I can't find one. The closest seems to be `func-style` which locks you
into one or the other, but what I'm actually looking for is the ability to
raise an error when Safari would.
Is there anything in ESLint to do this? Is there a way to propose this if
not?
--
You received this message because you are subscribed to the Google Groups
"ESLint" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.