diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..75823d9d --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +# Exclude libs. +**/lib/**/*.js diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index 83968614..00000000 --- a/.jscsrc +++ /dev/null @@ -1,75 +0,0 @@ -{ - "requireCurlyBraces": [ - "if", - "else", - "for", - "while", - "do", - "try", - "catch" - ], - "requireOperatorBeforeLineBreak": true, - "requireCamelCaseOrUpperCaseIdentifiers": true, - "maximumLineLength": { - "value": 80, - "allExcept": ["comments", "regex"] - }, - "validateIndentation": 2, - "validateQuoteMarks": "'", - - "disallowMultipleLineStrings": true, - "disallowMixedSpacesAndTabs": true, - "disallowTrailingWhitespace": true, - "disallowSpaceAfterPrefixUnaryOperators": true, - "disallowMultipleVarDecl": true, - "disallowKeywordsOnNewLine": ["else"], - - "requireSpaceAfterKeywords": [ - "if", - "else", - "for", - "while", - "do", - "switch", - "return", - "try", - "catch" - ], - "requireSpaceBeforeBinaryOperators": [ - "=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=", - "&=", "|=", "^=", "+=", - - "+", "-", "*", "/", "%", "<<", ">>", ">>>", "&", - "|", "^", "&&", "||", "===", "==", ">=", - "<=", "<", ">", "!=", "!==" - ], - "requireSpaceAfterBinaryOperators": true, - "requireSpacesInConditionalExpression": true, - "requireSpaceBeforeBlockStatements": true, - "requireSpacesInForStatement": true, - "requireLineFeedAtFileEnd": true, - "requireSpacesInFunctionExpression": { - "beforeOpeningCurlyBrace": true - }, - "disallowSpacesInAnonymousFunctionExpression": { - "beforeOpeningRoundBrace": false - }, - "disallowSpacesInsideObjectBrackets": "all", - "disallowSpacesInsideArrayBrackets": "all", - "disallowSpacesInsideParentheses": true, - - "disallowMultipleLineBreaks": true, - "disallowNewlineBeforeBlockStatements": true, - "disallowKeywords": ["with"], - "disallowSpacesInFunctionExpression": null, - "disallowSpacesInFunctionDeclaration": null, - "disallowSpacesInCallExpression": true, - "disallowSpaceAfterObjectKeys": false, - "requireSpaceBeforeObjectValues": true, - "requireCapitalizedConstructors": true, - "requireDotNotation": true, - "requireSemicolons": true, - "validateParameterSeparator": ", ", - - "jsDoc": null -} \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 6b972940..3aa979a7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -83,33 +83,12 @@ module.exports = function(grunt) { css : ['src/css/**/*.css'] }, - jscs : { - options : { - "config": ".jscsrc", - "maximumLineLength": 120, - "requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties", - "validateQuoteMarks": { "mark": "'", "escape": true }, - "disallowMultipleVarDecl": "exceptUndefined", - "disallowSpacesInAnonymousFunctionExpression": null - }, - js : [ 'src/js/**/*.js' , '!src/js/**/lib/**/*.js' ] - }, - - jshint: { - options: { - undef : true, - latedef : true, - browser : true, - trailing : true, - curly : true, - globals : {'$':true, 'jQuery' : true, 'pskl':true, 'Events':true, 'Constants':true, 'console' : true, 'module':true, 'require':true, 'Q':true, 'Promise': true} - }, + eslint: { files: [ // Includes - 'Gruntfile.js', - 'package.json', 'src/js/**/*.js', - // Excludes + // Exludes + // TODO: remove this (for now we still get warnings from the lib folder) '!src/js/**/lib/**/*.js' ] }, @@ -337,7 +316,7 @@ module.exports = function(grunt) { // TEST TASKS // Run linting - grunt.registerTask('lint', ['jscs:js', 'leadingIndent:css', 'jshint']); + grunt.registerTask('lint', ['eslint', 'leadingIndent:css']); // Run unit-tests grunt.registerTask('unit-test', ['karma']); // Run integration tests diff --git a/package.json b/package.json index 010cb969..4404f90a 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "grunt-contrib-jshint": "1.1.0", "grunt-contrib-uglify": "2.3.0", "grunt-contrib-watch": "1.0.0", + "grunt-eslint": "^19.0.0", "grunt-include-replace": "4.0.1", "grunt-jscs": "2.8.0", "grunt-karma": "1.0.0", diff --git a/src/js/.eslintrc b/src/js/.eslintrc new file mode 100644 index 00000000..a4e263e2 --- /dev/null +++ b/src/js/.eslintrc @@ -0,0 +1,99 @@ +{ + "env": { + "es6": true, + "browser": true + }, + "globals": { + "$": true, + "jQuery": true, + "pskl": true, + "Events": true, + "Constants": true, + "console": true, + "module": true, + "require": true, + "Q": true, + "Promise": true + }, + "rules": { + "no-undef": 2, + "no-use-before-define": [ + 2, + { + "functions": false + } + ], + "curly": [ + 2, + "all" + ], + "operator-linebreak": [ + 2, + "after" + ], + "camelcase": [ + 2, + { + "properties": "never" + } + ], + "max-len": [ + 2, + 120 + ], + "indent": [ + 2, + 2, + { + "SwitchCase": 1 + } + ], + "quotes": [ + 2, + "single" + ], + "no-multi-str": 2, + "no-mixed-spaces-and-tabs": 2, + "no-trailing-spaces": 2, + "space-unary-ops": [ + 2, + { + "nonwords": false, + "overrides": {} + } + ], + "one-var": [ + 2, + "never" + ], + "brace-style": [ + 2, + "1tbs", + { + "allowSingleLine": true + } + ], + "keyword-spacing": [ + 2, + {} + ], + "space-infix-ops": 2, + "space-before-blocks": [ + 2, + "always" + ], + "eol-last": 2, + "space-in-parens": [ + 2, + "never" + ], + "no-multiple-empty-lines": 2, + "no-with": 2, + "no-spaced-func": 2, + "dot-notation": 2, + "semi": [ + 2, + "always" + ] + } +}