npm.io
3.2.3 • Published 2 months ago

eslint-plugin-antfu

Licence
MIT
Version
3.2.3
Deps
0
Size
35 kB
Vulns
0
Weekly
0
Stars
175

eslint-plugin-antfu

npm version npm downloads

Anthony's opinionated ESLint rules, used as the foundation of @antfu/eslint-config.

Install

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.

Usage

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',
    },
  },
]

Rules

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

Sponsors

Sponsors

License

MIT License 2023-PRESENT Anthony Fu

Keywords