1.2.4 • Published 8 months ago
@ilyasemenov/lint-config v1.2.4
@ilyasemenov/lint-config
A set of reusable linter configs that I use in the projects that I develop or supervise:
- for
eslint
, extends @antfu/eslint-config. - for
stylelint
Install
pnpm add -D @ilyasemenov/lint-config eslint stylelint
Setup eslint
Create eslint.config.js
:
import { defineEslintConfig } from "@ilyasemenov/lint-config"
export default defineEslintConfig()
Available options:
export default defineEslintConfig({
// Lint Vue. Unlike antfu, must be enabled explicitly.
vue: true,
// Lint pug in Vue templates.
vuePug: true,
// ...and all @antfu/eslint-config options.
})
Setup stylelint
Create stylelint.config.js
:
import { defineStylelintConfig } from "@ilyasemenov/lint-config"
export default defineStylelintConfig()
Available options:
export default defineStylelintConfig({
// Use tabs for indentation.
tabs: true,
// Use single quotes.
quotes: "single",
// ...and all stylelint options.
})
Add command line script
Add to package.json
:
{
"scripts": {
"lint": "eslint --fix . && stylelint --fix '**/*.{css,scss,vue}'"
}
}
and run:
pnpm lint
Setup lint-staged
Create lint-staged.config.js
:
export default {
"*.{cjs,js,ts,json,md,yaml,toml}": "eslint --fix",
"*.{css,scss}": "stylelint --fix",
"*.vue": ["eslint --fix", "stylelint --fix"],
}