From 768ece28e606f19dc2f7cadfc66aad807d5d30e9 Mon Sep 17 00:00:00 2001 From: David Majda Date: Fri, 22 Jan 2016 13:48:22 +0100 Subject: [PATCH] Use ESLint instead of JSHint Implement the swap and change various directives in the source code. The "make hint" target becomes "make lint". The change leads to quite some errors being reported by ESLint. These will be fixed in subsequent commits. Note the configuration enables just the recommended rules. Later I plan to enable more rules to enforce the coding standard. The configuration also sets the environment to "node", which is far from ideal as the codebase contains a mix of CommonJS, Node.js and browser code. I hope to clean this up at some point. --- .eslintrc.json | 6 ++++++ .jshintrc | 20 ------------------- Makefile | 12 +++++------ benchmark/index.js | 2 +- package.json | 6 +++--- spec/api/generated-parser-api.spec.js | 2 +- spec/api/pegjs-api.spec.js | 2 +- spec/api/plugin-api.spec.js | 2 +- .../generated-parser-behavior.spec.js | 2 +- .../compiler/passes/generate-bytecode.spec.js | 2 +- spec/unit/compiler/passes/helpers.js | 2 +- .../passes/remove-proxy-rules.spec.js | 2 +- .../passes/report-infinite-loops.spec.js | 2 +- .../passes/report-left-recursion.spec.js | 2 +- .../passes/report-missing-rules.spec.js | 2 +- spec/unit/parser.spec.js | 2 +- 16 files changed, 27 insertions(+), 41 deletions(-) create mode 100644 .eslintrc.json delete mode 100644 .jshintrc diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..10ebc8a --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,6 @@ +{ + "extends": "eslint:recommended", + "env": { + "node": true + } +} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index dd732c7..0000000 --- a/.jshintrc +++ /dev/null @@ -1,20 +0,0 @@ -{ - "curly": true, - "eqeqeq": true, - "evil": true, - "forin": true, - "freeze": true, - "immed": true, - "latedef": "nofunc", - "laxbreak": true, - "loopfunc": true, - "newcap": false, - "noarg": true, - "node": true, - "noempty": true, - "nonew": true, - "strict": true, - "trailing": true, - "validthis": true, - "-W082": false -} diff --git a/Makefile b/Makefile index db0ab6e..a9942d2 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ VERSION_FILE = VERSION # ===== Executables ===== -JSHINT = $(NODE_MODULES_BIN_DIR)/jshint +ESLINT = $(NODE_MODULES_BIN_DIR)/eslint BROWSERIFY = $(NODE_MODULES_BIN_DIR)/browserify UGLIFYJS = $(NODE_MODULES_BIN_DIR)/uglifyjs JASMINE_NODE = $(NODE_MODULES_BIN_DIR)/jasmine-node @@ -82,14 +82,14 @@ spec: benchmark: $(BENCHMARK_RUN) -# Run JSHint on the source -hint: - $(JSHINT) \ +# Run ESLint on the source +lint: + $(ESLINT) \ `find $(LIB_DIR) -name '*.js'` \ `find $(SPEC_DIR) -name '*.js' -and -not -path '$(SPEC_DIR)/vendor/*'` \ $(BENCHMARK_DIR)/*.js \ $(BENCHMARK_RUN) \ $(PEGJS) -.PHONY: all parser browser browserclean spec benchmark hint -.SILENT: all parser browser browserclean spec benchmark hint +.PHONY: all parser browser browserclean spec benchmark lint +.SILENT: all parser browser browserclean spec benchmark lint diff --git a/benchmark/index.js b/benchmark/index.js index 726be23..e2aa861 100644 --- a/benchmark/index.js +++ b/benchmark/index.js @@ -1,4 +1,4 @@ -/* jshint node:false, browser:true, devel:true, jquery:true */ +/* eslint-env browser, jquery */ /* global Runner */ $("#run").click(function() { diff --git a/package.json b/package.json index a655e17..df3f081 100644 --- a/package.json +++ b/package.json @@ -43,13 +43,13 @@ "bin": "bin/pegjs", "repository": "pegjs/pegjs", "scripts": { - "test": "make hint && make spec" + "test": "make lint && make spec" }, "devDependencies": { "browserify": "11.2.0", + "eslint": "1.10.3", "jasmine-node": "1.14.5", - "uglify-js": "2.4.24", - "jshint": "2.8.0" + "uglify-js": "2.4.24" }, "engines": { "node": ">=0.10" diff --git a/spec/api/generated-parser-api.spec.js b/spec/api/generated-parser-api.spec.js index cb7e91f..85977e3 100644 --- a/spec/api/generated-parser-api.spec.js +++ b/spec/api/generated-parser-api.spec.js @@ -1,4 +1,4 @@ -/* jshint jasmine:true */ +/* eslint-env jasmine */ /* global PEG */ "use strict"; diff --git a/spec/api/pegjs-api.spec.js b/spec/api/pegjs-api.spec.js index 97c4319..9488e5f 100644 --- a/spec/api/pegjs-api.spec.js +++ b/spec/api/pegjs-api.spec.js @@ -1,4 +1,4 @@ -/* jshint jasmine:true */ +/* eslint-env jasmine */ /* global PEG */ "use strict"; diff --git a/spec/api/plugin-api.spec.js b/spec/api/plugin-api.spec.js index 129ea32..d3efe81 100644 --- a/spec/api/plugin-api.spec.js +++ b/spec/api/plugin-api.spec.js @@ -1,4 +1,4 @@ -/* jshint jasmine:true */ +/* eslint-env jasmine */ /* global PEG */ "use strict"; diff --git a/spec/behavior/generated-parser-behavior.spec.js b/spec/behavior/generated-parser-behavior.spec.js index acdd064..28f0765 100644 --- a/spec/behavior/generated-parser-behavior.spec.js +++ b/spec/behavior/generated-parser-behavior.spec.js @@ -1,4 +1,4 @@ -/* jshint jasmine:true */ +/* eslint-env jasmine */ /* global PEG */ "use strict"; diff --git a/spec/unit/compiler/passes/generate-bytecode.spec.js b/spec/unit/compiler/passes/generate-bytecode.spec.js index 616dd56..e09fdda 100644 --- a/spec/unit/compiler/passes/generate-bytecode.spec.js +++ b/spec/unit/compiler/passes/generate-bytecode.spec.js @@ -1,4 +1,4 @@ -/* jshint jasmine:true */ +/* eslint-env jasmine */ /* global PEG */ "use strict"; diff --git a/spec/unit/compiler/passes/helpers.js b/spec/unit/compiler/passes/helpers.js index 2fcc284..00819b2 100644 --- a/spec/unit/compiler/passes/helpers.js +++ b/spec/unit/compiler/passes/helpers.js @@ -1,4 +1,4 @@ -/* jshint jasmine:true */ +/* eslint-env jasmine */ /* global PEG */ "use strict"; diff --git a/spec/unit/compiler/passes/remove-proxy-rules.spec.js b/spec/unit/compiler/passes/remove-proxy-rules.spec.js index 476dbe6..512b67b 100644 --- a/spec/unit/compiler/passes/remove-proxy-rules.spec.js +++ b/spec/unit/compiler/passes/remove-proxy-rules.spec.js @@ -1,4 +1,4 @@ -/* jshint jasmine:true */ +/* eslint-env jasmine */ /* global PEG */ "use strict"; diff --git a/spec/unit/compiler/passes/report-infinite-loops.spec.js b/spec/unit/compiler/passes/report-infinite-loops.spec.js index 24d0366..eb3b7d8 100644 --- a/spec/unit/compiler/passes/report-infinite-loops.spec.js +++ b/spec/unit/compiler/passes/report-infinite-loops.spec.js @@ -1,4 +1,4 @@ -/* jshint jasmine:true */ +/* eslint-env jasmine */ /* global PEG */ "use strict"; diff --git a/spec/unit/compiler/passes/report-left-recursion.spec.js b/spec/unit/compiler/passes/report-left-recursion.spec.js index c1905cc..6188f0e 100644 --- a/spec/unit/compiler/passes/report-left-recursion.spec.js +++ b/spec/unit/compiler/passes/report-left-recursion.spec.js @@ -1,4 +1,4 @@ -/* jshint jasmine:true */ +/* eslint-env jasmine */ /* global PEG */ "use strict"; diff --git a/spec/unit/compiler/passes/report-missing-rules.spec.js b/spec/unit/compiler/passes/report-missing-rules.spec.js index 0e98a04..136fae1 100644 --- a/spec/unit/compiler/passes/report-missing-rules.spec.js +++ b/spec/unit/compiler/passes/report-missing-rules.spec.js @@ -1,4 +1,4 @@ -/* jshint jasmine:true */ +/* eslint-env jasmine */ /* global PEG */ "use strict"; diff --git a/spec/unit/parser.spec.js b/spec/unit/parser.spec.js index 4102ffb..5fe756d 100644 --- a/spec/unit/parser.spec.js +++ b/spec/unit/parser.spec.js @@ -1,4 +1,4 @@ -/* jshint jasmine:true */ +/* eslint-env jasmine */ /* global PEG */ "use strict";