๐Ÿ“ฆ hyoban / eslint-config-hyoban

Hyoban's ESLint config preset

โ˜… 42 stars โ‘‚ 3 forks ๐Ÿ‘ 42 watching โš–๏ธ MIT License
eslinteslint-config
๐Ÿ“ฅ Clone https://github.com/hyoban/eslint-config-hyoban.git
HTTPS git clone https://github.com/hyoban/eslint-config-hyoban.git
SSH git clone git@github.com:hyoban/eslint-config-hyoban.git
CLI gh repo clone hyoban/eslint-config-hyoban
Stephen Zhou Stephen Zhou chore: release v5.0.6 333ce56 6 days ago ๐Ÿ“ History
๐Ÿ“‚ main View all commits โ†’
๐Ÿ“ .github
๐Ÿ“ .vscode
๐Ÿ“ playground
๐Ÿ“ scripts
๐Ÿ“ src
๐Ÿ“„ .gitignore
๐Ÿ“„ .npmrc
๐Ÿ“„ eslint.config.ts
๐Ÿ“„ LICENSE
๐Ÿ“„ package.json
๐Ÿ“„ pnpm-lock.yaml
๐Ÿ“„ README.md
๐Ÿ“„ stub.d.ts
๐Ÿ“„ tsconfig.json
๐Ÿ“„ README.md

eslint-config-hyoban

npm version npm downloads License

Hyoban's ESLint Config enables most of the recommended rules for js, ts, and react, uses ESLint for formatting, and provides a lot of useful plugins.

Read more about why I use ESLint for linting and formatting on xLog.

BasicStyleReactOthersTools
[js] โœ…[stylistic] โœ…[react] โœ…[Tailwind CSS][config-inspector] โœ…
[ts] โœ…[antfu] โœ…[hooks] โœ…[UnoCSS][eslint-types]
[unicorn] โœ…[import-sort] โœ…[refresh] โœ…[flat-gitignore] โœ…[eslint-typegen] โœ…
[import-x] โœ…[jsonc] โœ…[compiler] โœ…[command] โœ…[@antfu/eslint-config]
[unused-import] โœ…[yml][jsx-a11y][regexp] โœ…
[n][perfectionist][next][package-json] โœ…
[compat][format][jsx-nesting][cspell]

Usage

[!TIP]
You may not need lint-staged and simple-git-hooks if you don't ignore auto-fix for rules in the editor.

ni -D eslint eslint-config-hyoban lint-staged simple-git-hooks

[!TIP]
You can install the nightly version from pkg.pr.new, for example, ni -D https://pkg.pr.new/hyoban/eslint-config-hyoban@{commit}.

eslint.config.mjs

// @ts-check
import { defineConfig } from 'eslint-config-hyoban'

export default defineConfig()

[!TIP]
You can customize the preset by passing options according to available options

package.json

{
  "scripts": {
    "lint": "eslint",
    "lint:fix": "eslint --fix",
    "prepare": "simple-git-hooks"
  },
  "simple-git-hooks": {
    "pre-commit": "npx lint-staged"
  },
  "lint-staged": {
    "*": "eslint --fix"
  }
}

.vscode/settings.json for VSCode.

{
  // You shouldn't use formatter with this ESLint config
  "[javascript][javascriptreact][typescript][typescriptreact][json][jsonc]": {
    "editor.formatOnSave": false,
    "editor.codeActionsOnSave": {
      "source.fixAll.eslint": "explicit"
    }
  },

  // If you do not want to auto fix some rules on save
  // You can put this in your user settings or workspace settings
  "eslint.codeActionsOnSave.rules": [
    "!prefer-const",
    "!unused-imports/no-unused-imports",
    "!@stylistic/jsx-self-closing-comp",
    "*"
  ],

  // If you want to silent stylistic rules
  // You can put this in your user settings or workspace settings
  "eslint.rules.customizations": [
    { "rule": "@stylistic/*", "severity": "off", "fixable": true },
    { "rule": "antfu/consistent-list-newline", "severity": "off" },
    { "rule": "hyoban/jsx-attribute-spacing", "severity": "off" },
    { "rule": "simple-import-sort/*", "severity": "off" },
    { "rule": "prefer-const", "severity": "off" },
    { "rule": "unused-imports/no-unused-imports", "severity": "off" }
  ],

  // You can also silent all auto fixable rules
  "eslint.rules.customizations": [
    { "rule": "*", "fixable": true, "severity": "off" }
  ]
}

TypeAware Rules

We recommend using tsslint for type-aware rules.

A example tsslint.config.ts:

import { defineConfig } from "@tsslint/config"
import { convertRules } from "@tsslint/eslint"

export default defineConfig({
  rules: await convertRules({
    "react-x/no-leaked-conditional-rendering": "error",
  }),
})

Who is using?