Skip to content

Commit 6ac1b5f

Browse files
authored
chore(lint): migrate to lefthook from lint-staged + husky (#13259)
* chore(deps-dev): remove {lint-staged,husky} * chore(deps-dev): add lefthook * style(lefthook): add hooks * chore(git): ignore .{eslint,stylelint}cache
1 parent a6b7137 commit 6ac1b5f

File tree

7 files changed

+133
-190
lines changed

7 files changed

+133
-190
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,6 @@ client/src/.linaria_cache
101101
ssr/.linaria-cache/
102102

103103
client/venv
104+
105+
.eslintcache
106+
.stylelintcache

.husky/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.husky/pre-commit

Lines changed: 0 additions & 1 deletion
This file was deleted.

.lefthook.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
pre-commit:
2+
parallel: true
3+
jobs:
4+
- name: prettier
5+
run: npx prettier --write --cache --ignore-unknown {staged_files}
6+
stage_fixed: true
7+
8+
- name: eslint
9+
run: npx eslint --fix --cache {staged_files}
10+
glob:
11+
- "*.js"
12+
- "*.jsx"
13+
- "*.ts"
14+
- "*.tsx"
15+
stage_fixed: true
16+
17+
- name: eslint (global)
18+
run: npx eslint --fix --cache .
19+
glob: .eslintrc.cjs
20+
stage_fixed: true
21+
22+
- name: stylelint
23+
run: npx stylelint --fix --cache {staged_files}
24+
glob: "*.scss"
25+
stage_fixed: true
26+
27+
- name: stylelint (global)
28+
run: npx stylelint --fix '**/*.scss' --cache --ignore-path .gitignore
29+
glob: .stylelintrc.json
30+
stage_fixed: true
31+
32+
pre-push:
33+
piped: true
34+
jobs:
35+
- run: yarn install
36+
37+
- name: lint
38+
group:
39+
parrallel: true
40+
jobs:
41+
- name: eslint
42+
run: npx eslint --cache
43+
- name: stylelint
44+
run: npx stylelint '**/*.scss' --cache --ignore-path .gitignore
45+
- name: tsc
46+
run: yarn check:tsc
47+
48+
post-merge:
49+
only:
50+
- ref: main
51+
commands:
52+
yarn-install:
53+
run: yarn install --ignore-scripts
54+
rari-postinstall:
55+
run: npm run postinstall --prefix node_modules/@mdn/rari
56+
57+
output:
58+
- summary
59+
- failure

lint-staged.config.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"jest": "node --experimental-vm-modules --expose-gc ./node_modules/.bin/jest --logHeapUsage",
4343
"m2h": "cross-env NODE_OPTIONS=\"--no-warnings=ExperimentalWarning --loader ts-node/esm\" node markdown/m2h/cli.ts",
4444
"prepack": "yarn render:html && yarn build:dist",
45-
"prepare": "(husky || true) && yarn install:all && yarn install:all:npm",
45+
"prepare": "yarn install:all && yarn install:all:npm",
4646
"prettier-check": "prettier --check .",
4747
"prettier-format": "prettier --write .",
4848
"render:html": "cross-env NODE_ENV=production NODE_OPTIONS=\"--no-warnings=ExperimentalWarning --loader ts-node/esm\" node build/ssr-cli.ts",
@@ -228,15 +228,14 @@
228228
"history": "^5.2.0",
229229
"html-validate": "^8.28.0",
230230
"html-webpack-plugin": "^5.6.3",
231-
"husky": "^9.1.7",
232231
"ignore-loader": "^0.1.2",
233232
"jest": "^29.7.0",
234233
"jest-environment-jsdom": "^30.0.2",
235234
"jest-junit-reporter": "^1.1.0",
236235
"jest-resolve": "^30.0.2",
237236
"jest-watch-typeahead": "^2.2.2",
238237
"jsdom": "^26.1.0",
239-
"lint-staged": "^16.1.2",
238+
"lefthook": "^1.11.15",
240239
"mdast-util-to-hast": "^13.2.0",
241240
"mini-css-extract-plugin": "^2.9.2",
242241
"node-dev": "^8.0.0",

0 commit comments

Comments
 (0)