Pre Commit Hook for JSLint in Mercurial and Git

前端 未结 3 1123
予麋鹿
予麋鹿 2021-02-05 10:09

I want to run JSLint before a commit into either a Mercurial or Git repo is done.

I want this as an automatic step that is set up instead of relying on the developer (ma

3条回答
  •  忘了有多久
    2021-02-05 10:43

    JSLint with SpiderMonkey

    for js in $(git diff-index --name-only --cached HEAD -- | grep '\.js$'); do
        if jslint.sh $js 2>&1 | grep 'Lint at line' ; then
            echo $js
            exit 1
        else
            echo "js files validated"
            exit 0
        fi  
    done
    

提交回复
热议问题