@ntnyq/eslint-config
v2.0.0-beta.5eslint-config
Flat ESLint config for JavaScript, TypeScript, Vue 2, Vue 3, Prettier.
Features
- 🚦 Designed to work alongside with Prettier
Install
pnpm add eslint prettier typescript @ntnyq/eslint-config @ntnyq/prettier-config -D
Usage
Highly recommended using eslint.config.mjs
as the config file :
import { defineESLintConfig } from '@ntnyq/eslint-config'
export default defineESLintConfig()
Add scripts lint
in package.json
:
{
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix"
}
}
VSCode Config
{
"eslint.enable": true,
"prettier.enable": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"eslint.validate": [
"vue",
"html",
"yaml",
"toml",
"json",
"jsonc",
"json5",
"markdown",
"javascript",
"typescript",
"javascriptreact",
"typescriptreact"
]
}
Lint changed files only
1. Add dependencies
pnpm add husky nano-staged -D
2. Config package.json
{
"scripts": {
"prepare": "husky"
},
"nano-staged": {
"*.{js,ts,cjs,mjs,vue,md,yml,yaml,json,html}": "eslint --fix"
}
}
3. Add a hook
echo "nano-staged" > .husky/pre-commit
Advanced config
Check for detail in:
Config interface
export interface ConfigOptions {
sortTsConfig?: boolean
sortI18nLocale?: boolean
sortPackageJson?: boolean
ignores?: ConfigIgnoresOptions
command?: boolean | ConfigCommandOptions
gitignore?: boolean | ConfigGitIgnoreOptions
imports?: ConfigImportsOptions
node?: ConfigNodeOptions
javascript?: ConfigJavaScriptOptions
typescript?: boolean | ConfigTypeScriptOptions
unicorn?: boolean | ConfigUnicornOptions
prettier?: boolean | ConfigPrettierOptions
perfectionist?: boolean | ConfigPerfectionistOptions
/**
* @internal
*/
unusedImports?: boolean | ConfigUnusedImportsOptions
/**
* @internal
*/
antfu?: boolean | ConfigAntfuOptions
comments?: boolean | ConfigCommentsOptions
jsdoc?: boolean | ConfigJsdocOptions
unocss?: boolean | ConfigUnoCSSOptions
regexp?: boolean | ConfigRegexpOptions
jsonc?: boolean | ConfigJsoncOptions
yml?: boolean | ConfigYmlOptions
markdown?: boolean | ConfigMarkdownOptions
toml?: boolean | ConfigTomlOptions
vue?: boolean | ConfigVueOptions
test?: boolean | ConfigTestOptions
}
Credits
License
npm i @ntnyq/[email protected]
Metadata
- MIT
- >=16.14.0
- ntnyq
- released 4/11/2023