ESLint
安装
- npm
- Yarn
- pnpm
npm install --save-dev eslint eslint-config-alloy eslint-plugin-react @typescript-eslint/eslint-plugin @typescript-eslint/parser
yarn add --dev eslint eslint-config-alloy eslint-plugin-react @typescript-eslint/eslint-plugin @typescript-eslint/parser
pnpm add --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/**"