Browse Source

Added lint-server, lint-client, format-server and format-client tasks to the Makefile (#8177)

Hitansh Shah 3 years ago
parent
commit
a8106e5072

+ 1 - 0
CHANGELOG.txt

@@ -33,6 +33,7 @@ Changelog
  * Replace `content_json` `TextField` with `content` `JSONField` in `PageRevision` (Sage Abdullah)
  * Remove `replace_text` management command (Sage Abdullah)
  * Replace `data_json` `TextField` with `data` `JSONField` in `BaseLogEntry` (Sage Abdullah)
+ * Split up linting / formatting tasks in Makefile into client and server components (Hitansh Shah)
  * Fix: When using `simple_translations` ensure that the user is redirected to the page edit view when submitting for a single locale (Mitchel Cabuloy)
  * Fix: When previewing unsaved changes to `Form` pages, ensure that all added fields are correctly shown in the preview (Joshua Munn)
  * Fix: When Documents (e.g. PDFs) have been configured to be served inline via `WAGTAILDOCS_CONTENT_TYPES` & `WAGTAILDOCS_INLINE_CONTENT_TYPES` ensure that the filename is correctly set in the `Content-Disposition` header so that saving the files will use the correct filename (John-Scott Atlakson)

+ 1 - 0
CONTRIBUTORS.rst

@@ -576,6 +576,7 @@ Contributors
 * Kyle Hart
 * Stephanie Cheng Smith
 * Luis Espinoza
+* Hitansh Shah
 
 Translators
 ===========

+ 13 - 2
Makefile

@@ -4,6 +4,7 @@ help:
 	@echo "clean-pyc - remove Python file artifacts"
 	@echo "develop - install development dependencies"
 	@echo "lint - check style with black, flake8, sort python with isort, indent html, and lint frontend css/js"
+	@echo "format - enforce a consistent code style across the codebase, sort python files with isort and fix frontend css/js"
 	@echo "test - run tests"
 	@echo "coverage - check code coverage"
 
@@ -16,24 +17,34 @@ develop: clean-pyc
 	pip install -e .[testing,docs]
 	npm install --no-save && npm run build
 
-lint:
+lint-server:
 	black --target-version py37 --check --diff .
 	flake8
 	isort --check-only --diff .
 	curlylint --parse-only wagtail
 	git ls-files '*.html' | xargs djhtml --check
+
+lint-client:
 	npm run lint:css --silent
 	npm run lint:js --silent
 	npm run lint:format --silent
+
+lint-docs:
 	doc8 docs
 
-format:
+lint: lint-server lint-client lint-docs
+
+format-server:
 	black --target-version py37 .
 	isort .
 	git ls-files '*.html' | xargs djhtml -i
+
+format-client:
 	npm run format
 	npm run fix:js
 
+format: format-server format-client
+
 test:
 	python runtests.py
 

+ 2 - 1
docs/contributing/html_guidelines.rst

@@ -7,7 +7,8 @@ Linting HTML
 ~~~~~~~~~~~~
 
 We use `curlylint <https://www.curlylint.org/>`_ to lint templates and `djhtml <https://github.com/rtts/djhtml>`_ to format them.
-If you have installed Wagtail's testing dependencies (``pip install -e .[testing]``), you can check your code by running ``make lint``, and format your code by running ``make format``.
+If you have installed Wagtail's testing dependencies (``pip install -e .[testing]``), you can check your code by running ``make lint``, and format your code by running ``make format``. Alternatively you can also run
+``make lint-client`` for checking and ``make format-client`` for formatting frontend (html/css/js) only files.
 
 Principles
 ~~~~~~~~~~

+ 3 - 2
docs/contributing/python_guidelines.rst

@@ -14,9 +14,10 @@ run by ``pre-commit`` if that is configured.
 
 In addition, import lines should be sorted according to `isort <https://pycqa.github.io/isort/>`_ 5.6.4 rules.
 If you have installed Wagtail's testing dependencies (``pip install -e '.[testing]'``), you can check your code by
-running ``make lint``.
+running ``make lint``. You can also just check python related linting by running ``make lint-server``.
 
-You can run all Python formatting with ``make format``.
+You can run all Python formatting with ``make format``. Similar to linting you can format python/template only files
+by running ``make format-server``.
 
 Django compatibility
 ~~~~~~~~~~~~~~~~~~~~

+ 1 - 0
docs/releases/2.17.md

@@ -55,6 +55,7 @@ The panel types `StreamFieldPanel`, `RichTextFieldPanel`, `ImageChooserPanel`, `
  * Add Pinterest support to the list of default oEmbed providers (Dharmik Gangani)
  * Update Jinja2 template support for Jinja2 3.x (Seb Brown)
  * Add ability for `StreamField` to use `JSONField` to store data, rather than `TextField` (Sage Abdullah)
+ * Split up linting / formatting tasks in Makefile into client and server components (Hitansh Shah)
 
 
 ### Bug fixes