commit-sheriff 1.3.1 → 1.4.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
@@ -77,9 +77,9 @@ Run this once per repo, from the repo root (where `package.json` lives). This wo
77
77
  3. Creates a default `.commitsheriffrc.json` file at the repo root **only if one doesn't already exist** (and only if there's no legacy `package.json` → `commitGuard` block either — see [Configuration](#configuration-commitsheriffrcjson)) — re-running `init` never overwrites your customized config.
78
78
  4. Adds a default `lint-staged` block to `package.json` **only if one doesn't already exist**.
79
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.
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, which **overwrites** `.eslintrc.js` and `.prettierrc.js` with the latest template. Otherwise it's skipped and you can add it manually later.
81
81
 
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 `.commitsheriffrc.json` / `lint-staged` config alone.
82
+ Re-running `npx commit-sheriff init` later (e.g. after updating the package) is safe for your project-specific settings: it refreshes the hook scripts and (on react+typescript projects) the ESLint/Prettier templates to the latest version, but leaves your `.commitsheriffrc.json` / `lint-staged` config alone. If you've hand-edited `.eslintrc.js` or `.prettierrc.js`, back them up first — those two get overwritten on every re-run.
83
83
 
84
84
  ## Commit message format
85
85
 
@@ -257,12 +257,18 @@ other through a public barrel file, never through deep/internal paths:
257
257
  npx commit-sheriff add-eslint-react
258
258
  ```
259
259
 
260
- This copies two templates into your repo root, **without overwriting** anything already there:
260
+ This copies two templates into your repo root, **always overwriting** whatever is already
261
+ there at those exact filenames (same behavior as the `commit-msg`/`pre-commit` hooks — re-running
262
+ it refreshes both files to the latest version of the template):
261
263
 
262
264
  - `.eslintrc.js` — legacy-format ESLint config (TypeScript + React + a11y + import + sonarjs +
263
265
  testing-library/jest/vitest rules) with a module-boundary `no-restricted-imports` rule.
264
266
  - `.prettierrc.js` — matching Prettier config.
265
267
 
268
+ If you've customized either file by hand, back it up under a different name before re-running
269
+ `add-eslint-react` (or `init` on a react+typescript project, which calls it automatically) —
270
+ your edits will be replaced.
271
+
266
272
  The module list for the boundary rule isn't hardcoded — it's read straight from the `modules`
267
273
  array in your root `.commitsheriffrc.json` (the same list the commit-msg/branch-name hooks use
268
274
  for the `[MODULE]` tag), lowercased. For older installs still using `package.json`'s
@@ -161,24 +161,24 @@ const ESLINT_REACT_DEV_DEPS = [
161
161
  "prettier",
162
162
  ];
163
163
 
164
- function copyTemplateIfMissing(templateName, destName) {
164
+ function copyTemplateOverwrite(templateName, destName) {
165
165
  const src = path.join(__dirname, "..", "templates", templateName);
166
166
  const dest = path.join(cwd, destName);
167
- if (fs.existsSync(dest)) {
168
- console.log(`• ${destName} artıq var, toxunulmadı`);
169
- return;
170
- }
167
+ const existed = fs.existsSync(dest);
171
168
  fs.copyFileSync(src, dest);
172
- console.log(`✔ ${destName} yazıldı`);
169
+ console.log(existed ? `✔ ${destName} yeniləndi (üzərinə yazıldı)` : `✔ ${destName} yazıldı`);
173
170
  }
174
171
 
175
172
  function addEslintReact() {
176
- copyTemplateIfMissing("eslintrc.module-boundaries.js", ".eslintrc.js");
177
- copyTemplateIfMissing("prettier.module-boundaries.js", ".prettierrc.js");
173
+ copyTemplateOverwrite("eslintrc.module-boundaries.js", ".eslintrc.js");
174
+ copyTemplateOverwrite("prettier.module-boundaries.js", ".prettierrc.js");
178
175
  console.log(
179
176
  "\nBu şablon TypeScript/React + modul-sərhəd (module-boundary) qaydaları üçündür.\n" +
180
177
  `Modul siyahısı ${CONFIG_FILE_NAME}.modules-dən avtomatik oxunur (boşdursa nümunə\n` +
181
178
  "siyahı istifadə olunur — .eslintrc.js içindəki şərhi oxuyun).\n\n" +
179
+ "Diqqət: .eslintrc.js və .prettierrc.js hər dəfə şablonun ən son versiyası ilə\n" +
180
+ "üzərinə yazılır (commit-msg/pre-commit hook-ları kimi) — özünüzə uyğun etdiyiniz\n" +
181
+ "dəyişiklikləri qorumaq istəsəniz, əvvəlcə fərqli adla backup götürün.\n\n" +
182
182
  "Lazımi devDependencies (özünüz quraşdırın, layihənizin real versiyalarına uyğun):\n" +
183
183
  ` npm install --save-dev ${ESLINT_REACT_DEV_DEPS.join(" ")}\n`,
184
184
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commit-sheriff",
3
- "version": "1.3.1",
3
+ "version": "1.4.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": {