[Lint] Add pre-commit config

- Added a pre-commit config for code linting and formatting. It will
  auto-format python, javascript, CSS, YAML and markdown files to save
  manually doing so. To install:

      pip install pre-commit
      pre-commit install

- Added a default virtual environment directory to gitignore.
This commit is contained in:
Calum Lind 2018-10-05 09:39:30 +01:00
parent 36606fc448
commit 0548bdb655
3 changed files with 41 additions and 2 deletions

1
.gitignore vendored
View File

@ -17,3 +17,4 @@ deluge.pot
.build_data*
osx/app
RELEASE-VERSION
.venv

38
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,38 @@
repos:
- repo: https://github.com/ambv/black
rev: 18.9b0
hooks:
- id: black
name: Fmt Black
language_version: python3.6
- repo: https://github.com/prettier/prettier
rev: 1.14.3
hooks:
- id: prettier
name: Fmt Prettier
files: "\\.(
css\
|less\
|scss\
|html\
|ts|tsx\
|graphql|gql\
|json\
|js|jsx\
|md|markdown|mdown|mkdn\
|yaml|yml\
)$"
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v1.4.0
hooks:
- id: double-quote-string-fixer
name: Fix Double-quotes
- id: end-of-file-fixer
name: Fix End-of-files
- id: mixed-line-ending
name: Fix Line-endings
args: [--fix=auto]
- id: flake8
name: Chk Flake8
additional_dependencies:
- flake8-isort==2.5

View File

@ -23,8 +23,8 @@ known_third_party =
bbfreeze, win32verstamp,
# Ignore gtk modules, primarily for tox testing.
pygtk, gtk, gobject, gtk.gdk, pango, cairo, pangocairo,
# Ignore sphinx dependencies.
recommonmark,
# Ignore other module dependencies for pre-commit isort.
twisted, OpenSSL, pytest, recommonmark, chardet, pkg_resources, zope, mock
known_first_party = msgfmt, deluge
order_by_type = true
not_skip = __init__.py