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
~~~~~~~~~~~~~~~~~~
"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": {
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