@tofrankie/eslint
v0.0.21
Published
Shared ESLint configuration
Maintainers
Readme
@tofrankie/eslint
Shared ESLint configuration built on @antfu/eslint-config.
[!IMPORTANT] Before 1.0.0, releases may include breaking changes. Read the CHANGELOG before upgrading.
Requirements
- Node.js >= 20
- ESLint >= 9.10.0
- Flat config only
Quick Start
Install dependencies:
$ pnpm add eslint @tofrankie/eslint -DESM (eslint.config.mjs):
import { defineConfig } from '@tofrankie/eslint'
export default defineConfig()CJS (eslint.config.cjs):
const { defineConfig } = require('@tofrankie/eslint')
module.exports = defineConfig()Configuration
defineConfig(antfuOptions?, ...flatConfigItems) mirrors @antfu/eslint-config usage: the first argument is antfu-style options (integrations, rules, etc.); rest arguments are extra flat config items appended after the generated stack.
import { defineConfig } from '@tofrankie/eslint'
export default defineConfig(
{
typescript: true,
react: true,
},
{
// additional flat config item
}
)- The first argument uses antfu-compatible options.
- User
rulesin the first argument follow antfu's fused-config semantics and stay ahead of any extra flat configs passed in the rest arguments.
@tofrankie/eslintalready ships the plugin dependencies behind antfu's renamed rule prefixes. In normal usage you do not need to install those ESLint plugins again in your project. Enable the corresponding antfu options as needed, such astypescript,vue,react,test, orformatters.
Integration overrides vs global rules
Prefer per-integration overrides when a rule belongs to a specific stack (correct file globs and plugin context). Use top-level rules only for truly global tweaks; that layer is not scoped to integration file patterns.
import { defineConfig } from '@tofrankie/eslint'
export default defineConfig({
vue: {
overrides: {
'vue/operator-linebreak': ['error', 'before'],
},
},
typescript: {
overrides: {
'ts/consistent-type-definitions': ['error', 'interface'],
},
},
})export default defineConfig({
rules: { 'no-console': 'off' },
})TypeScript
Activation follows antfu: when typescript is left unset, support turns on if a typescript package is present. Set typescript: false for JS-only repos that still install TypeScript for tooling.
Type-aware rules need typescript.tsconfigPath (stricter, slower, requires a valid tsconfig.json). With React enabled, React type-aware rules follow the same gate.
export default defineConfig({
typescript: { tsconfigPath: 'tsconfig.json' },
})Formatters
@antfu/eslint-config can wire formatters (CSS, HTML, Markdown, GraphQL, Astro, etc.). This preset disables those integrations by default so ESLint does not duplicate work when you already use Prettier (and optionally Stylelint). Defaults still include a formatters.prettierOptions base aligned with @tofrankie/prettier; it applies once you turn formatters on.
Behavior:
formatters: false— all formatter integrations offformatters: true— enables the same subset as antfu's boolean shortcut (css,html,markdown,graphql), merged with the built-inprettierOptionsbaseformatters: { ... }— deep-merged with the preset defaults (individual flags off until you set them)
export default defineConfig({
formatters: {
html: true,
markdown: true,
prettierOptions: { printWidth: 100 },
},
})Unused variables
With default options:
.js—unused-imports/no-unused-vars.ts—ts/no-unused-vars- Vue SFCs with TypeScript
<script>—ts/no-unused-vars
WeChat miniprogram
MINIPROGRAM_LANGUAGE_OPTIONS exposes common miniprogram globals for an extra flat item:
import { defineConfig, MINIPROGRAM_LANGUAGE_OPTIONS } from '@tofrankie/eslint'
export default defineConfig(
{ ignores: ['project.config.json', 'project.private.config.json'] },
{ languageOptions: MINIPROGRAM_LANGUAGE_OPTIONS }
)Acknowledgements
Thanks to these referenced packages:
