ESLint config for JavaScript, TypeScript, Vue 2/3.
Based on Anthony Fu configs.
pnpm add -D @cany748/eslint-config
# Or yarn add -D / npm install -D / bun add -D
// 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,
}
For example:
{
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix"
}
}
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
Go to your project root that contains eslint.config.*
and run:
npx @eslint/config-inspector