核心概念

此页面包含 ESLint 的一些核心概念的高级概述。

什么是 ESLint?

ESLint 是一个可配置的 JavaScript 检查器。它可以帮助您发现并修复 JavaScript 代码中的问题。问题可以是任何东西,从潜在的运行时错误,到不遵循最佳实践,再到样式问题。

规则

规则是 ESLint 的核心构建块。规则验证您的代码是否满足特定期望,以及如果不满足该期望该怎么办。规则还可以包含特定于该规则的其他配置选项。

例如,semi 规则允许您指定 JavaScript 语句是否应以分号 (;) 结尾。您可以将规则设置为始终需要分号或要求语句从不以分号结尾。

ESLint 包含数百个您可以使用的内置规则。您还可以创建自定义规则或使用其他人通过 插件 创建的规则。

4FjNo8EaiG5botKunf2Ixf/HHFnVE8gkGA0s2jK2Be2yDOoX0TVMnqnjXKSjI/v88q9zJ6sLaowMSxjSm+eVCL0nnm1qCMKbhN6iszUqs3EICwqb7vqTzvHWUoHNNcSu

配置文件

CFqar5dMVToZCow8iYs4BAETxh2ZroWo6232mqwUHJYfcr98YGx/+ubKdk+HOOWW64TUc0drN2d99nPX0h+gzyHn+90VUsPE8MrnX0zSu3uMLOP5UB/TmIREqbi3WzjpPzu8Sa2oFetDvU12O/LY8mu1qE1WT89nLVAI8sYU01glNcVSgyxMNr/UdE6L0rT9Ni2r+iv/lQL4hePEr8456C8vIEqNEXMy/9CYEWcSXRF0qFceyb5IKNe4kiSWpUgYaVKabUsDYa5lgQdvIo4FjDbFrxCDRazHsorpnKZQ0pdD/cloZQCnhRe9XMKd6RO6

4FjNo8EaiG5botKunf2Ixf/HHFnVE8gkGA0s2jK2Be31+sh45GqpNWvecyl17U5qLk8JrNmCzzra5m+gMasjy3F8CzWEQ2n1CzEHEQCO7d+CGoZDWjBvakTDCL196kiH

可共享的配置

6+IQJOJAMnD1RLLFiI/IcX2gY5GTjBwFeNXcH4k57rZyxTh2CNcIyqzaNOFmBNANh7LkDsJIZwetJH8eGPu7Og==

eTPH26KAvg3pL0yZf7QimL9Sglr7T1v3I2ZuNTMOZdJKfKrKjdU9C3xayeslfXHJdussK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