From 97db36822eacc42030c84722d9cd877eca3c9b86 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Thu, 2 Apr 2015 10:37:32 -0600 Subject: [PATCH] Establish baseline JSCS configuration Establishes the ability to have JSCS (JS Code Style) run from the run_tests.sh script. Also provides basis for code style configuration. Co-Authored-By: Brian Tully Change-Id: Ib22da5ae05c353d12507a1809ec79e93379acecf Closes-Bug: 1450626 --- .jscsrc | 3 +++ doc/source/ref/run_tests.rst | 7 +++++++ run_tests.sh | 18 ++++++++++++++++++ tox.ini | 5 +++++ 4 files changed, 33 insertions(+) create mode 100644 .jscsrc diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 0000000000..ceffe72503 --- /dev/null +++ b/.jscsrc @@ -0,0 +1,3 @@ +{ + "disallowTrailingWhitespace": true +} diff --git a/doc/source/ref/run_tests.rst b/doc/source/ref/run_tests.rst index a8e731ea80..2a703a66a6 100644 --- a/doc/source/ref/run_tests.rst +++ b/doc/source/ref/run_tests.rst @@ -140,6 +140,13 @@ Give me metrics! You can generate various reports and metrics using command line arguments to ``run_tests.sh``. +JSCS +---- + +To run JSCS, a JavaScript code style checker:: + + ./run_tests.sh --jscs + Coverage -------- diff --git a/run_tests.sh b/run_tests.sh index cf38894b04..296946bd47 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -27,6 +27,7 @@ function usage { echo " -t, --tabs Check for tab characters in files." echo " -y, --pylint Just run pylint" echo " -j, --jshint Just run jshint" + echo " -s, --jscs Just run jscs" echo " -q, --quiet Run non-interactively. (Relatively) quiet." echo " Implies -V if -N is not set." echo " --only-selenium Run only the Selenium unit tests" @@ -106,6 +107,7 @@ function process_option { -P|--no-pep8) no_pep8=1;; -y|--pylint) just_pylint=1;; -j|--jshint) just_jshint=1;; + -s|--jscs) just_jscs=1;; -f|--force) force=1;; -t|--tabs) just_tabs=1;; -q|--quiet) quiet=1;; @@ -161,6 +163,16 @@ function run_jshint { jshint openstack_dashboard/static/dashboard/ } +function run_jscs { + echo "Running jscs ..." + if [ "`which jscs`" == '' ] ; then + echo "jscs is not present; please install, e.g. sudo npm install jscs -g" + else + jscs horizon/static/horizon/js horizon/static/horizon/tests \ + horizon/static/angular/ openstack_dashboard/static/dashboard/ + fi +} + function warn_on_flake8_without_venv { set +o errexit ${command_wrapper} python -c "import hacking" 2>/dev/null @@ -555,6 +567,12 @@ if [ $just_jshint -eq 1 ]; then exit $? fi +# Jscs +if [ $just_jscs -eq 1 ]; then + run_jscs + exit $? +fi + # Tab checker if [ $just_tabs -eq 1 ]; then tab_check diff --git a/tox.ini b/tox.ini index 9781ffe06e..2d2cfafd36 100644 --- a/tox.ini +++ b/tox.ini @@ -49,6 +49,11 @@ commands = nodeenv -p npm install jshint -g /bin/bash run_tests.sh -N --jshint +[testenv:jscs] +commands = nodeenv -p + npm install jscs -g + /bin/bash run_tests.sh -N --jscs + [testenv:docs] setenv = DJANGO_SETTINGS_MODULE=openstack_dashboard.test.settings commands = python setup.py build_sphinx