eslint-plugin-antfu
raw JSON → 3.2.2 verified Sat Apr 25 auth: no javascript
Anthony Fu's opinionated ESLint plugin providing rules like consistent-chaining, consistent-list-newline, top-level-function, and no-top-level-await. Current stable version is 3.2.2, released under MIT license. v3.0.0 dropped CJS support (ESM-only). Designed for use with antfu/eslint-config. Active development with frequent releases. Ships TypeScript types. Peer dependency on eslint.
Common errors
error Error [ERR_REQUIRE_ESM]: require() of ES Module ↓
cause Using CommonJS require() on an ESM-only package (v3+).
fix
Switch to ESM imports or downgrade to v2.x.
error TypeError: antfu.configs is not iterable ↓
cause Incorrectly using antfu.configs.recommended inside an array without spreading or without flat config.
fix
Ensure your ESLint config uses flat config format: export default [antfu.configs.recommended].
error Rule 'antfu/consistent-chaining' has unknown option 'allowFirstPropertyAccess'. ↓
cause Using deprecated option name from pre-2.6.0.
fix
Replace 'allowFirstPropertyAccess' with 'allowLeadingPropertyAccess'.
Warnings
breaking v3.0.0 drops CJS support; require() will fail. ↓
fix Use ESM imports: import antfu from 'eslint-plugin-antfu'.
gotcha Rule 'consistent-chaining' option 'allowLeadingPropertyAccess' was renamed from 'allowFirstPropertyAccess' in v2.6.0. ↓
fix Use 'allowLeadingPropertyAccess' instead of deprecated 'allowFirstPropertyAccess'.
gotcha The plugin is opinionated and intended for use with antfu/eslint-config; mixing with other configs may cause conflicts. ↓
fix Use antfu/eslint-config as base or carefully merge configs.
Install
npm install eslint-plugin-antfu yarn add eslint-plugin-antfu pnpm add eslint-plugin-antfu Imports
- plugin wrong
const antfu = require('eslint-plugin-antfu');correctimport antfu from 'eslint-plugin-antfu'; export default [antfu.configs.recommended]; - rules
import { rules } from 'eslint-plugin-antfu'; - configs wrong
const { configs } = require('eslint-plugin-antfu');correctimport { configs } from 'eslint-plugin-antfu';
Quickstart
// eslint.config.js
import antfu from 'eslint-plugin-antfu';
export default [
antfu.configs.recommended,
{
rules: {
'antfu/consistent-chaining': ['warn', { allowLeadingPropertyAccess: false }],
'antfu/consistent-list-newline': ['error', { multiline: 'always' }],
'antfu/top-level-function': ['error'],
'antfu/no-top-level-await': ['error'],
},
},
];