commit-sheriff 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,14 +2,17 @@
2
2
 
3
3
  Shared [Husky](https://typicode.github.io/husky/) git hooks for any project — enforces a consistent **branch naming format** and **commit message format** (ticket + type, optionally module), and runs **lint-staged** / type-check / related tests before every commit.
4
4
 
5
- One command installs the same hooks in any repo:
5
+ ## Quick start
6
6
 
7
7
  ```bash
8
+ npm i commit-sheriff
8
9
  npx commit-sheriff init
10
+ npx commit-sheriff add-eslint-react # optional — TypeScript/React + module-boundary ESLint config
9
11
  ```
10
12
 
11
13
  ## Table of contents
12
14
 
15
+ - [Quick start](#quick-start)
13
16
  - [Why](#why)
14
17
  - [Requirements](#requirements)
15
18
  - [Install](#install)
@@ -74,6 +77,7 @@ Run this once per repo, from the repo root (where `package.json` lives). This wo
74
77
  3. Adds a default `commitGuard` block to `package.json` **only if one doesn't already exist** — re-running `init` never overwrites your customized config.
75
78
  4. Adds a default `lint-staged` block to `package.json` **only if one doesn't already exist**.
76
79
  5. Adds a `"prepare": "husky"` npm script if missing, so hooks are (re)installed automatically after `npm install`.
80
+ 6. If `react` and `typescript` are both present in your `dependencies`/`devDependencies`, also runs [`add-eslint-react`](#advanced-eslint-module-boundary-template-typescriptreact) automatically. Otherwise it's skipped and you can add it manually later.
77
81
 
78
82
  Re-running `npx commit-sheriff init` later (e.g. after updating the package) is safe: it refreshes the two hook scripts to the latest version but leaves your `commitGuard` / `lint-staged` config alone.
79
83
 
@@ -101,11 +101,29 @@ function mergeConfig() {
101
101
  }
102
102
  }
103
103
 
104
+ function isReactTypescriptProject() {
105
+ const { pkg } = readPackageJson();
106
+ const deps = Object.assign({}, pkg.dependencies, pkg.devDependencies);
107
+ return Boolean(deps.react && deps.typescript);
108
+ }
109
+
104
110
  function init() {
105
111
  ensureHusky();
106
112
  copyHook("commit-msg");
107
113
  copyHook("pre-commit");
108
114
  mergeConfig();
115
+
116
+ if (isReactTypescriptProject()) {
117
+ console.log(
118
+ "\n• react + typescript aşkarlandı → TS/React modul-sərhəd ESLint şablonu da əlavə olunur:",
119
+ );
120
+ addEslintReact();
121
+ } else {
122
+ console.log(
123
+ "\n(Layihə TS/React kimi aşkarlanmadı — istəsəniz `npx commit-sheriff add-eslint-react` ilə əlavə edə bilərsiniz.)",
124
+ );
125
+ }
126
+
109
127
  console.log(
110
128
  "\nHazırdır. package.json → commitGuard bölməsində 'project' və lazım olsa 'modules' dəyərlərini tənzimləyin.\n",
111
129
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commit-sheriff",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Shared husky commit-msg / pre-commit hooks enforcing ticket-based commit messages and branch naming",
5
5
  "main": "index.js",
6
6
  "bin": {