forked from rinafcode/teachLink_backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlint-staged.config.js
More file actions
39 lines (33 loc) · 1.87 KB
/
Copy pathlint-staged.config.js
File metadata and controls
39 lines (33 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict';
/**
* lint-staged configuration for TeachLink Backend
*
* Runs on every `git commit`. Only staged files are processed —
* the full codebase is never re-linted, keeping the pre-commit
* hook fast even in a large repo.
*
* Order of operations per staged TypeScript file:
* 1. Prettier — rewrites formatting in-place and re-stages the file.
* 2. ESLint — checks for rule violations; --fix applies safe auto-fixes.
* If unfixable errors remain, the commit is blocked.
*
* JSON / Markdown / YAML files get Prettier only — no linting needed.
*/
module.exports = {
// ── TypeScript source and test files ───────────────────────────────────────
'{src,test,apps,libs}/**/*.ts': [
// 1. Format first so ESLint sees already-formatted code.
// `--write` rewrites the file; lint-staged re-stages it automatically.
'prettier --write',
// 2. Lint with auto-fix for fixable violations.
// `--max-warnings 0` makes any warning fail the commit.
// Pass filenames explicitly so ESLint only checks staged files.
'eslint --fix --max-warnings 0',
],
// ── JSON files ─────────────────────────────────────────────────────────────
'*.json': ['prettier --write'],
// ── Markdown ───────────────────────────────────────────────────────────────
'*.md': ['prettier --write'],
// ── YAML (GitHub Actions, configs) ─────────────────────────────────────────
'*.{yml,yaml}': ['prettier --write'],
};