azl397985856 / fe-interview

宇宙最强的前端面试指南 (https://lucifer.ren/fe-interview)
Apache License 2.0
2.83k stars 260 forks source link

【每日一题】- 2020-05-05 - no-magic-string #122

Closed azl397985856 closed 4 years ago

azl397985856 commented 4 years ago

为什么eslint 有一个 rule 是 no-magic-number. 而没有类似的比如 no-magic-string?或者更广泛一点,为什么没有no-magic-literal?

suukii commented 4 years ago

Why Constant Beats Magic Number

Why Magic String Might Be Bad

Magic string can be evil too. 所以感觉是不是也应该有一个 no-magic-string rule 呢。

至于其他 literal,boolean, undefined, null 都只有一两个值就没必要了,object, array 之类的,也很少会有人这样子用吧。

azl397985856 commented 4 years ago

https://lucifer.ren/blog/2020/05/05/why-no-magic-string/

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.