项目作者: dwightgunning

项目描述 :
A pre-commit plugin for the angular-cli linter (`ng lint`)
高级语言: Python
项目地址: git://github.com/dwightgunning/pre-commit-nglint.git
创建时间: 2019-05-01T16:17:57Z
项目社区:https://github.com/dwightgunning/pre-commit-nglint

开源协议:MIT License

下载


A pre-commit hook for Angular-Cli Lint

This is the Angular-Cli lint (ng lint) hook for pre-commit. This hook will prevent git commits if ng lint does not pass.

Usage

  • Install pre-commit (see links below).
  • Create a pre-commit config file (.pre-commit-config.yaml).
  • Run pre-commit install from the root of your project.

Finally add this to your .pre-commit-config.yaml:

  1. - repo: git://github.com/dwightgunning/pre-commit-nglint/
  2. sha: '' # Use the sha or tag (e.g. 'stable') you want to point at
  3. hooks:
  4. - id: nglint

When making a commit, the hook will run ng lint on the staged files and if errors or warnings are raised, the commit will be blocked.

Caveats

If args are provided in the pre-commit configuration, the final element must be ‘—‘ in order to distinguish between ng lint options and the filenames to be linted.

By default, pre-commit-nglint makes use of the “—files” argument on ng lint so that only files staged for commit are passed through ng lint. This keeps the linter runtime to a minimum.

Unfortunately, the combination of Angular-cli’s support for multiple ‘projects’ (e.g. ‘src’ and ‘e2e’) and the “—files” argument on ng lint can cause errors indicating that a particular file is not part of a given project. This can be worked-around by being more explicit in setting the ‘excludes’ property on the ‘lint’ project configuration (angular.json). This can be tedious but keeps the commit times to a minimum.

Copyright (c) 2019 Dwight Gunning, and individual contributors. All rights reserved.

See the file “LICENSE” for information on the history of this software, terms & conditions for usage, and a DISCLAIMER OF ALL WARRANTIES.