Skip to content

Advanced Usage

Config Composer, type-aware rules, command codemods, plugin renaming, and versioning policy.

Updated View as Markdown

Type Aware Rules

Some of the strongest TypeScript lint rules require type information — they need to resolve what a value actually is at runtime, not just what its local syntax looks like. Opt into type-aware linting by pointing at your tsconfig.json:

eslint.config.tsts
import pleaseai from '@pleaseai/eslint-config'

export default pleaseai({
  typescript: {
    tsconfigPath: 'tsconfig.json',
  },
})

Config Composer

pleaseai() returns a FlatConfigComposer, so you can fluently override, prepend, remove, or rename named config blocks when the plain options object isn’t granular enough:

eslint.config.tsts
import pleaseai from '@pleaseai/eslint-config'

export default pleaseai()
  .prepend(
    // flat configs before the main PleaseAI config
  )
  .override('antfu/stylistic/rules', {
    rules: {
      'style/generator-star-spacing': ['error', { after: true, before: false }],
    },
  })
  .renamePlugins({
    'old-prefix': 'new-prefix',
  })
  .remove('antfu/stylistic')

Reach for this API when:

  • You want to remove a named config block entirely
  • You need to rename a plugin prefix without writing a custom config
  • You want to override rules inside a specific named block (more surgical than the top-level overrides)

command Codemods

@pleaseai/eslint-config ships eslint-plugin-command — an on-demand micro-codemod system triggered by triple-slash comments. It’s not a typical lint rule; you explicitly opt in per-site.

Built-in triggers include:

  • /// to-function — arrow function → function declaration
  • /// to-arrow — function declaration → arrow function
  • /// to-for-each — for loop → .forEach()
  • /// to-for-of — .forEach() → for-of
  • /// keep-sorted — sort the next object/array/interface

See the plugin docs for the full catalogue.

Usage — place the trigger one line above the code:

before.tsts
/// to-function
const greet = async (name: string): Promise<void> => {
  console.log(`Hello, ${name}`)
}

After eslint --fix:

after.tsts
async function greet(name: string): Promise<void> {
  console.log(`Hello, ${name}`)
}

The trigger comment is one-off — it’s removed along with the transformation.

Anti-slop Rules

antislop turns on rules from eslint-plugin-slop and a curated subset of eslint-plugin-sonarjs through @antfu/eslint-config’s antislop option. Both plugins are optional peer dependencies:

bun add -D eslint-plugin-slop eslint-plugin-sonarjs

When you leave antislop unset, each plugin’s rules turn on if that plugin is installed. Upgrading without the plugins changes nothing, and please-style installs both for new projects.

antislop: true requires both plugins. An object requires each plugin it turns on explicitly (slop: true or slop: { ... }; a numeric cognitiveComplexity turns on sonarjs), and a plugin it does not mention follows what is installed. An object that ends up turning on neither plugin leaves antislop off. A missing required plugin throws: `antislop` requires `eslint-plugin-sonarjs`. Install with `bun add -D eslint-plugin-sonarjs`, or set `antislop: false`. Turn off one part with { sonarjs: false } or { slop: false }, or everything with false.

import pleaseai from '@pleaseai/eslint-config'

export default pleaseai({
  antislop: { cognitiveComplexity: 20 },
})
  • cognitiveComplexity sets the sonarjs/cognitive-complexity threshold (default 15). false disables it.
  • slop: { cwd, inspection } sets which changes the slop rules report: the whole file, uncommitted lines, or lines from recent commits. inspection is 'full' (default), 'uncommitted' or 'recent-changes'. Keep 'full' in CI: the other modes depend on git state (shallow clones, clean checkouts) and give different results locally and in CI.
  • slop/no-em-dash is a warning in Markdown files and an error elsewhere. It has no autofix.
  • On non-JS files (CSS, HTML, Vue, JSON, YAML, TOML, Markdown, and so on), the rule runs only where another config already parses them. Enabling antislop never makes ESLint lint new file types, so you get no parsing errors on CSS or HTML.

When this repository first turned antislop on, it reported 193 findings: 174 slop/no-em-dash (136 in Markdown), 8 sonarjs/cognitive-complexity, 7 slop/prefer-jsdoc (autofixable), 3 slop/max-comment-length and 1 slop/no-trivial-functions. They are fixed, and this repository now lints itself with antislop on. See issue #76 for the measurements.

Quality Rules

