Skip to content

Commit 99fb79c

Browse files
chore: Create optional eslint pre-commit hook (#1472)
Co-authored-by: April Sylph <28949509+AprilSylph@users.noreply.github.com>
1 parent 3356f32 commit 99fb79c

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

.git-hooks/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm run posttest -- --max-warnings=0

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.DS_Store
2+
.eslintcache
23
.vscode/
34
.web-extension-id
45
**.less

docs/Chapter 2 - Getting started.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
- **`npm test --ignore-scripts`**: Runs only the addon linter. Only reports syntax and WebExtension API errors.
1414
- **`npm run autofix`**: Automatically fixes any style errors.
1515
- **`npm run build`**: Creates an unsigned ZIP of the addon.
16+
- **`npm run enable-hooks`**: Enables a git hook that lints staged files locally before they are committed.
17+
- **`npm run disable-hooks`**: Disables git hooks.
1618

1719
### Web-only development
1820

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
"type": "module",
55
"scripts": {
66
"test": "web-ext lint",
7-
"posttest": "eslint src/",
7+
"posttest": "eslint src/ --cache",
88
"autofix": "eslint src/ --fix",
99
"start": "web-ext run",
10-
"build": "web-ext build"
10+
"build": "web-ext build",
11+
"enable-hooks": "git config core.hooksPath .git-hooks",
12+
"disable-hooks": "git config --unset core.hooksPath"
1113
},
1214
"devDependencies": {
1315
"chrome-webstore-upload-cli": "^3.5.0",

0 commit comments

Comments
 (0)