diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..3ae0c77 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,18 @@ +{ + "env": { "shared-node-browser":true }, + "globals": {}, + "parserOptions": { + "ecmaVersion": 3, + }, + "plugins": [ "html", "json" ], + "!extends": "eslint:recommended", + "rules": { + "no-console": 0, + "no-bitwise": 0, + "curly": 0, + "comma-style": [ 2, "last" ], + "no-trailing-spaces": 2, + "semi": [ 2, "always" ], + "comma-dangle": [ 2, "never" ] + } +} diff --git a/.travis.yml b/.travis.yml index ecbe283..327390f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: node_js node_js: + - "8" - "7" - "6" - "5" diff --git a/Makefile b/Makefile index d76764d..cf54e13 100644 --- a/Makefile +++ b/Makefile @@ -9,20 +9,22 @@ ULIB=$(shell echo $(LIB) | tr a-z A-Z) DEPS=$(sort $(wildcard bits/*.js)) TARGET=$(LIB).js FLOWTARGET=$(LIB).flow.js +FLOWTGTS=$(TARGET) $(AUXTARGETS) +CLOSURE=/usr/local/lib/node_modules/google-closure-compiler/compiler.jar ## Main Targets .PHONY: all all: $(TARGET) $(AUXTARGETS) ## Build library and auxiliary scripts -$(TARGET) $(AUXTARGETS): %.js : %.flow.js +$(FLOWTGTS): %.js : %.flow.js node -e 'process.stdout.write(require("fs").readFileSync("$<","utf8").replace(/^[ \t]*\/\*[:#][^*]*\*\/\s*(\n)?/gm,"").replace(/\/\*[:#][^*]*\*\//gm,""))' > $@ $(FLOWTARGET): $(DEPS) cat $^ | tr -d '\15\32' > $@ bits/01_version.js: package.json - echo "ADLER32.version = '"`grep version package.json | awk '{gsub(/[^0-9a-z\.-]/,"",$$2); print $$2}'`"';" > $@ + echo "$(ULIB).version = '"`grep version package.json | awk '{gsub(/[^0-9a-z\.-]/,"",$$2); print $$2}'`"';" > $@ .PHONY: clean clean: clean-baseline ## Remove targets and build artifacts @@ -56,12 +58,19 @@ clean-baseline: ## Remove test baselines ## Code Checking .PHONY: lint -lint: $(TARGET) $(AUXTARGETS) ## Run jshint and jscs checks +lint: $(TARGET) $(AUXTARGETS) ## Run eslint checks + @eslint --ext .js,.njs,.json,.html,.htm $(TARGET) $(AUXTARGETS) $(CMDS) $(HTMLLINT) package.json bower.json + if [ -e $(CLOSURE) ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi + +.PHONY: old-lint +old-lint: $(TARGET) $(AUXTARGETS) ## Run jshint and jscs checks @jshint --show-non-errors $(TARGET) $(AUXTARGETS) @jshint --show-non-errors $(CMDS) @jshint --show-non-errors package.json @jshint --show-non-errors --extract=always $(HTMLLINT) @jscs $(TARGET) $(AUXTARGETS) + if [ -e $(CLOSURE) ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi + .PHONY: flow flow: lint ## Run flow checker diff --git a/demo/browser.flow.js b/demo/browser.flow.js index 5dd168c..d9517ca 100644 --- a/demo/browser.flow.js +++ b/demo/browser.flow.js @@ -3,7 +3,8 @@ /*:: declare var ADLER32: ADLER32Module; */ var X = ADLER32; -function console_log() { if(typeof console !== 'undefined') console.log.apply(console, [].slice.call(arguments)); } +// $FlowIgnore +function console_log(/*:: ...args:Array */) { if(typeof console !== 'undefined') console.log.apply(console, [].slice.call(arguments)); } function lpad(s/*:string*/, len/*:number*/, chr/*:?string*/)/*:string*/{ var L/*:number*/ = len - s.length, C/*:string*/ = chr || " "; diff --git a/demo/browser.js b/demo/browser.js index f7dcf00..2f46fb1 100644 --- a/demo/browser.js +++ b/demo/browser.js @@ -2,6 +2,7 @@ /*global ADLER32, console */ var X = ADLER32; +// $FlowIgnore function console_log() { if(typeof console !== 'undefined') console.log.apply(console, [].slice.call(arguments)); } function lpad(s, len, chr){