Skip to content

Latest commit

 

History

History
51 lines (33 loc) · 1.13 KB

lint-staged.md

File metadata and controls

51 lines (33 loc) · 1.13 KB

Lint-staged configuration

The purpose of the lint-staged is to lint and to format indexed files before they got committed.

Contents

Prerequisites

  • ➡ eslint - linting javascript and typescript languages.
  • ➡ prettier - formatting js, ts, tsx, md, json, yaml files.
  • ➡ remark - linting and formatting markdown files.

Setup

  • Add workspace reference to lint-staged:

    pnpm add -w lint-staged
  • Add lint-staged configuration file:

    // .lintstagedrc.mjs
    
    export default {
      '*.md': ['pnpm remark:fix', 'pnpm format:fix'],
      '*.{mjs,js,ts,tsx,json,yaml}': 'pnpm format:fix',
      '*.{mjs,js,ts,tsx}': 'pnpm lint:fix'
    };

Usage

  • Automatic linting and formatting of staged files on commit.
    In case of any failures, commit will be rejected.

License

MIT © Sergey Muravjev


⬅ Back