File: lint_staged

package info (click to toggle)
node-wikibase-cli 15.15.4-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,940 kB
  • sloc: javascript: 4,531; sh: 26; makefile: 7
file content (14 lines) | stat: -rwxr-xr-x 357 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/env bash

set -eu

# keep A (added) and M (modified) files
# only if staged (0 space before/2 space after the letter)
staged=$(git status --porcelain | grep -E "^(A|M)" | grep -E 'wb-|\.js$' | sed -E 's/^\w+\s+//')
if [ -z "$staged" ]
  then
    echo 'no file to lint'
  else
    sed -i 's/ / /g' $staged
    eslint -c .eslintrc --fix $staged
fi