0.0.2 • Published 2 months ago

@mozartchen/eslint-config v0.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
2 months ago

@mozartchen/eslint-config

TODO: 基于Airbnb的一些常用的eslint配置,包括basic、react、ts

Usage

  1. 安装eslint

    npm i eslint -D
  2. 安装本包

    npm i @mozartchen/eslint-config -D
  3. 若无eslint配置文件,则新建eslint配置文件.eslintrc.js

    module.exports = {
      root: true,
      extends: ['@mozartchen/eslint-config'],
      ignorePatterns: ['dist', '.eslintrc.cjs'],
    }
  4. 若需要使用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,
          },
        },
      ],
  5. 设置vscode中的默认格式化程序为eslint