quality: true turns on 12 quality/* rules from anti-slop, vendored through @nkzw/oxlint-config. They flag low-evidence typing and code patterns: a known value widened to unknown and asserted back, chained type assertions, unknown returns and type aliases, unsafe dictionary value types, object parameters, adjacent filter/map passes, reducer accumulator copies, Reflect.get / Reflect.apply, and conditional empty-object spreads. The option is off by default and needs no extra packages.

import pleaseai from '@pleaseai/eslint-config'

export default pleaseai({
  quality: true,
  rules: {
    'quality/no-object-parameters': 'off',
  },
})
  • Every rule is an error on JS and TS files. Code blocks in Markdown are skipped.
  • no-object-parameters and no-unknown-returns are the most opinionated. Turn them off in rules if they do not fit your code.
  • quality/no-chained-type-assertions reports the same code as slop/no-chained-type-assertions from antislop. If both are on, turn one off.
  • None of the rules has an autofix.

When quality: true was first turned on, this repository reported 29 findings: 13 no-known-value-widening, 10 no-array-filter-map, 3 no-unsafe-dictionary-type, 2 no-conditional-empty-object-spread and 1 no-unknown-returns. A larger private monorepo (2,669 files) reports 4,396 findings in 1,172 files, 61% of them in tests. The most frequent are no-chained-type-assertions (1,282), no-unsafe-dictionary-type (1,240), no-known-value-widening (745) and no-conditional-empty-object-spread (658). That volume is why the option is off by default. The findings in this repository are fixed, and it now lints itself with quality: true. See issue #77.

Strict Rules

strict: true turns on rules adopted from cloudflare/oxlint-config that need no type information. The option is off by default.

import pleaseai from '@pleaseai/eslint-config'

export default pleaseai({
  strict: true,
  rules: {
    'unicorn/prefer-set-has': 'off',
  },
})
  • no-promise-executor-return reports a value returned from a Promise executor function.
  • eqeqeq is set to 'always' instead of antfu’s 'smart', so value == null is reported too.
  • unicorn/prefer-set-has reports an array that you only use for membership checks and could be a Set.
  • ts/no-confusing-non-null-assertion reports a non-null assertion that reads like part of an equality or assignment operator, such as a! == b. With canonicalPluginNames it is @typescript-eslint/no-confusing-non-null-assertion.
  • import/no-self-import reports a module that imports itself.
  • Every rule is an error on JS and TS files. Code blocks in Markdown are skipped.
  • A rule is skipped when its plugin is off: ts/* when typescript is false, unicorn/* when unicorn is false, and import/no-self-import when imports is false.
  • In the default mode, import/no-self-import comes from eslint-plugin-import-x. With canonicalPluginNames, the rule comes from eslint-plugin-import. In both modes, eslint-import-resolver-typescript resolves TypeScript sources. eslint-plugin-import-x and eslint-import-resolver-typescript are regular dependencies that the config loads only when strict is on, while canonicalPluginNames still needs the optional peer eslint-plugin-import installed (bun add -D eslint-plugin-import). In either mode the rule catches extensionless specifiers, .js specifiers that point at a .ts file, and tsconfig paths aliases. The resolver finds tsconfig.json from the directory where you run ESLint. If any of your configs sets a resolver the active import plugin reads (import-x/resolver-next, import-x/resolver, import-x/resolver-legacy or import-x/resolve by default; import/resolver with canonicalPluginNames), the strict resolver is dropped for every file and your resolver decides how imports resolve.
  • Turn a single rule off in rules, as in the example above. Your rules and your own configs win over strict.
  • eqeqeq has no autofix for == null. Rewrite it by hand as x === null || x === undefined, or as a single check when only one of the two can reach it.

When strict: true was first turned on, this repository reported 88 findings in 18 files: 86 eqeqeq (mostly == null and != null) and 2 unicorn/prefer-set-has. The other rules reported nothing, apart from one import/no-self-import on a test fixture that imports itself on purpose, which eslint.config.ts excludes from linting. The findings are fixed, and this repository now lints itself with strict: true. See issue #96.

Plugins Renaming

@pleaseai/eslint-config inherits @antfu/eslint-config’s plugin renaming for a shorter, consistent DX:

New prefix Original prefix Source plugin
import/* import-lite/* eslint-plugin-import-lite
node/* n/* eslint-plugin-n
yaml/* yml/* eslint-plugin-yml
ts/* @typescript-eslint/* @typescript-eslint/eslint-plugin
style/* @stylistic/* @stylistic/eslint-plugin
test/* vitest/* @vitest/eslint-plugin

So when you override a rule, use the new prefix:

eslint.config.tsts
import pleaseai from '@pleaseai/eslint-config'

export default pleaseai({
  rules: {
    'ts/consistent-type-definitions': ['error', 'interface'],
    'style/max-statements-per-line': ['error', { max: 2 }],
  },
})

View Enabled Rules

Use @eslint/config-inspector to visualise the fully-resolved config in a browser — every enabled rule, every plugin, every file glob:

Terminalbash
npx @eslint/config-inspector

It opens a local server showing the flat config graph. Indispensable when you’re debugging “why is this rule firing” or “which preset added this”.

Re-exports

Every export from @antfu/eslint-config is re-exported, so you can import fine-grained configs directly when you want to compose them by hand instead of using the pleaseai() factory:

eslint.config.tsts
import { combine, javascript, typescript, vue } from '@pleaseai/eslint-config'

export default combine(
  javascript(),
  typescript(),
  vue(),
)

Versioning Policy

@pleaseai/eslint-config follows Semantic Versioning, but because it’s an opinionated style preset with many moving parts, rule changes are not treated as breaking changes.

Breaking (major bump)

  • Node.js version requirement changes
  • Large refactors that may break downstream configs
  • Major plugin upgrades that may break existing rules
  • Changes that likely affect most codebases

Non-breaking (minor/patch)

  • Enabling or disabling individual rules (even if stricter)
  • Changing rule options
  • Dependency version bumps

If a rule tightening breaks your build, pin to the previous minor version and open an issue so we can discuss the trade-off.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close