Formatters
JavaScript, TypeScript, Vue, JSON, YAML, TOML and Markdown code blocks are formatted by ESLint Stylistic and language plugins. Use formatters for file types those plugins don't cover.
eslint-plugin-format is already a dependency of @vinicunca/eslint-config. Extra Prettier plugins are optional peers.
Enable formatters
Pass true to turn on CSS, HTML, GraphQL and Markdown (Prettier). XML, SVG, Astro and Slidev turn on only when their plugins are already installed:
import { vinicuncaESLint } from '@vinicunca/eslint-config';
export default vinicuncaESLint({
formatters: true,
});
Or pick languages:
export default vinicuncaESLint({
formatters: {
css: true,
html: true,
markdown: 'dprint',
xml: true,
graphql: true,
},
});
format/* for CSS, HTML, XML, Markdown, GraphQL and Astro.Options
*.css, *.pcss, *.postcss, *.scss and *.less. With Vue sfcBlocks on (the default), <style> blocks are formatted too.*.html and *.htm.*.xml. Requires @prettier/plugin-xml.*.svg. Requires @prettier/plugin-xml.*.md. true means Prettier. Use this for Markdown prose; the Markdown integration still lints fenced code.*.graphql and *.gql.*.astro with Prettier. Requires prettier-plugin-astro. Also turns off conflicting style/* rules on those files.**/slides.md by default) with prettier-plugin-slidev. Only works when markdown is Prettier (true or 'prettier').boolean, so TypeScript users need a cast.Prettier defaults
When you don't pass prettierOptions, formatters inherit:
| Option | Source |
|---|---|
semi | stylistic.semi (true) |
singleQuote | stylistic.quotes === 'single' |
tabWidth / useTabs | stylistic.indent (2) |
trailingComma | 'all' |
printWidth | 120 |
endOfLine | 'auto' |
XML/SVG also set xmlQuoteAttributes: 'double', xmlSelfClosingSpace: true, xmlWhitespaceSensitivity: 'ignore'.
Editor
Add the extra languages to eslint.validate in .vscode/settings.json (CSS, HTML, XML, GraphQL, Astro, Markdown) so format-on-save works. The getting started snippet already lists them.
Keep "prettier.enable": false so the Prettier extension doesn't format the same files twice.