From 477f4346047b61ac12dbf946d86b0d6dd93477aa Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Tue, 30 Dec 2014 17:52:03 -0800 Subject: update linters & their configs; add ESLint --- .eslintrc | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ .jscsrc | 1 + .jshintrc | 1 + Gruntfile.js | 19 ++++++++++++++++--- package.json | 3 ++- test/css_flip_test.js | 6 +++--- 6 files changed, 75 insertions(+), 7 deletions(-) create mode 100644 .eslintrc diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..fdd1ab4 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,52 @@ +{ + "env": { + "node": true + }, + "rules": { + "block-scoped-var": 2, + "brace-style": [2, "stroustrup"], + "camelcase": 2, + "comma-spacing": [2, {"before": false, "after": true}], + "comma-style": [2, "last"], + "consistent-this": [2, "self"], + "curly": 2, + "eol-last": 2, + "eqeqeq": 2, + "key-spacing": [2, {"beforeColon": false, "afterColon": true}], + "new-cap": 2, + "new-parens": 2, + "no-array-constructor": 2, + "no-bitwise": 2, + "no-constant-condition": 0, + "no-floating-decimal": 2, + "no-inline-comments": 0, + "no-irregular-whitespace": 2, + "no-mixed-spaces-and-tabs": 2, + "no-multi-spaces": 2, + "no-multiple-empty-lines": 0, + "no-new-object": 2, + "no-process-env": 2, + "no-reserved-keys": 0, + "no-self-compare": 2, + "no-space-before-semi": 2, + "no-spaced-func": 2, + "no-trailing-spaces": 2, + "no-underscore-dangle": 0, + "no-void": 2, + "operator-assignment": [2, "always"], + "padded-blocks": 0, + "quotes": 0, + "radix": 2, + "semi": [2, "always"], + "space-after-keywords": [2, "always", {"checkFunctionKeyword": true}], + "space-before-blocks": [2, "always"], + "space-in-brackets": [2, "never"], + "space-in-parens": [2, "never"], + "space-return-throw-case": 2, + "space-unary-ops": [2, {"words": true, "nonwords": false}], + "spaced-line-comment": [2, "always"], + "vars-on-top": 0, + "wrap-iife": [2, "inside"], + "yoda": [2, "never"] + } +} diff --git a/.jscsrc b/.jscsrc index dfeab1f..0ab111a 100644 --- a/.jscsrc +++ b/.jscsrc @@ -12,6 +12,7 @@ "requireCommaBeforeLineBreak": true, "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch", "case", "default"], "requireLineFeedAtFileEnd": true, + "requireOperatorBeforeLineBreak": ["+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", "<", ">=", "<="], "requireParenthesesAroundIIFE": true, "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", "<", ">=", "<="], "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"], diff --git a/.jshintrc b/.jshintrc index 61bc4a3..0c9e5ce 100644 --- a/.jshintrc +++ b/.jshintrc @@ -10,6 +10,7 @@ "node": true, "noempty": true, "plusplus": false, + "predef": ["exports"], "sub": true, "undef": true } diff --git a/Gruntfile.js b/Gruntfile.js index 2f73445..38615c3 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -23,6 +23,17 @@ module.exports = function (grunt) { ] }, + eslint: { + options: { + config: '.eslintrc' + }, + all: [ + 'Gruntfile.js', + 'tasks/*.js', + '<%= nodeunit.tests %>' + ] + }, + jscs: { options: { config: '.jscsrc' @@ -41,13 +52,13 @@ module.exports = function (grunt) { // Configuration to be run (and then tested). cssflip: { - default_options: { + defaultOptions: { options: {}, files: { 'tmp/default_options.css': 'test/fixtures/example.css' } }, - custom_options: { + customOptions: { options: { indent: ' ' }, @@ -74,7 +85,9 @@ module.exports = function (grunt) { // plugin's task(s), then test the result. grunt.registerTask('test', ['clean', 'cssflip', 'nodeunit']); + grunt.registerTask('lint', ['jshint', 'eslint', 'jscs']); + // By default, lint and run all tests. - grunt.registerTask('default', ['jshint', 'jscs', 'test']); + grunt.registerTask('default', ['lint', 'test']); }; diff --git a/package.json b/package.json index 67cc317..8eb5de4 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ "grunt-contrib-clean": "~0.6.0", "grunt-contrib-jshint": "~0.10.0", "grunt-contrib-nodeunit": "~0.4.0", - "grunt-jscs": "~0.8.0", + "grunt-eslint": "^2.1.0", + "grunt-jscs": "^1.1.0", "load-grunt-tasks": "^2.0.0" }, "peerDependencies": { diff --git a/test/css_flip_test.js b/test/css_flip_test.js index 869ab00..b62ced7 100644 --- a/test/css_flip_test.js +++ b/test/css_flip_test.js @@ -23,11 +23,11 @@ var grunt = require('grunt'); */ exports.cssflip = { - setUp: function(done) { + setUp: function (done) { // setup here if necessary done(); }, - default_options: function(test) { + defaultOptions: function (test) { test.expect(1); var actual = grunt.file.read('tmp/default_options.css'); @@ -36,7 +36,7 @@ exports.cssflip = { test.done(); }, - custom_options: function(test) { + customOptions: function (test) { test.expect(1); var actual = grunt.file.read('tmp/custom_options.css'); -- cgit v1.2.3