We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3022606 commit 1dc77b8Copy full SHA for 1dc77b8
pre-commit/2-js-debug.sh
@@ -0,0 +1,30 @@
1
+#!/usr/bin/env bash
2
+
3
+function test_file {
4
+ file="${1}"
5
6
+ if [ ! -f "${file}" ] ; then
7
+ return
8
+ fi
9
10
+ echo "Running JS debug statement lint..."
11
+ # Set -e before and +e after for _required_ linters (i.e.: that will prevent
12
+ # commit, e.g.: syntax linters).
13
+ # Set +e before and -e after for _optional_ linters (i.e.: that will only
14
+ # output messages upon commit, e.g.: style linters).
15
+ set +e
16
+ grep -i -E '\b(console\.)\b' $file
17
+ set -e
18
+}
19
20
+case "${1}" in
21
+ --about )
22
+ echo "Check for Drupal debug statements left in the code."
23
+ ;;
24
25
+ * )
26
+ for file in $(git diff-index --cached --name-only HEAD | grep -E '\.(js)') ; do
27
+ test_file "${file}"
28
+ done
29
30
+esac
0 commit comments