npm install -g eslint
npm install —save-dev eslint eslint-loader
eslint —init
npm install —save-dev @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint eslint-friendly-formatter eslint-loader eslint-plugin-react
webpack.config.js
配置loader
{
test: /\.(js|ts|jsx|tsx)$/,
loader: 'eslint-loader',
enforce: "pre",
include: [path.resolve(__dirname, 'src')], // 指定检查的目录
options: { // 这里的配置项参数将会被传递到 eslint 的 CLIEngine
formatter: require('eslint-friendly-formatter') // 指定错误报告的格式规范
}
}
package.json