Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a place to test if code is ES5 compliant / safe?

Sometimes I'd like to know if the code I'm writing is ES5 compliant/safe or not.

Example: this would fail because of the arrow function.

() => "something";

I know Babel could take care of this. But sometimes I would like to test some cases.

Is there a place where I could do this?

like image 525
cbdeveloper Avatar asked Mar 03 '23 19:03

cbdeveloper


1 Answers

Try ESlint, https://eslint.org/demo. You can disable advanced rules and stick to the basics.

For example, with an arrow function on ES5: https://eslint.org/demo#eyJ0ZXh0IjoiKCkgPT4gXCJzb21ldGhpbmdcIjsiLCJvcHRpb25zIjp7InBhcnNlck9wdGlvbnMiOnsiZWNtYVZlcnNpb24iOjUsInNvdXJjZVR5cGUiOiJzY3JpcHQiLCJlY21hRmVhdHVyZXMiOnt9fSwicnVsZXMiOnt9LCJlbnYiOnt9fX0=

It could also be automated as part of a build/ci script.

like image 164
rkouye Avatar answered Mar 05 '23 07:03

rkouye