]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Update frontend linting scripts and documentation 24273/head
authorTiago Melo <tspmelo@gmail.com>
Tue, 25 Sep 2018 17:02:01 +0000 (18:02 +0100)
committerTiago Melo <tspmelo@gmail.com>
Wed, 26 Sep 2018 11:15:43 +0000 (12:15 +0100)
Signed-off-by: Tiago Melo <tmelo@suse.com>
src/pybind/mgr/dashboard/HACKING.rst
src/pybind/mgr/dashboard/frontend/package.json
src/pybind/mgr/dashboard/run-frontend-unittests.sh

index 3c9f588f916119efe2d6da9355af4de148af772d..83f7ff2109216e66f52daacf4a096a2d70c3aa5d 100644 (file)
@@ -63,18 +63,21 @@ Run ``npm run build`` to build the project. The build artifacts will be
 stored in the ``dist/`` directory. Use the ``-prod`` flag for a
 production build. Navigate to ``https://localhost:8443``.
 
-Formatting TS and SCSS files
+Code linting and formatting
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-We use `Prettier <https://prettier.io/>`_ to automatically format TS and SCSS
-files.
-To use this plugin you can either install it in your IDE, if supported, or use
-it via the cli.
+We use the following tools to lint and format the code in all our TS, SCSS and
+HTML files:
 
-We added 2 npm scripts to help running prettier commands:
+- `codelyzer <http://codelyzer.com/>`_
+- `html-linter <https://github.com/chinchiheather/html-linter>`_
+- `Prettier <https://prettier.io/>`_
+- `TSLint <https://palantir.github.io/tslint/>`_
 
-- ``npm run prettier``, will run prettier formatter on all frontend files
-- ``npm run prettier:lint``, will check all frontend files against prettier linter
+We added 2 npm scripts to help run these tools:
+
+- ``npm run lint``, will check frontend files against all linters
+- ``npm run fix``, will try to fix all the detected linting errors
 
 Running Unit Tests
 ~~~~~~~~~~~~~~~~~~
index 7678416a5991b095adb1bd950c1c1eb32ec1a279..7f388544b512ea0873ce5c719130659d721f3090 100644 (file)
@@ -8,11 +8,15 @@
     "build": "ng build",
     "test": "jest --watch",
     "test:ci": "jest --coverage",
-    "lint": "ng lint",
     "e2e": "ng e2e",
-    "prettier": "prettier --write \"{src,e2e}/**/*.{ts,scss}\"",
-    "prettier:lint": "prettier --list-different \"{src,e2e}/**/*.{ts,scss}\"",
-    "lint:html": "html-linter --config html-linter.config.json"
+    "lint:tslint": "ng lint ceph-dashboard ceph-dashboard-e2e",
+    "lint:prettier": "prettier --list-different \"{src,e2e}/**/*.{ts,scss}\"",
+    "lint:html": "html-linter --config html-linter.config.json",
+    "lint": "npm run lint:tslint && npm run lint:prettier && npm run lint:html",
+    "fix:prettier": "prettier --write \"{src,e2e}/**/*.{ts,scss}\"",
+    "fix:tslint": "npm run lint:tslint -- --fix",
+    "fix": "npm run fix:tslint; npm run fix:prettier"
+
   },
   "private": true,
   "jest": {
index b546f5337eb56b1e280a3980964febafa5e7ee8e..403775af0a87750e184844449aa2ca7f90cec1c1 100755 (executable)
@@ -27,18 +27,13 @@ fi
 npm run lint --silent
 if [ $? -gt 0 ]; then
   failed=true
-  echo -e "\nTry running 'npm run lint -- --fix' to fix some linting errors."
-fi
-
-npm run prettier:lint --silent
-if [ $? -gt 0 ]; then
-  failed=true
-  echo -e "\nTry running 'npm run prettier' to fix linting errors."
+  echo -e "\nTry running 'npm run fix' to fix some linting errors. \
+Some errors might need a manual fix."
 fi
 
 if [ `uname` != "FreeBSD" ]; then
   deactivate
-fi 
+fi
 
 if [ "$failed" = "true" ]; then
   exit 1