The purpose of the lint-staged
is to lint and to format indexed files before they got committed.
- ➡ eslint - linting
javascript
andtypescript
languages. - ➡ prettier - formatting
js
,ts
,tsx
,md
,json
,yaml
files. - ➡ remark - linting and formatting
markdown
files.
-
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' };
- Automatic linting and formatting of staged files on commit.
In case of any failures, commit will be rejected.