Skip to content

cany748/eslint-config

Repository files navigation

@cany748/eslint-config

ESLint config for JavaScript, TypeScript, Vue 2/3.

Based on Anthony Fu configs.

Usage

Install

pnpm add -D @cany748/eslint-config
# Or yarn add -D / npm install -D / bun add -D

Config

// eslint.config.ts
{
  import { factoryConfig } from "@cany748/eslint-config";

  export default factoryConfig({
    // Type of the project. 'lib' for libraries, the default is 'app'
    type: "lib",

    // TypeScript, Vue and UnoCSS are autodetected, you can also explicitly enable them:
    typescript: true,
    vue: true,
    unocss: true,

    // to enable type-aware rules use
    typescript: { tsconfigPath: "./tsconfig.json", filesTypeAware: ["**/*.{ts,tsx,vue}"] },
  });
}
// `.prettierrc` or `prettier` on `package.json`
{
  "printWidth": 140,
}

Add script for package.json

For example:

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

Lint Staged

If you want to apply lint and auto-fix before every commit, you can add the following to your package.json:

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

and then

pnpm add -D lint-staged simple-git-hooks

View what rules are enabled

Go to your project root that contains eslint.config.* and run:

npx @eslint/config-inspector

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published