{"id":19763,"library":"eslint-plugin-format","title":"ESLint Plugin Format","description":"An ESLint plugin that integrates multiple formatters (Prettier, dprint, oxfmt) for formatting various languages directly through ESLint rules. Current stable version is 2.0.1, released with support for ESLint v8 through v10, TypeScript types included. Key differentiators: side-effects-free, flat config native, supports multiple formatters in one plugin, and does not require language detection or external config files. Each file type must be explicitly configured with a formatter and options, giving full control but requiring manual setup.","status":"active","version":"2.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/antfu/eslint-plugin-format","tags":["javascript","eslint","eslint-plugin","formatters","prettier","dprint","oxfmt","typescript"],"install":[{"cmd":"npm install eslint-plugin-format","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-format","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-format","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required to function as an ESLint plugin","package":"eslint","optional":false}],"imports":[{"note":"The default export is an object with `parserPlain` and rule definitions. Named export `format` is not available; use default import.","wrong":"import { format } from 'eslint-plugin-format'","symbol":"format (default)","correct":"import format from 'eslint-plugin-format'"},{"note":"parserPlain is a property of the default export, not a named export. Access via the default import object.","wrong":"import { parserPlain } from 'eslint-plugin-format'","symbol":"parserPlain","correct":"import format from 'eslint-plugin-format'; const { parserPlain } = format"},{"note":"v2.0.0 dropped CJS support; only ESM is supported. For CJS projects, pin to v1.x or use dynamic import.","wrong":"const { format } = require('eslint-plugin-format')","symbol":"CommonJS require","correct":"const format = require('eslint-plugin-format')"}],"quickstart":{"code":"// eslint.config.js\nimport format from 'eslint-plugin-format'\n\nexport default [\n  {\n    files: ['**/*.css'],\n    languageOptions: {\n      parser: format.parserPlain,\n    },\n    plugins: {\n      format,\n    },\n    rules: {\n      'format/prettier': ['error', { parser: 'css' }],\n    },\n  },\n  {\n    files: ['**/*.toml'],\n    languageOptions: {\n      parser: format.parserPlain,\n    },\n    plugins: {\n      format,\n    },\n    rules: {\n      'format/dprint': ['error', { language: 'toml' }],\n    },\n  },\n]","lang":"typescript","description":"Configures ESLint flat config to format CSS files with Prettier and TOML files with dprint. Each formatter rule must be applied per file type with explicit parser and options."},"warnings":[{"fix":"Use ESM imports. If CJS is required, pin to v1.x (e.g., 'eslint-plugin-format': '^1.5.0')","message":"CJS support dropped in v2.0.0","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Add a rule with matching `files` pattern for each file type you want to format. The plugin does not apply to all files automatically.","message":"No default configs: formatters only apply to files explicitly configured with a rule","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always specify a parser in format/prettier options. The rule will not infer from file extension.","message":"Prettier parser option may be deprecated in future versions; prefer explicit parser per file type","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Ensure dprint plugin WASM files are installed or use a URL. Example: plugin: 'node_modules/dprint-plugin-malva/plugin.wasm'","message":"dprint requires WASM plugins; local paths may fail if binary not found","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to >=2.0.1 to ignore unsupported file type errors gracefully.","message":"oxfmt rule changed behavior for unsupported file types in v2.0.1","severity":"breaking","affected_versions":"<2.0.1"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install eslint-plugin-format --save-dev'. For CJS, pin to v1.x or use dynamic import().","cause":"Missing dependency or using incorrect import path in CJS context","error":"Cannot find module 'eslint-plugin-format'"},{"fix":"Add parser option: 'format/prettier': ['error', { parser: 'css' }]","cause":"Prettier parser not specified in rule options","error":"Error: The 'format/prettier' rule expects a `parser` option"},{"fix":"Verify the path: plugin: 'node_modules/dprint-plugin-<name>/plugin.wasm' or use an absolute path.","cause":"Path to dprint WASM plugin is incorrect or plugin not installed","error":"Error: dprint plugin not found"},{"fix":"Use `import format from 'eslint-plugin-format'`","cause":"Using destructured import `{ format }` instead of default import","error":"TypeError: format is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}