commit-sheriff 1.7.1 → 1.7.2
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 +7 -7
- package/bin/commit-sheriff.js +3 -4
- package/package.json +1 -1
- package/templates/pre-commit +5 -1
package/README.md
CHANGED
|
@@ -251,19 +251,19 @@ The default config added by `init` (only if you don't already have one):
|
|
|
251
251
|
```json
|
|
252
252
|
{
|
|
253
253
|
"lint-staged": {
|
|
254
|
-
"*.{js,jsx,ts,tsx}": ["eslint --fix
|
|
254
|
+
"*.{js,jsx,ts,tsx}": ["eslint --fix", "prettier --write"],
|
|
255
255
|
"*.{json,md,css,scss,html}": ["prettier --write"]
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
```
|
|
259
259
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
260
|
+
Warnings are printed but never block the commit — only actual errors (ESLint's non-zero exit) do.
|
|
261
|
+
That's the default ESLint behavior (`--fix` alone exits 0 on warning-only results), so a rule set to
|
|
262
|
+
`"warn"` (e.g. an unused import under some "recommended" configs) shows up in the terminal as a
|
|
263
|
+
heads-up but doesn't stop you from committing.
|
|
263
264
|
|
|
264
|
-
Adjust freely — `commit-sheriff` doesn't overwrite it once present.
|
|
265
|
-
|
|
266
|
-
change, add `--max-warnings=0` to it by hand to get the same behavior.
|
|
265
|
+
Adjust freely — `commit-sheriff` doesn't overwrite it once present. If you want warnings to block
|
|
266
|
+
the commit too, add `--max-warnings=0` to the `eslint --fix` command by hand.
|
|
267
267
|
|
|
268
268
|
## Advanced: ESLint module-boundary template (TypeScript/React)
|
|
269
269
|
|
package/bin/commit-sheriff.js
CHANGED
|
@@ -38,10 +38,9 @@ const DEFAULT_COMMIT_GUARD = {
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
const DEFAULT_LINT_STAGED = {
|
|
41
|
-
// --max-warnings=0
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
"*.{js,jsx,ts,tsx}": ["eslint --fix --max-warnings=0", "prettier --write"],
|
|
41
|
+
// No --max-warnings=0 here on purpose: warnings should be visible (ESLint prints them to the
|
|
42
|
+
// terminal either way) but must NOT block the commit — only actual errors (non-zero exit) do.
|
|
43
|
+
"*.{js,jsx,ts,tsx}": ["eslint --fix", "prettier --write"],
|
|
45
44
|
"*.{json,md,css,scss,html}": ["prettier --write"],
|
|
46
45
|
};
|
|
47
46
|
|
package/package.json
CHANGED
package/templates/pre-commit
CHANGED
|
@@ -77,7 +77,11 @@ HAS_LINT_CONFIG=$(node -e "
|
|
|
77
77
|
" 2>/dev/null)
|
|
78
78
|
if [ "$HAS_LINT_CONFIG" = "1" ]; then
|
|
79
79
|
if node -e "require.resolve('lint-staged')" 2>/dev/null; then
|
|
80
|
-
|
|
80
|
+
# --verbose: lint-staged only prints a task's output when it *fails* by default, so a
|
|
81
|
+
# warning-only ESLint result (exit 0, commit still allowed through) would otherwise show
|
|
82
|
+
# nothing at all. --verbose keeps it printing on success too, so warnings stay visible as
|
|
83
|
+
# a heads-up without blocking the commit.
|
|
84
|
+
npx lint-staged --verbose || exit 1
|
|
81
85
|
else
|
|
82
86
|
echo ""
|
|
83
87
|
echo " package.json-da 'lint-staged' konfiqurasiyası var, amma paketin özü"
|