eslint-plugin-prettier-doc

raw JSON →
1.1.0 verified Sat Apr 25 auth: no javascript

ESLint plugin providing rules to enforce best practices when using Prettier's document builder API (prettier/doc). Current stable version is 1.1.0. Released under the MIT license by fisker. Active development with minor patch updates. Key differentiator: specifically targets Prettier Doc code patterns (e.g., deprecated concat, nested concat, empty ifBreak flatContents) to prevent common mistakes and deprecated usage.

error Plugin 'prettier-doc' not found
cause Plugin folder missing in node_modules; often due to missing install or incorrect name.
fix
Run npm install eslint-plugin-prettier-doc --save-dev and ensure it's in dependencies.
error Configuration for rule 'prettier-doc/no-concat' is invalid
cause Severity set to a number instead of 'off'/'warn'/'error'.
fix
Use string severity: 'prettier-doc/no-concat': 'error'.
error Referenced rule 'prettier-doc/no-empty-flat-contents-for-if-break' is not defined
cause Typo in rule name (e.g., missing hyphen) or using an old version before the rule was added.
fix
Check correct rule name: 'no-empty-flat-contents-for-if-break' (with hyphens). Update plugin to >=1.0.0.
error Cannot read property 'defineRules' of null
cause ESLint version mismatch; plugin expects specific ESLint API.
fix
Ensure ESLint version is compatible (ESLint 8+ recommended).
deprecated Use of `concat(…)` is deprecated in Prettier Doc; prefer array literals.
fix Replace concat(['a','b']) with ['a','b'].
breaking v1.0.0 changed rule names from 'prettier-doc/<old-name>' to 'prettier-doc/<new-name>'. Check migration if upgrading from 0.x.
fix Update rule names in ESLint config: e.g., 'no-concat' remains same; check all rules.
gotcha Disable `no-concat` before fixing `no-nested-concat` and `no-single-doc-concat` because the latter two rely on detecting concat calls.
fix Temporarily disable `no-concat` rule when auto-fixing other rules, then re-enable.
gotcha The `no-empty-flat-contents-for-if-break` rule fires on `ifBreak(',', '')` but not on `ifBreak(',')`.
fix Remove second argument if it's an empty string.
npm install eslint-plugin-prettier-doc
yarn add eslint-plugin-prettier-doc
pnpm add eslint-plugin-prettier-doc

Shows installation, basic ESLint configuration with recommended preset, and a code example that violates the no-concat rule.

// install: npm install eslint-plugin-prettier-doc --save-dev

// .eslintrc.json
{
  "plugins": ["prettier-doc"],
  "extends": ["plugin:prettier-doc/recommended"],
  "rules": {
    "prettier-doc/no-concat": "error",
    "prettier-doc/no-nested-concat": "error",
    "prettier-doc/no-single-doc-concat": "error",
    "prettier-doc/no-empty-flat-contents-for-if-break": "error"
  }
}

// example.js (will trigger no-concat)
const doc = concat(['hello', line, 'world']);