0.0.2 • Published 2 months ago
@mozartchen/eslint-config v0.0.2
@mozartchen/eslint-config
TODO: 基于Airbnb的一些常用的eslint配置,包括basic、react、ts
Usage
安装eslint
npm i eslint -D
安装本包
npm i @mozartchen/eslint-config -D
若无
eslint
配置文件,则新建eslint
配置文件.eslintrc.js
module.exports = { root: true, extends: ['@mozartchen/eslint-config'], ignorePatterns: ['dist', '.eslintrc.cjs'], }
若需要使用
ts
,则项目中需要配置相应的tsconfig.json
文件,然后在eslint
配置中将ts
类型文件重载并指定ts
配置入口文件地址overrides: [ { // 若使用了react,则.tsx files: ['*.ts', '*.tsx'], // 若使用了react,则引入@mozartchen/eslint-config/react extends: ['@mozartchen/eslint-config/react', '@mozartchen/eslint-config/typescript'], parserOptions: { // 指定ts配置入口文件地址 tsconfigRootDir: __dirname, tsx: true, }, }, ],
设置
vscode
中的默认格式化程序为eslint