Skip to content

zgsgs/eslint-config

Repository files navigation

Manage code specification with eslint only

English | 中文翻译


npm

Feature

  • Single quotes, no semi
  • Auto fix for formatting (aimed to be used standalone without Prettier)
  • TypeScript, Vue, React out-of-box
  • Lint also for json, yaml, markdown
  • Sorted imports, dangling commas for cleaner commit diff
  • Reasonable defaults, best practices, only one-line of config

Usage

Install

pnpm add -D eslint @unonu/eslint-config

Config .eslintrc

{
  "extends": "@unonu"
}

OR

// package.json
{
  "eslintConfig": {
    "extends": "@unonu"
  }
}

You don't need .eslintignore normally as it has been provided by the preset.

Add script for package.json

For example:

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

Config VS Code auto fix

Create .vscode/settings.json

{
  "prettier.enable": false,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  }
}

It is recommended not to use prettier when using eslint. This configuration has done quite a bit of formatting lint, leaving the rest of the flexibility and style to the developer.

VS Code Settings


Copy the .vscode directory go to Your Project Root Directory

Other Setting

Github Setting

Copy the .github directory go to Your Project Root Directory

Complete the commit message specification restriction and repair using Husky & lint-staged & COMMITLINT

  • Copy the .husky directory and commitlint.config.js go to Your Project Root Directory
  • Edit your .package.json
{
  "scripts": {
    "lint": "lint-staged",
    "prepare": "husky install"
  },
  "lint-staged": {
    "*.{vue,js,jsx,ts,tsx,json}": [
      "eslint --fix",
      "git add ." // Note that all files are automatically saved here, please use with `.gitignore`
    ]
  }
}

Other configuration files

  • .editorconfig - Edit config
  • .gitignore Git ignore special files
  • LICENSE Open Source LICENSE
  • netlify.toml Netlify platform configuration
  • pnpm-workspace.yaml defines the root of the and enables you to include / exclude directories from the workspace.
  • renovate.json Use renovate to monitor third-party dependent updates

Check Also

License

MIT