核心概念

此页面包含 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/HHFnVE8gkGA0s2jK2Be3kYeQAILbNlvGRQ0awxE8cabREksu8bQuFIk0FKk/aH63mq1eVeHVXS6T66sCmBQT6s9sskiAZ9yeoytf7tseP

可共享的配置

6+IQJOJAMnD1RLLFiI/IcX2gY5GTjBwFeNXcH4k57rZyxTh2CNcIyqzaNOFmBNANh7LkDsJIZwetJH8eGPu7Og==

eTPH26KAvg3pL0yZf7QimL9Sglr7T1v3I2ZuNTMOZdJKfKrKjdU9C3xayeslfXHJdussK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