From 0548bdb65540b780850b9a0138eb6da7d668a052 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Fri, 5 Oct 2018 09:39:30 +0100 Subject: [PATCH] [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. --- .gitignore | 1 + .pre-commit-config.yaml | 38 ++++++++++++++++++++++++++++++++++++++ setup.cfg | 4 ++-- 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.gitignore b/.gitignore index 1f6576205..1a311cdf2 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ deluge.pot .build_data* osx/app RELEASE-VERSION +.venv diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..95f028402 --- /dev/null +++ b/.pre-commit-config.yaml @@ -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 diff --git a/setup.cfg b/setup.cfg index 4809e64b5..822958602 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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