我有一个包含大约 100 条规则的配置,在我的项目上运行包含所有这些规则的 eslint 大约需要 10 秒。我想找出最慢的规则并消除其中一些。我该怎么做呢?有没有针对 eslint 的分析器工具?
最佳答案
如果设置了环境变量TIMING
,eslint会显示规则所花费的时间。
例如:
$ TIMING=1 eslint lib
Rule | Time (ms) | Relative
:----------------------------|----------:|--------:
valid-jsdoc | 203.798 | 6.7%
camelcase | 142.146 | 4.6%
no-unmodified-loop-condition | 136.811 | 4.5%
indent | 127.138 | 4.2%
no-undefined | 124.525 | 4.1%
keyword-spacing | 85.397 | 2.8%
space-in-parens | 76.179 | 2.5%
no-this-before-super | 72.317 | 2.4%
no-implied-eval | 69.945 | 2.3%
space-infix-ops | 57.128 | 1.9%
另请参阅 Per-rule Performance 上的官方文档.
关于javascript - 我的配置中哪些 eslint 规则很慢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38458067/