diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..1521c8b7 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +dist diff --git a/.eslintrc.js b/.eslintrc.js index 5c8b7758..376253c3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,346 +1,358 @@ +'use strict'; + +const degreeOfComplexity = 20; + module.exports = { - "env": { - "browser": true, - "jquery": true, - "node": true, - "amd": true + env : { + amd : true, + browser : true, + jquery : true, + node : true }, - "parserOptions": { - "ecmaVersion": 5, - "sourceType": "script" + extends : 'eslint:recommended', + overrides : [{ + files : ['.eslintrc.js', 'Gruntfile.js'], + rules : { + strict : [ + 'warn', + 'safe' + ] + } + }], + parserOptions : { + ecmaVersion : 2015, + sourceType : 'script' }, - "extends": "eslint:recommended", - "rules": { - "array-bracket-spacing": [ - "warn", - "never" - ], - "array-callback-return": "warn", - "arrow-body-style": "error", - "arrow-parens": "error", - "arrow-spacing": "error", - "block-scoped-var": "warn", - "block-spacing": [ - "warn", - "always" - ], - "brace-style": [ - "error", - "1tbs" - ], - "callback-return": "error", - "camelcase": [ - "warn", - { "properties": "always" } - ], - "class-methods-use-this": "error", - "comma-dangle": [ - "error", - "never" - ], - "comma-spacing": "error", - "comma-style": "error", - "complexity": [ - "warn", - 20 - ], - "computed-property-spacing": "error", - "consistent-return": "error", - "consistent-this": [ - "error", - "that", - "outerThis", - "self" - ], - "curly": [ - "error", - "all" - ], - "default-case": "error", - "dot-location": [ - "error", - "property" - ], - "dot-notation": "error", - "eol-last": "error", - "eqeqeq": "error", - "func-call-spacing": "error", - "func-name-matching": "error", - "id-length": [ - "warn", - { "exceptions": ["$","e","i","j"] } - ], - "indent": [ - "error", - "tab" - ], - "key-spacing": [ - "warn", { - "singleLine": { - "beforeColon": false, - "afterColon": true + rules : { + 'array-bracket-spacing' : [ + 'warn', + 'never' + ], + 'array-callback-return' : 'warn', + 'arrow-body-style' : 'error', + 'arrow-parens' : 'error', + 'arrow-spacing' : 'error', + 'block-scoped-var' : 'warn', + 'block-spacing' : [ + 'warn', + 'always' + ], + 'brace-style' : [ + 'error', + '1tbs' + ], + 'callback-return' : 'error', + 'camelcase' : [ + 'warn', + {allow: ['clk_x', 'clk_y'], properties: 'always'} + ], + 'class-methods-use-this' : 'error', + 'comma-dangle' : [ + 'error', + 'never' + ], + 'comma-spacing' : 'error', + 'comma-style' : 'error', + 'complexity' : [ + 'warn', + degreeOfComplexity + ], + 'computed-property-spacing' : 'error', + 'consistent-return' : 'error', + 'consistent-this' : [ + 'error', + 'that', + 'outerThis', + 'self' + ], + 'curly' : [ + 'error', + 'all' + ], + 'default-case' : 'error', + 'dot-location' : [ + 'error', + 'property' + ], + 'dot-notation' : 'error', + 'eol-last' : 'error', + 'eqeqeq' : 'error', + 'func-call-spacing' : 'error', + 'func-name-matching' : 'error', + 'id-length' : [ + 'warn', + {exceptions: ['$', 'e', 'i', 'j'] } + ], + 'indent' : [ + 'error', + 'tab' + ], + 'key-spacing' : [ + 'warn', { + multiLine : { + afterColon : true, + align : 'colon', + beforeColon : true }, - "multiLine": { - "beforeColon": true, - "afterColon": true, - "align": "colon" + singleLine : { + afterColon : true, + beforeColon : false } } ], - "keyword-spacing": "error", - "linebreak-style": [ - "warn", - "unix" - ], - "max-depth": "warn", - "max-nested-callbacks": "error", - "max-params": [ - "warn", - { "max": 4 } - ], - "max-statements": [ - "warn", - { "max": 20 } - ], - "max-statements-per-line": [ - "error", - { "max": 2 } - ], - "multiline-ternary": [ - "error", - "never" - ], - "new-parens": "error", - "newline-per-chained-call": [ - "warn", - { "ignoreChainWithDepth": 3 } - ], - "no-alert": "error", - "no-array-constructor": "error", - "no-await-in-loop": "error", - "no-bitwise": "error", - "no-caller": "error", - "no-compare-neg-zero": "error", - "no-confusing-arrow": "error", - "no-continue": "warn", - "no-div-regex": "error", - "no-duplicate-imports": "error", - "no-else-return": [ - "error", - { "allowElseIf": false } - ], - "no-empty": [ - "error", - { "allowEmptyCatch": true } - ], - "no-empty-function": [ - "error", - { "allow": ["functions"] } - ], - "no-eq-null": "error", - "no-eval": [ - "error", - { "allowIndirect": true } - ], - "no-extend-native": "error", - "no-extra-bind": "error", - "no-extra-label": "error", - "no-extra-parens": [ - "warn", - "all", + 'keyword-spacing' : 'error', + 'linebreak-style' : [ + 'warn', + 'unix' + ], + 'max-depth' : 'warn', + 'max-nested-callbacks' : 'error', + 'max-params' : [ + 'warn', + {max: 4} + ], + 'max-statements' : [ + 'warn', + {max: 20} + ], + 'max-statements-per-line' : [ + 'error', + {max: 2} + ], + 'multiline-ternary' : [ + 'error', + 'never' + ], + 'new-parens' : 'error', + 'newline-per-chained-call' : [ + 'warn', + {ignoreChainWithDepth: 3} + ], + 'no-alert' : 'error', + 'no-array-constructor' : 'error', + 'no-await-in-loop' : 'error', + 'no-bitwise' : 'error', + 'no-caller' : 'error', + 'no-compare-neg-zero' : 'error', + 'no-confusing-arrow' : 'error', + 'no-continue' : 'warn', + 'no-div-regex' : 'error', + 'no-duplicate-imports' : 'error', + 'no-else-return' : [ + 'error', + {allowElseIf: false} + ], + 'no-empty' : [ + 'error', + {allowEmptyCatch: true} + ], + 'no-empty-function' : [ + 'error', + {allow: ['functions'] } + ], + 'no-eq-null' : 'error', + 'no-eval' : [ + 'error', + {allowIndirect: true} + ], + 'no-extend-native' : 'error', + 'no-extra-bind' : 'error', + 'no-extra-label' : 'error', + 'no-extra-parens' : [ + 'warn', + 'all', { - "returnAssign": false, - "nestedBinaryExpressions": false + nestedBinaryExpressions : false, + returnAssign : false } ], - "no-floating-decimal": "error", - "no-global-assign": "error", - "no-implicit-globals": "error", - "no-implied-eval": "error", - "no-inner-declarations": [ - "warn", - "both" - ], - "no-invalid-this": "warn", - "no-iterator": "error", - "no-label-var": "error", - "no-labels": "error", - "no-lone-blocks": "error", - "no-lonely-if": "error", - "no-loop-func": "error", - "no-magic-numbers": [ - "warn", + 'no-floating-decimal' : 'error', + 'no-global-assign' : 'error', + 'no-implicit-globals' : 'error', + 'no-implied-eval' : 'error', + 'no-inner-declarations' : [ + 'warn', + 'both' + ], + // 'no-invalid-this' : 'warn', // Not practical for jQuery + 'no-iterator' : 'error', + 'no-label-var' : 'error', + 'no-labels' : 'error', + 'no-lone-blocks' : 'error', + 'no-lonely-if' : 'error', + 'no-loop-func' : 'error', + 'no-magic-numbers' : [ + 'warn', { - "ignore": [0,1], - "ignoreArrayIndexes": true + ignore : [0, 1], + ignoreArrayIndexes : true } ], - "no-mixed-operators": "error", - "no-mixed-requires": "error", - "no-multi-assign": "warn", - "no-multi-spaces": "error", - "no-multi-str": "error", - "no-multiple-empty-lines": [ - "error", + 'no-mixed-operators' : 'error', + 'no-mixed-requires' : 'error', + 'no-multi-assign' : 'warn', + 'no-multi-spaces' : 'error', + 'no-multi-str' : 'error', + 'no-multiple-empty-lines' : [ + 'error', { - max: 2, - maxEOF: 1, - maxBOF: 0 + max : 2, + maxBOF : 0, + maxEOF : 1 } ], - "no-negated-condition": "warn", - "no-nested-ternary": "error", - "no-new": "error", - "no-new-func": "error", - "no-new-object": "error", - "no-new-require": "error", - "no-new-wrappers": "error", - "no-octal-escape": "error", - "no-path-concat": "error", - "no-process-env": "error", - "no-process-exit": "error", - "no-proto": "error", - "no-prototype-builtins": "warn", - "no-restricted-globals": "error", - "no-restricted-imports": "error", - "no-restricted-modules": "error", - "no-restricted-properties": "error", - "no-restricted-syntax": "error", - "no-return-assign": "error", - "no-return-await": "error", - "no-script-url": "error", - "no-self-compare": "error", - "no-sequences": "error", - "no-shadow": "warn", - "no-shadow-restricted-names": "error", - "no-sync": "warn", - "no-template-curly-in-string": "error", - "no-ternary": "warn", - "no-throw-literal": "warn", - "no-trailing-spaces": "error", - "no-undef-init": "error", - "no-undefined": "warn", - "no-underscore-dangle": "error", - "no-unmodified-loop-condition": "error", - "no-unneeded-ternary": "error", - "no-unsafe-negation": "error", - "no-unused-expressions": "error", - "no-unused-vars": [ - "warn", + 'no-negated-condition' : 'warn', + 'no-nested-ternary' : 'error', + 'no-new' : 'error', + 'no-new-func' : 'error', + 'no-new-object' : 'error', + 'no-new-require' : 'error', + 'no-new-wrappers' : 'error', + 'no-octal-escape' : 'error', + 'no-path-concat' : 'error', + 'no-process-env' : 'error', + 'no-process-exit' : 'error', + 'no-proto' : 'error', + 'no-prototype-builtins' : 'warn', + 'no-restricted-globals' : 'error', + 'no-restricted-imports' : 'error', + 'no-restricted-modules' : 'error', + 'no-restricted-properties' : 'error', + 'no-restricted-syntax' : 'error', + 'no-return-assign' : 'error', + 'no-return-await' : 'error', + 'no-script-url' : 'error', + 'no-self-compare' : 'error', + 'no-sequences' : 'error', + 'no-shadow' : 'warn', + 'no-shadow-restricted-names' : 'error', + 'no-sync' : 'warn', + 'no-template-curly-in-string' : 'error', + // 'no-ternary' : 'warn', + 'no-throw-literal' : 'warn', + 'no-trailing-spaces' : 'error', + 'no-undef-init' : 'error', + 'no-underscore-dangle' : 'error', + 'no-unmodified-loop-condition' : 'error', + 'no-unneeded-ternary' : 'error', + 'no-unsafe-negation' : 'error', + 'no-unused-expressions' : 'error', + 'no-unused-vars' : [ + 'warn', { - "vars": "local", - "args": "none" + args : 'none', + vars : 'local' } ], - "no-use-before-define": [ - "error", + 'no-use-before-define' : [ + 'error', { - "functions": false + functions : false } ], - "no-useless-call": "error", - "no-useless-computed-key": "error", - "no-useless-concat": "error", - "no-useless-constructor": "error", - "no-useless-escape": "error", - "no-useless-rename": "error", - "no-useless-return": "error", - "no-var": "warn", - "no-void": "error", - "no-warning-comments": "warn", - "no-whitespace-before-property": "error", - "no-with": "error", - "nonblock-statement-body-position": "error", - "object-curly-newline": "error", - "object-curly-spacing": [ - "error", - "never", + 'no-useless-call' : 'error', + 'no-useless-computed-key' : 'error', + 'no-useless-concat' : 'error', + 'no-useless-constructor' : 'error', + 'no-useless-escape' : 'error', + 'no-useless-rename' : 'error', + 'no-useless-return' : 'error', + 'no-var' : 'warn', + 'no-void' : 'error', + 'no-warning-comments' : 'warn', + 'no-whitespace-before-property' : 'error', + 'no-with' : 'error', + 'nonblock-statement-body-position' : 'error', + 'object-curly-newline' : 'error', + 'object-curly-spacing' : [ + 'error', + 'never', { - "arraysInObjects": true, - "objectsInObjects": true + arraysInObjects : true, + objectsInObjects : true } ], - "object-property-newline": [ - "error", + 'object-property-newline' : [ + 'error', { - "allowMultiplePropertiesPerLine": true + allowMultiplePropertiesPerLine : true } ], - "object-shorthand": [ - "warn", - "consistent" - ], - "operator-assignment": [ - "error", - "always" - ], - "operator-linebreak": "error", - "padding-line-between-statements": [ - "warn", - { "blankLine": "always", "prev": ["const", "let", "var"], "next": "*"}, - { "blankLine": "any", "prev": ["const", "let", "var"], "next": ["const", "let", "var"]}, - { "blankLine": "always", "prev": "directive", "next": "*" }, - { "blankLine": "any", "prev": "directive", "next": "directive" }, - { "blankLine": "always", "prev": "*", "next": "return" } - ], - "prefer-const": "error", - "prefer-promise-reject-errors": "error", - "quote-props": [ - "warn", - "consistent-as-needed" - ], - "quotes": [ - "error", - "single", + 'object-shorthand' : [ + 'warn', + 'consistent' + ], + 'operator-assignment' : [ + 'error', + 'always' + ], + 'operator-linebreak' : 'error', + 'padding-line-between-statements' : [ + 'warn', + {blankLine: 'always', next: '*', prev: ['const', 'let', 'var'] }, + {blankLine: 'any', next: ['const', 'let', 'var'], prev: ['const', 'let', 'var'] }, + {blankLine: 'always', next: '*', prev: 'directive'}, + {blankLine: 'any', next: 'directive', prev: 'directive'}, + {blankLine: 'always', next: 'return', prev: '*'} + ], + 'prefer-const' : 'error', + 'prefer-promise-reject-errors' : 'error', + 'quote-props' : [ + 'warn', + 'consistent-as-needed' + ], + 'quotes' : [ + 'error', + 'single', { - "avoidEscape": true, - "allowTemplateLiterals": true + allowTemplateLiterals : true, + avoidEscape : true } ], - "radix": "error", - "require-await": "error", - "rest-spread-spacing": "error", - "semi": [ - "error", - "always" - ], - "semi-spacing": "error", - "sort-imports": "error", - "sort-keys": "warn", - "sort-vars": "warn", - "space-before-blocks": "warn", - "space-before-function-paren": [ - "warn", + 'radix' : 'error', + 'require-await' : 'error', + 'rest-spread-spacing' : 'error', + 'semi' : [ + 'error', + 'always' + ], + 'semi-spacing' : 'error', + 'sort-imports' : 'error', + 'sort-keys' : 'warn', + 'sort-vars' : 'warn', + 'space-before-blocks' : 'warn', + 'space-before-function-paren' : [ + 'warn', { - "anonymous": "ignore", - "named": "never", - "asyncArrow": "ignore" + anonymous : 'ignore', + asyncArrow : 'ignore', + named : 'never' } ], - "space-in-parens": "warn", - "space-infix-ops": "error", - "space-unary-ops": "error", - "spaced-comment": ["error", "always", { - "line": { - "markers": ["/"], - "exceptions": ["-", "+"] + 'space-in-parens' : 'warn', + 'space-infix-ops' : 'error', + 'space-unary-ops' : 'error', + 'spaced-comment' : ['error', 'always', { + block : { + balanced : true, + exceptions : ['*'], + markers : ['!'] }, - "block": { - "markers": ["!"], - "exceptions": ["*"], - "balanced": true + line : { + exceptions : ['-', '+'], + markers : ['/'] } }], - "strict": [ - "warn", - "function" - ], - "template-curly-spacing": "error", - "template-tag-spacing": "error", - "unicode-bom": "error", - "vars-on-top": "warn", - "wrap-iife": "error", - "yield-star-spacing": "error", - "yoda": "error" + 'strict' : [ + 'warn', + 'function' + ], + 'template-curly-spacing' : 'error', + 'template-tag-spacing' : 'error', + 'unicode-bom' : 'error', + 'vars-on-top' : 'warn', + 'wrap-iife' : 'error', + 'yield-star-spacing' : 'error', + 'yoda' : 'error' } }; diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a603da09..5eeb5a87 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,7 +33,7 @@ Here are a couple of guidelines that will help you contribute. Before we get sta ```shell $ git commit -m "A brief summary of the commit" > - > A paragraph describing what changed and its impact." + > A paragraph describing what changed and its impact. ``` * If your PR fixes a separate issue number, include it in the commit message. diff --git a/Gruntfile.js b/Gruntfile.js index 926abb55..ea517de9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,57 +1,60 @@ +'use strict'; + module.exports = function(grunt) { grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - meta: { - banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd HH:MM:ss") %> */' + eslint : { + options : { + quiet : true + }, + target : ['src/**/*.js'] }, - githooks: { - options: { - hashbang: '#!/bin/sh', - template: 'install/template/shell.hb', - startMarker: '# GRUNT-GITHOOKS START', - endMarker: '# GRUNT-GITHOOKS END' + githooks : { + all : { + 'pre-commit' : 'pre-commit' }, - all: { - 'pre-commit': 'pre-commit' + options : { + endMarker : '# GRUNT-GITHOOKS END', + hashbang : '#!/bin/sh', + startMarker : '# GRUNT-GITHOOKS START', + template : 'install/template/shell.hb' } }, - eslint: { - options: { - quiet: true - }, - target: ['src/**/*.js'] + meta : { + banner : '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd HH:MM:ss") %> */' }, - mocha: { - all: { - src: ['test/*.html'] + mocha : { + all : { + src : ['test/*.html'] }, - options: { - run: true, - growlOnSuccess: false + options : { + growlOnSuccess : false, + run : true } }, + pkg : grunt.file.readJSON('package.json'), + // Minifies JS files - uglify: { - options: { - output: { - comments: /^!|@preserve|@license|@cc_on/i - }, - sourceMap: true, - footer: '\n' - }, - dist: { - files: [{ - expand: true, - cwd: 'src', - src: ['*.js','!*.min.js'], - dest: 'dist', - ext: '.min.js', - extDot: 'last' + uglify : { + dist : { + files : [{ + cwd : 'src', + dest : 'dist', + expand : true, + ext : '.min.js', + extDot : 'last', + src : ['*.js', '!*.min.js'] }] + }, + options : { + footer : '\n', + output : { + comments : /^!|@preserve|@license|@cc_on/i + }, + sourceMap : true } } }); @@ -63,8 +66,8 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-githooks'); // Default task. - grunt.registerTask('lint', [ 'eslint' ]); - grunt.registerTask('test', [ 'lint', 'mocha' ]); - grunt.registerTask('pre-commit', [ 'test' ]); - grunt.registerTask('default', [ 'test', 'uglify' ]); + grunt.registerTask('lint', ['eslint']); + grunt.registerTask('test', ['lint', 'mocha']); + grunt.registerTask('pre-commit', ['test']); + grunt.registerTask('default', ['test', 'uglify']); }; diff --git a/README.md b/README.md index e506fc09..031e54b3 100644 --- a/README.md +++ b/README.md @@ -47,8 +47,8 @@ The jqXHR object is stored in element data-cache with the jqxhr - +