0.2.3 • Published 1 year ago

eslint-config-soybeanjs-base v0.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

eslint-config-soybeanjs-base

English | 中文

SoybeanJS's base eslint config presets

  • Auto fix for formatting with prettier
  • Lint JavaScript
  • Lint also for JSON, yaml, markdown
  • Reasonable defaults, best practices, only one-line of config
  • Default Alias mapping "@" => "src", "~" => "./"

Usage

Install

pnpm i -D eslint eslint-config-soybeanjs-base

Eslint config file

create a file, one of .eslintrc, .eslintrc.js, .eslintrc.json

  • .eslintrc.js
module.exports = {
  extends: "soybeanjs-base"
}
  • .eslintrc.json、.eslintrc
{
  "extends": "soybeanjs-base"
}

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

Config alias

the following code is the default config(there is no need to add), please change the alias follow the following code if need

{
  "settings": {
    "import/resolver": {
      "alias": {
        "map": [
          ["~", "."],
          ["@", "./src"]
        ],
        "extensions": [".js", ".jsx", ".mjs", ".ts", ".tsx", "mts", ".d.ts"]
      }
    }
  }
}

Add scripts for package.json

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

then use the following scripts to format and fix the project code

npm run lint # npm
yarn lint # yarn
pnpm lint # pnpm