0.0.5 • Published 10 months ago

eslint-config-tyson v0.0.5

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

tyson's eslint config presets

English | 中文

  • Auto fix for formatting with Prettier
  • Mulit eslint config presets: JavaScript, JSON, TypeScript, Vue, React, ReactNative, Svelte, Solid and Astro
  • Format other files by Prettier: HTML, CSS, Less, Sass, Scss, Markdown, MDX, yaml and yml
  • Default Alias mapping "@" => "src", "~" => "./"

Usage

Install

pnpm i -D eslint typescript eslint-config-tyson

Eslint config file

create config file ".eslintrc.js"

module.exports = {
  extends: "tyson",
};
  • tyson: base config, lint JS, TS, JSON
  • tyson/vue: extend base config,lint Vue
  • tyson/vue2: extend base config,lint Vue2
  • tyson/react: extend base config,lint React
  • tyson/react-native: extend react config,lint ReactNative
  • tyson/solid: extend base config,lint Solid
  • tyson/svelte: extend base config,lint Svelte
  • tyson/astro: extend base config,lint Astro

please choose the suitable config for your project You don't need .eslintignore normally as it has been provided by the preset.

set multi eslint configs in a project

For example, there are some tsx files written by Solid under the folder "solid", and there are some tsx files written by React under the folder "react", then you can create the eslint config file under the folder, which are "tyson/solid" and "tyson/react"

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"]
      }
    }
  }
}

VSCode settings for ESlint

{
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "editor.formatOnSave": false,
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact",
    "vue",
    "svelte",
    "astro",
    "json"
  ]
}

Add scripts for package.json

{
  "scripts": {
    "lint": "eslint . --fix"
  }
}
  • then use the following scripts to format and fix the project code
pnpm lint
  • format other files
pnpm format