Usage & Features

Stylistic & Formatters

Format code using ESLint Stylistic rules and optional Prettier formatters for CSS, HTML, Markdown, XML, SVG, and Astro.

@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: 2 spaces
  • Quotes: 'single'
  • Semicolons: Always (semi: true)
  • Brace Style: '1tbs' (allowing single-line blocks)
  • Max Line Length: 160 characters (warning, ignoring comments)
  • Arrow Parens: Always ((x) => x)
  • Blank Lines: Enforces a blank line before return, interface, and type statements.

Customizing Stylistic Options

Pass a StylisticConfig object to customize formatting behavior:

eslint.config.js
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:

eslint.config.js
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:

eslint.config.js
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:

eslint.config.js
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',
    },
  },
});
Formatter settings automatically inherit 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 in package.json (eienjs/sort/package-json) and tsconfig.json (eienjs/sort/tsconfig-json).
  • YAML (yaml: true): Lints and formats .yml and .yaml files via eslint-plugin-yml.
  • TOML (toml: true): Lints and formats .toml files via eslint-plugin-toml.
  • Markdown (markdown: true): Lints Markdown files (@eslint/markdown with GitHub Flavored Markdown) and extracts fenced code blocks (js, ts, vue, etc.) to lint example snippets with relaxed rules.