Skip to content

tinywaves/eslint-config

Repository files navigation

@dhzh/eslint-config

npm

Special Statement: This project comes from @antfu/eslint-config. The two are almost the same, with only some differences to meet personal needs. In order to seek convenience and prevent some conflicts between the upstream branch and my own changes after forking, I chose to copy instead of fork.

Differences from @antfu/eslint-config:

  1. With semi: semi: true.
  2. Always arrow parens: arrowParens: true.
  3. Explicitly use 1tbs as brace style: braceStyle: '1tbs'.
  4. Disabled antfu's top level function rule: 'antfu/top-level-function': 'off'.
  5. Always curly:
  • 'antfu/curly': 'off'
  • 'curly': ['error', 'all']
  1. This eslint-config will enable ts/consistent-type-imports rule. But it will cause compile issue in nest projects. So I disabled it in this config in nest framework.
  2. Support '**/*.?([cm])js and '**/*.?([cm])jsx files in react projects.
  3. Perfectionist plugin for imports sorting:
[
  'builtin',
  'external',
  'internal',
  'parent',
  'sibling',
  'index',
  'style',
  'side-effect',
  'side-effect-style',
  'object',
  'builtin-type',
  'external-type',
  'internal-type',
  'parent-type',
  'sibling-type',
  'index-type',
  'unknown',
];

Note: Temporarily close the rules of the Perfectionist plugin from version v0.15.0, because I haven't found a way to achieve the best balance between actual development needs and personal habits.

  1. React related:
  • 'react/no-useless-fragment': 'warn'
  1. Remove spacing when useing jsx curly braces:
  • 'style/jsx-curly-spacing': ['error', { children: true, when: 'never' }]
  1. Keep auto fix with code editors for rules: prefer-const, unused-imports/no-unused-imports.

Usage

Requires ESLint v9.5.0+

Starter Wizard

We provided a CLI tool to help you set up your project, or migrate from the legacy config to the new flat config with one command.

pnpm dlx @dhzh/eslint-config@latest

Manual Install

If you prefer to set up manually:

pnpm i -D eslint @dhzh/eslint-config

And create eslint.config.mjs in your project root:

// eslint.config.mjs
import dhzh from '@dhzh/eslint-config';

export default dhzh();

License

MIT License © 2022-PRESENT Lyle Zheng