diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..9a4c14fee --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +assets/static/lru.js diff --git a/.eslintrc.yaml b/.eslintrc.yaml new file mode 100644 index 000000000..753a3db0c --- /dev/null +++ b/.eslintrc.yaml @@ -0,0 +1,27 @@ +env: + browser: true + jquery: true +extends: + - eslint:recommended +rules: + indent: + - error + - 4 + linebreak-style: + - error + - unix + quotes: + - error + - double + array-bracket-spacing: + - warn + - always + block-spacing: + - warn + - always + brace-style: + - warn + - 1tbs + camelcase: warn + no-console: off + no-use-before-define: error diff --git a/.travis.yml b/.travis.yml index 043745934..a67f86434 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,15 +6,11 @@ go: go_import_path: github.com/cloudflare/unsee -# nodejs is needed so that we can install jshint -addons: - apt: - packages: - - nodejs - -# install jshint, it's used for linting js files (needs nodejs) +# install jshint & eslint, it's used for linting js files (needs nodejs) before_script: + - nvm install 6 - npm install jshint + - npm install eslint script: - make test diff --git a/Makefile b/Makefile index 3699b3f62..95aebe3d5 100644 --- a/Makefile +++ b/Makefile @@ -19,8 +19,9 @@ ifdef DEBUG DOCKER_ARGS = -v $(CURDIR)/assets:$(CURDIR)/assets:ro endif -# detect if jshint is installed +# detect if jshint and/or eslint is installed JSHINT := $(shell which jshint) +ESLINT := $(shell which eslint) .DEFAULT_GOAL := $(NAME) @@ -81,6 +82,9 @@ lint: .build/deps.ok ifneq ($(JSHINT),) @$(JSHINT) assets/static/*.js endif +ifneq ($(ESLINT),) + @$(ESLINT) assets/static/*.js +endif .PHONY: test test: lint bindata_assetfs.go