跳到主要内容

ESLint

安装

npm install --save-dev eslint eslint-config-alloy eslint-plugin-react @typescript-eslint/eslint-plugin @typescript-eslint/parser
npm pkg set scripts.eslint="eslint src"
npm pkg set scripts.eslint:fix="eslint --fix src"

配置

.eslintrc.cjs
module.exports = {
extends: ['alloy', 'alloy/typescript'],
env: {
// Your environments (which contains several predefined global variables)
//
// browser: true,
// node: true,
// mocha: true,
// jest: true,
// jquery: true
},
globals: {
// Your global variables (setting to false means it's not allowed to be reassigned)
//
// myGlobal: false
},
rules: {
// Customize your rules
},
};
.eslintignore
*.css

使用

npx eslint "src/**"