Why do linters pick on useless escape character?

前端 未结 2 1449
有刺的猬
有刺的猬 2021-01-29 07:51

Escaping non-special characters in strings, template literals, and regular expressions doesn\'t have any effect

Source: https://eslint.org/d

2条回答
  •  再見小時候
    2021-01-29 08:11

    Some linting rules are meant to make your code perfect.

    You can escape characters if you want to, but sometimes it doesn't have any effect. If you still do that, you just put a meaningless character in your code, confusing other programmers and wasting 1 byte. Your code escapes the underscore character with \_ sequence, whereas \ doesn't do anything in that sequence.

    This lint rule tells you about that. It's not the end of the world, but using that lint rule, you wanted to know.

提交回复
热议问题