Stylistic & Formatters
@eienjs/eslint-config handles code formatting directly inside ESLint so you do not need a separate Prettier setup for JavaScript, TypeScript, Vue, JSON, YAML, or TOML.
Stylistic Rules
By default, stylistic: true is enabled using @stylistic/eslint-plugin with EienJS defaults:
- Indentation:
2spaces - Quotes:
'single' - Semicolons: Always (
semi: true) - Brace Style:
'1tbs'(allowing single-line blocks) - Max Line Length:
160characters (warning, ignoring comments) - Arrow Parens: Always (
(x) => x) - Blank Lines: Enforces a blank line before
return,interface, andtypestatements.
Customizing Stylistic Options
Pass a StylisticConfig object to customize formatting behavior:
import { eienjs } from '@eienjs/eslint-config';
export default eienjs({
stylistic: {
braceStyle: '1tbs',
experimental: false,
indent: 2,
maxLineLength: 120,
quotes: 'single',
overrides: {
'@stylistic/padding-line-between-statements': 'off',
},
},
});
To disable all stylistic formatting rules and use an external tool instead, set stylistic: false:
import { eienjs } from '@eienjs/eslint-config';
export default eienjs({
stylistic: false,
});
External Formatters (formatters)
For file formats that ESLint does not natively format (such as .css, .scss, .less, .html, .md, .xml, .svg, and .astro), you can enable formatters powered by eslint-plugin-format (which runs Prettier under the hood as an ESLint rule).
Peer Dependencies
Install eslint-plugin-format and any optional Prettier plugins you need:
pnpm add -D eslint-plugin-format
# Optional: for XML and SVG formatting
pnpm add -D @prettier/plugin-xml
# Optional: for Astro formatting
pnpm add -D prettier-plugin-astro
Enabling All Formatters
Setting formatters: true enables CSS/SCSS/Less, HTML, and Markdown formatting by default, and automatically enables Astro (prettier-plugin-astro) and XML/SVG (@prettier/plugin-xml) if their respective plugins are installed:
import { eienjs } from '@eienjs/eslint-config';
export default eienjs({
formatters: true,
});
Granular Formatter Configuration
You can also pass an OptionsFormatters object to control each file type and customize Prettier options:
import { eienjs } from '@eienjs/eslint-config';
export default eienjs({
formatters: {
astro: false,
css: true,
html: true,
markdown: true,
svg: true,
xml: true,
prettierOptions: {
printWidth: 120,
trailingComma: 'all',
},
},
});
indent and quotes from your stylistic configuration unless overridden in prettierOptions.JSON, YAML, TOML & Markdown
Even without formatters: true, @eienjs/eslint-config lints and formats structured data and documentation files:
- JSON / JSONC / JSON5 (
jsonc: true): Lints JSON files and automatically sorts keys inpackage.json(eienjs/sort/package-json) andtsconfig.json(eienjs/sort/tsconfig-json). - YAML (
yaml: true): Lints and formats.ymland.yamlfiles viaeslint-plugin-yml. - TOML (
toml: true): Lints and formats.tomlfiles viaeslint-plugin-toml. - Markdown (
markdown: true): Lints Markdown files (@eslint/markdownwith GitHub Flavored Markdown) and extracts fenced code blocks (js,ts,vue, etc.) to lint example snippets with relaxed rules.
