erb-no-unsafe-script-interpolation says to not use escape_javascript or j() in erb in script tags.
The docs say to do something like this:
<script>
var name = <%= user.name.to_json %>;
</script>
This actual breaks the resulting Javascript as to_json is not flagged as safe by Rails by default resulting in:
<script>
var name = "Someone";
</script>
To unbreak it, you have to call html_safe on it:
<script>
var name = <%= user.name.to_json.html_safe %>;
</script>
However, this interferes with erb-no-unsafe-raw.
erb-no-unsafe-script-interpolationsays to not useescape_javascriptorj()in erb in script tags.The docs say to do something like this:
This actual breaks the resulting Javascript as to_json is not flagged as safe by Rails by default resulting in:
To unbreak it, you have to call
html_safeon it:However, this interferes with
erb-no-unsafe-raw.