From 3455423f04098e9b43c1699dd5e7022c653cd77d Mon Sep 17 00:00:00 2001 From: Stefane Fermigier Date: Tue, 12 May 2015 17:56:09 +0200 Subject: [PATCH] Lint our JS code. --- .eslintrc | 11 +++++++++++ .gitignore | 1 + Makefile | 13 ++++++++----- abilian/web/resources/js/abilian.js | 2 +- abilian/web/resources/js/widgets/dynamic-row.js | 4 ++-- abilian/web/resources/js/widgets/file.js | 2 +- package.json | 17 +++++++++++++++++ 7 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 .eslintrc create mode 100644 package.json diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..d51e6118 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,11 @@ +{ + "env": { + "browser": true, + "node": true + }, + "rules": { + "camelcase": false, + "no-trailing-spaces": false, + "quotes": 0 + } +} diff --git a/.gitignore b/.gitignore index 77f55da5..f621dbd6 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ .ropeproject *,cover +node_modules env whoosh* abilian.db diff --git a/Makefile b/Makefile index 4af2c947..fa2dfbe7 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: test pep8 pylama clean docs tox +.PHONY: test pep8 pylama clean docs tox jslint # The source director SRC=abilian @@ -28,6 +28,10 @@ test-with-coverage: tox: tox +vagrant-tests: + vagrant up + vagrant ssh -c /vagrant/deploy/vagrant_test.sh + # # Various Checkers # @@ -52,13 +56,12 @@ pylama: pylint: pylint --rcfile=etc/pylintrc $(SRC) +jslint: + npm run lint --silent + check-docs: sphinx-build -W -b html docs/ docs/_build/html -vagrant-tests: - vagrant up - vagrant ssh -c /vagrant/deploy/vagrant_test.sh - # # Everything else # diff --git a/abilian/web/resources/js/abilian.js b/abilian/web/resources/js/abilian.js index 6c12123f..fb8a2dc7 100644 --- a/abilian/web/resources/js/abilian.js +++ b/abilian/web/resources/js/abilian.js @@ -134,7 +134,7 @@ ); } ); - }; + } function initLiveSearch() { var datasets = []; diff --git a/abilian/web/resources/js/widgets/dynamic-row.js b/abilian/web/resources/js/widgets/dynamic-row.js index 63eb2929..6fad7515 100644 --- a/abilian/web/resources/js/widgets/dynamic-row.js +++ b/abilian/web/resources/js/widgets/dynamic-row.js @@ -37,8 +37,8 @@ function() { var item = $(this); var shortName = item.data("shortName"); - var name = self.prefix + '-' + self.current_index - if(shortName) { + var name = self.prefix + '-' + self.current_index; + if (shortName) { name = name + '-' + shortName; } item.attr('name', name); diff --git a/abilian/web/resources/js/widgets/file.js b/abilian/web/resources/js/widgets/file.js index f19011cc..d34534e5 100644 --- a/abilian/web/resources/js/widgets/file.js +++ b/abilian/web/resources/js/widgets/file.js @@ -24,7 +24,7 @@ self.button.on('change.fileapi', 'input', {fileinput: self}, self.addFiles); - }; + } FileInput.prototype = { addFiles: function(evt) { diff --git a/package.json b/package.json new file mode 100644 index 00000000..06e24fad --- /dev/null +++ b/package.json @@ -0,0 +1,17 @@ +{ + "name": "abilian-core", + "repository": { + "type": "git", + "url": "TODO" + }, + "description": "TODO", + "scripts": { + "prestart": "npm install", + "lint": "eslint abilian/web/resources/js/ --ext .js" + }, + "dependencies": { + }, + "devDependencies": { + "eslint": "^0.20.0" + } +}