Anthony’s opinionated ESLint rules, used as the foundation of @antfu/eslint-config.
pnpm add -D eslint-plugin-antfu
Most users should consume these rules via
@antfu/eslint-config, which wires them up with sensible defaults alongside the rest of Anthony’s ESLint setup. Install this plugin directly only when you want to pick and choose individual rules.
Register the plugin in your flat config and enable the rules you want:
// eslint.config.js
import antfu from 'eslint-plugin-antfu'
export default [
{
plugins: {
antfu,
},
rules: {
'antfu/consistent-list-newline': 'error',
'antfu/if-newline': 'error',
'antfu/top-level-function': 'error',
},
},
]
| Rule | Description | ||
|---|---|---|---|
consistent-chaining |
Enforce consistent line breaks for chaining member access | 🔧 | ⚙️ |
consistent-list-newline |
Enforce consistent line breaks inside braces and parentheses | 🔧 | ⚙️ |
curly |
Opinionated curly bracket enforcement that allows both styles on one-liners | 🔧 | |
if-newline |
Enforce a newline between if and its consequent |
🔧 | |
import-dedupe |
Auto-fix duplicate named imports from the same source | 🔧 | |
indent-unindent |
Enforce consistent indentation inside unindent tagged template strings |
🔧 | ⚙️ |
no-import-dist |
Prevent importing from a local dist folder |
||
no-import-node-modules-by-path |
Prevent importing from node_modules by relative or absolute path |
||
no-top-level-await |
Prevent top-level await |
||
no-ts-export-equal |
Prevent TypeScript’s export = syntax in .ts/.tsx/.mts/.cts files |
||
top-level-function |
Enforce top-level functions to be declared with the function keyword |
🔧 |
MIT License © 2023-PRESENT Anthony Fu