Add eslint javascript checker

This commit adds a eslint tox environment, that installs eslint and
checks muranodashboard js code against it.

Eslint is the current linter of choice for horizon, because it is
capable of detecting both style and syntax errors (and does not have
license limitations of jshint).

To run: tox -e eslint
Partially implements: blueprint add-js-lint-jobs

Change-Id: I645f279ab6ac45b7d1d872ded803c126dd0a10e7
This commit is contained in:
Kirill Zaitsev 2015-07-11 03:36:49 +03:00
parent 633bcb4571
commit 886807c337
5 changed files with 79 additions and 0 deletions

52
.eslintrc Normal file
View File

@ -0,0 +1,52 @@
# For a detailed list of all options please see here:
# http://eslint.org/docs/configuring/
env:
# Use jquery global variables
jquery: true
browser: true
rules:
# Specify whether backticks, double or single quotes should be used
# http://eslint.org/docs/rules/quotes
quotes:
- 0 # TODO(kzaitsev): Activate & Fix
- 'single'
# Require camel case names
# http://eslint.org/docs/rules/camelcase
camelcase:
- 1
- properties: "never"
globals:
# allow accessing horizon
horizon: false
# Only support ECMA5, disable everything else.
# NOTE(kzaitsev): blatantly copied from horizon
ecmaFeatures:
arrowFunctions: false
binaryLiterals: false
blockBindings: false
classes: false
defaultParams: false
destructuring: false
forOf: false
generators: false
modules: false
objectLiteralComputedProperties: false
objectLiteralDuplicateProperties: false
objectLiteralShorthandMethods: false
objectLiteralShorthandProperties: false
octalLiterals: false
regexUFlag: false
regexYFlag: false
restParams: false
spread: false
superInFunctions: false
templateStrings: false
unicodeCodePointEscapes: false
globalReturn: false
jsx: false

2
.gitignore vendored
View File

@ -25,3 +25,5 @@ doc/source/api
# Tests
muranodashboard/test/functional/config/config.conf
node_modules
npm-debug.log

15
package.json Normal file
View File

@ -0,0 +1,15 @@
{
"version": "0.0.0",
"private": true,
"name": "muranodashboard",
"description": "Murano Dashboard",
"repository": "none",
"license": "Apache 2.0",
"devDependencies": {
"eslint": "^0.23.0"
},
"scripts": {
"lint": "eslint --no-color muranodashboard/static"
},
"dependencies": {}
}

View File

@ -22,3 +22,6 @@ sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
Django<1.8,>=1.4.2
django-compressor>=1.4
django-openstack-auth!=1.1.8,>=1.1.7
# js lint tests
nodeenv>=0.9.4 # BSD License

View File

@ -33,6 +33,13 @@ commands = nosetests --cover-erase --cover-package=muranodashboard --with-xcover
deps = flake8
commands = flake8
[testenv:eslint]
deps = -r{toxinidir}/test-requirements.txt
passenv = *
commands = nodeenv -p
npm install
npm run lint
[tox:jenkins]
downloadcache = ~/cache/pip