1.0.4 • Published 5 months ago

@itaober/eslint-config v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@itaober/eslint-config

English | 简体中文

Introduction

@itaober/eslint-config provides a set of ESLint configuration presets based on personal preferences:

  • Requires ESLint v9 or above
  • Default support for ESLint Flat config
  • Reasonable presets, one-line setup, out-of-the-box usage
  • Support for TypeScript, React, and more
  • Compatible with Prettier

Installation

pnpm add eslint @itaober/eslint-config -D

Usage

Configuration File

For more configuration options, refer to ESLint Flat config

Create eslint.config.js in your project root directory and add the following code:

import getESLintConfig from '@itaober/eslint-config';

export default getESLintConfig();

Add Scripts to package.json

{
  "scripts": {
    "lint": "eslint .",
    "lint:fix": "eslint . --fix"
  }
}

IDE Support

VSCode

  1. Install the ESLint extension
  2. Add the following configuration to your settings.json:
{
  "eslint.enable": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "explicit",
    "source.organizeImports": "never",
  },
  "eslint.runtime": "node",
  "eslint.run": "onSave",
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact",
    "vue",
    "html",
  ],
  "eslint.workingDirectories": [
    {
      "mode": "auto",
    },
  ],
}

Optional Configs

Lint staged

If you want ESLint to check and automatically fix your code before each commit, you can use simple-git-hooks and lint-staged:

  1. Install the required dependencies:
pnpm add simple-git-hooks lint-staged -D
  1. Add the following configuration to your package.json:
{
  "scripts": {
    "prepare": "simple-git-hooks"
  },
  "simple-git-hooks": {
    "pre-commit": "pnpm lint-staged"
  },
  "lint-staged": {
    "*": "pnpm lint:fix"
  }
}
  1. Activate simple-git-hooks:
npx simple-git-hooks

License

License MIT