From 755f1dfba28081223a1f1a1890223a133bc5130f Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Thu, 5 Feb 2015 13:38:23 +0200 Subject: Add grunt-eslint. --- Gruntfile.js | 38 +++++++++---- docs/assets/js/docs.js | 9 +--- docs/assets/js/fingerblast.js | 2 +- grunt/ratchicons-data-generator.js | 1 + js/.eslintrc | 106 +++++++++++++++++++++++++++++++++++++ js/.jshintrc | 6 +++ package.json | 1 + 7 files changed, 145 insertions(+), 18 deletions(-) create mode 100644 js/.eslintrc diff --git a/Gruntfile.js b/Gruntfile.js index 44c8fe3..eec1627 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -6,8 +6,11 @@ */ /* jshint node: true */ +/* eslint-env node */ + +'use strict'; + module.exports = function (grunt) { - 'use strict'; // Force use of Unix newlines grunt.util.linefeed = '\n'; @@ -153,7 +156,7 @@ module.exports = function (grunt) { 'Android 2.3', 'Android >= 4', 'Chrome >= 20', - 'Firefox >= 24', // Firefox 24 is the latest ESR + 'Firefox >= 24', // Firefox 24 is the latest ESR 'Explorer >= 9', 'iOS >= 6', 'Opera >= 12', @@ -169,7 +172,7 @@ module.exports = function (grunt) { 'Android 2.3', 'Android >= 4', 'Chrome >= 20', - 'Firefox >= 24', // Firefox 24 is the latest ESR + 'Firefox >= 24', // Firefox 24 is the latest ESR 'Opera >= 12' ] }, @@ -188,7 +191,7 @@ module.exports = function (grunt) { cssmin: { options: { - keepSpecialComments: '*' // keep all important comments + keepSpecialComments: '*' // keep all important comments }, ratchet: { src: '<%= meta.distPath %>css/<%= pkg.name %>.css', @@ -295,7 +298,7 @@ module.exports = function (grunt) { options: { jshintrc: 'js/.jshintrc' }, - grunt: { + gruntfile: { src: ['Gruntfile.js', 'grunt/*.js'] }, src: { @@ -310,8 +313,23 @@ module.exports = function (grunt) { options: { config: 'js/.jscsrc' }, - grunt: { - src: '<%= jshint.grunt.src %>' + gruntfile: { + src: '<%= jshint.gruntfile.src %>' + }, + src: { + src: '<%= jshint.src.src %>' + }, + docs: { + src: '<%= jshint.docs.src %>' + } + }, + + eslint: { + options: { + config: 'js/.eslintrc' + }, + gruntfile: { + src: '<%= jshint.gruntfile.src %>' }, src: { src: '<%= jshint.src.src %>' @@ -408,11 +426,13 @@ module.exports = function (grunt) { grunt.registerTask('validate-html', ['jekyll:docs', 'htmllint']); grunt.registerTask('build', ['dist']); grunt.registerTask('default', ['dist']); - grunt.registerTask('test', ['dist', 'csslint', 'jshint', 'jscs', 'validate-html']); + grunt.registerTask('test', ['dist', 'csslint', 'eslint', 'jshint', 'jscs', 'validate-html']); grunt.registerTask('server', ['dist', 'jekyll:docs', 'connect', 'watch']); grunt.registerTask('prep-release', ['dist', 'jekyll:github', 'htmlmin', 'compress']); - grunt.registerTask('build-ratchicons-data', function () { generateRatchiconsData.call(this, grunt); }); + grunt.registerTask('build-ratchicons-data', function () { + generateRatchiconsData.call(this, grunt); + }); // Version numbering task. // grunt change-version-number --oldver=A.B.C --newver=X.Y.Z diff --git a/docs/assets/js/docs.js b/docs/assets/js/docs.js index 753ffba..5951988 100644 --- a/docs/assets/js/docs.js +++ b/docs/assets/js/docs.js @@ -1,4 +1,5 @@ /* jshint jquery: true */ +/* eslint-env jquery */ /* global FingerBlast: true */ $(function () { @@ -8,12 +9,8 @@ $(function () { var device; var windowWidth; var windowHeight; - var pageHeight; - var contentPadding; - var footerHeight; var navComponentLinks; var componentsList; - var componentLinks; var contentSection; var currentActive; var topCache; @@ -32,14 +29,10 @@ $(function () { device = device || $('.js-device'); navComponentLinks = $('.js-jump-menu'); componentsList = $('.js-component-group'); - componentLinks = $('.component-example a'); contentSection = $('.component'); topCache = contentSection.map(function () { return $(this).offset().top; }); windowHeight = $(window).height() / 3; windowWidth = $(window).width(); - pageHeight = $(document).height(); - contentPadding = parseInt($('.docs-content').css('padding-bottom'), 10); - footerHeight = $('.docs-footer').outerHeight(false); toolbarToggle = $('.js-docs-component-toolbar'); // Device placement diff --git a/docs/assets/js/fingerblast.js b/docs/assets/js/fingerblast.js index 5d5d646..3828d6b 100644 --- a/docs/assets/js/fingerblast.js +++ b/docs/assets/js/fingerblast.js @@ -36,7 +36,7 @@ var descendant; if (!element) { - return; + return false; } if ('compareDocumentPosition' in ancestor) { diff --git a/grunt/ratchicons-data-generator.js b/grunt/ratchicons-data-generator.js index 0cf07ec..a72decb 100644 --- a/grunt/ratchicons-data-generator.js +++ b/grunt/ratchicons-data-generator.js @@ -6,6 +6,7 @@ */ /* jshint node: true */ +/* eslint-env node */ 'use strict'; diff --git a/js/.eslintrc b/js/.eslintrc new file mode 100644 index 0000000..d596b5d --- /dev/null +++ b/js/.eslintrc @@ -0,0 +1,106 @@ +{ + "env": { + "browser": true + }, + + "rules": { + "block-scoped-var": 2, + "brace-style": [2, "1tbs"], + "camelcase": 2, + "comma-dangle": 2, + "comma-spacing": [2, { "before": false, "after": true }], + "comma-style": [2, "last"], + "consistent-return": 2, + "consistent-this": [2, "self"], + "curly": 2, + "eol-last": 2, + "eqeqeq": 2, + "func-names": 0, + "func-style": [0, "expression"], + "guard-for-in": 2, + "handle-callback-err": 2, + "indent": [2, 2], + "key-spacing": [0, { "beforeColon": false, "afterColon": true }], + "new-cap": 0, + "newline-after-var": [0, "always"], + "new-parens": 2, + "no-array-constructor": 2, + "no-bitwise": 0, + "no-cond-assign": 2, + "no-constant-condition": 2, + "no-control-regex": 2, + "no-debugger": 2, + "no-delete-var": 2, + "no-dupe-args": 2, + "no-dupe-keys": 2, + "no-duplicate-case": 2, + "no-else-return": 2, + "no-empty": 2, + "no-empty-character-class": 2, + "no-eq-null": 2, + "no-ex-assign": 2, + "no-extra-boolean-cast": 2, + "no-extra-parens": 0, + "no-extra-semi": 2, + "no-fallthrough": 2, + "no-floating-decimal": 2, + "no-func-assign": 2, + "no-implicit-coercion": 0, + "no-inline-comments": 0, + "no-inner-declarations": 2, + "no-invalid-regexp": 2, + "no-irregular-whitespace": 2, + "no-lone-blocks": 2, + "no-lonely-if": 2, + "no-loop-func": 2, + "no-mixed-requires": 2, + "no-mixed-spaces-and-tabs": 2, + "no-multiple-empty-lines": 2, + "no-multi-spaces": 0, + "no-multi-str": 2, + "no-negated-in-lhs": 2, + "no-new-object": 2, + "no-obj-calls": 2, + "no-octal": 2, + "no-path-concat": 2, + "no-process-env": 2, + "no-redeclare": 2, + "no-regex-spaces": 2, + "no-return-assign": 2, + "no-self-compare": 2, + "no-sequences": 2, + "no-spaced-func": 2, + "no-sparse-arrays": 2, + "no-throw-literal": 2, + "no-trailing-spaces": 2, + "no-undef": 2, + "no-underscore-dangle": 0, + "no-unexpected-multiline": 2, + "no-unreachable": 2, + "no-unused-expressions": 2, + "no-unused-vars": 2, + "no-useless-call": 2, + "no-useless-concat": 2, + "no-void": 2, + "object-curly-spacing": [2, "always"], + "one-var": [0, "always"], + "operator-assignment": [2, "always"], + "quote-props": [2, "as-needed"], + "quotes": [2, "single"], + "radix": 2, + "semi": [2, "always"], + "semi-spacing": 2, + "space-after-keywords": [2, "always"], + "space-before-blocks": [2, "always"], + "spaced-comment": [0, "always"], + "space-in-parens": [2, "never"], + "space-return-throw-case": 2, + "space-unary-ops": [2, { "words": true, "nonwords": false }], + "strict": [0, "global"], + "use-isnan": 2, + //"valid-jsdoc": 1, + "valid-typeof": 2, + "wrap-iife": [0, "outside"], + "yoda": [2, "never"] + } +} diff --git a/js/.jshintrc b/js/.jshintrc index 2eac213..4a5c377 100644 --- a/js/.jshintrc +++ b/js/.jshintrc @@ -1,13 +1,19 @@ { "bitwise" : true, "browser" : true, + "curly" : true, "devel" : true, "eqeqeq" : true, "expr" : true, "forin" : true, "freeze" : true, + "immed" : true, "latedef" : true, + "newcap" : true, + "noarg" : true, "nonbsp" : true, + "noempty" : true, + "plusplus": false, "strict" : true, "undef" : true, "unused" : true diff --git a/package.json b/package.json index fa3f3dd..dce3bc3 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "grunt-contrib-uglify": "~0.11.0", "grunt-contrib-watch": "~0.6.1", "grunt-csscomb": "~3.1.0", + "grunt-eslint": "~17.3.1", "grunt-html": "~5.0.0", "grunt-jekyll": "~0.4.2", "grunt-jscs": "~2.5.0", -- cgit v1.2.3