-
Notifications
You must be signed in to change notification settings - Fork 17
/
lint-staged.config.cjs
24 lines (24 loc) · 1.29 KB
/
lint-staged.config.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module.exports = {
// Run ESLint and Prettier on typescript, javascript, and json
// files. lint-staged automatically adds any updated files
// to git, so it's safe to use `--fix` and `--write` flags,
// which change source files.
"*.{tsx,ts,js,cjs,json}": ["eslint --cache --fix", "prettier --write"],
// If typescript files or json files (Typescript statically types .json
// files, and package.json and tsconfig.json files can change type
// correctness) change, we run tsc on the whole project. We use
// incremental: true in our tsconfig, so this isn't very expensive if
// only a few files have changed.
//
// Note that we use the function configuration option here, instead of
// just a string or array of strings. lint-staged calls this function
// with an array of filenames and expects us to produce an entire command
// (including filename arguments). Since we just want to run check:types
// on the whole project, not some specific files, we ignore this file list.
"*.{tsx,ts,json}": () => "yarn check:types",
// Keep the table of contents up to date in the README file
"README.md": () => "yarn fix:toc",
// For markdown, HTML, and YAML files, we just run Prettier. ESLint doesn't have
// anything to say about these.
"*.{md,yml,html}": "prettier --write",
};