Skip to content

Commit 0f5d749

Browse files
Roland Grozarolandjitsu
authored andcommitted
ci: add pre-commit hooks
1 parent c6f6af1 commit 0f5d749

2 files changed

Lines changed: 77 additions & 19 deletions

File tree

‎.pre-commit-config.yaml‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Git hooks, managed by prek (https://github.com/j178/prek).
2+
#
3+
# prek install wire up the git hooks (run once, or via `npm install`)
4+
# prek run --all-files run every hook over the whole repo
5+
#
6+
# Config reference: https://pre-commit.com/#pre-commit-configyaml---top-level
7+
8+
# `prek install` sets up both git hooks in one go.
9+
default_install_hook_types: [pre-commit, commit-msg]
10+
11+
repos:
12+
# Conventional Commits.
13+
# Validates the commit message; the default type set (feat, fix, chore, ci,
14+
# docs, style, refactor, perf, test, build, revert) matches this repo's history
15+
# and what semantic-release consumes.
16+
- repo: https://github.com/compilerla/conventional-pre-commit
17+
rev: v4.4.0
18+
hooks:
19+
- id: conventional-pre-commit
20+
stages: [commit-msg]
21+
22+
# Project toolchain on staged files. Reuses the oxfmt /
23+
# oxlint binaries already in node_modules (via npx), so there's no second
24+
# toolchain to install or keep in sync. `require_serial` gives each tool a
25+
# single invocation with all files — the tools parallelize internally, and it
26+
# avoids paying npx startup once per batch.
27+
- repo: local
28+
hooks:
29+
- id: oxfmt
30+
name: oxfmt
31+
entry: npx oxfmt
32+
language: system
33+
types_or: [ts, tsx, javascript, jsx, json]
34+
exclude: (^|/)package-lock\.json$ # never rewrite the generated lockfile
35+
stages: [pre-commit]
36+
require_serial: true
37+
- id: oxlint
38+
name: oxlint
39+
entry: npx oxlint --fix
40+
language: system
41+
types_or: [ts, tsx, javascript, jsx]
42+
stages: [pre-commit]
43+
require_serial: true

‎package.json‎

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,15 @@
22
"name": "attr-accept",
33
"version": "0.0.0-development",
44
"description": "JavaScript implementation of the \"accept\" attribute for HTML5 <input type=\"file\">",
5-
"type": "module",
6-
"main": "./dist/index.cjs",
7-
"module": "./dist/index.js",
8-
"types": "./dist/index.d.ts",
9-
"exports": {
10-
".": {
11-
"types": "./dist/index.d.ts",
12-
"import": "./dist/index.js",
13-
"require": "./dist/index.cjs"
14-
},
15-
"./package.json": "./package.json"
16-
},
17-
"sideEffects": false,
18-
"files": ["dist", "src", "!src/**/*.spec.*"],
19-
"keywords": ["html5", "input", "tag", "attribute", "attr", "accept", "file"],
5+
"keywords": [
6+
"accept",
7+
"attr",
8+
"attribute",
9+
"file",
10+
"html5",
11+
"input",
12+
"tag"
13+
],
2014
"homepage": "https://github.com/react-dropzone/attr-accept#readme",
2115
"bugs": {
2216
"url": "https://github.com/react-dropzone/attr-accept/issues"
@@ -31,10 +25,31 @@
3125
"type": "git",
3226
"url": "https://github.com/react-dropzone/attr-accept.git"
3327
},
28+
"files": [
29+
"dist",
30+
"src",
31+
"!src/**/*.spec.*"
32+
],
33+
"type": "module",
34+
"sideEffects": false,
35+
"main": "./dist/index.cjs",
36+
"module": "./dist/index.js",
37+
"types": "./dist/index.d.ts",
38+
"exports": {
39+
".": {
40+
"types": "./dist/index.d.ts",
41+
"import": "./dist/index.js",
42+
"require": "./dist/index.cjs"
43+
},
44+
"./package.json": "./package.json"
45+
},
3446
"publishConfig": {
3547
"access": "public"
3648
},
3749
"scripts": {
50+
"prepare": "prek install || exit 0",
51+
"hooks:install": "prek install",
52+
"hooks:run": "prek run --all-files",
3853
"prebuild": "npm run clean",
3954
"build": "tsdown",
4055
"dev": "tsdown --watch",
@@ -63,9 +78,6 @@
6378
"typescript": "^7.0.2",
6479
"vitest": "^4.1.10"
6580
},
66-
"engines": {
67-
"node": ">= 20"
68-
},
6981
"size-limit": [
7082
{
7183
"name": "esm",
@@ -77,5 +89,8 @@
7789
"path": "dist/index.cjs",
7890
"limit": "2 kB"
7991
}
80-
]
92+
],
93+
"engines": {
94+
"node": ">= 20"
95+
}
8196
}

0 commit comments

Comments
 (0)