gruntfile.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. module.exports = function( grunt ) {
  2. grunt.initConfig( {
  3. pkg: grunt.file.readJSON( 'package.json' ),
  4. jscs: {
  5. src: '*.js',
  6. options: jscsConfig
  7. }
  8. } );
  9. grunt.loadNpmTasks( 'grunt-jscs' );
  10. };
  11. // Configurations for JSCS (JavaScript Code Style checker)
  12. var jscsConfig = {
  13. 'excludeFiles': [
  14. 'node_modules/*'
  15. ],
  16. 'requireCurlyBraces': [
  17. 'if', 'else', 'for', 'while', 'do', 'switch', 'try', 'catch'
  18. ],
  19. 'requireSpaceAfterKeywords': [
  20. 'if', 'else', 'for', 'while', 'do', 'switch', 'return', 'try', 'catch'
  21. ],
  22. 'requireSpaceBeforeBlockStatements': true,
  23. 'requireParenthesesAroundIIFE': true,
  24. 'requireSpacesInConditionalExpression': {
  25. 'afterTest': true,
  26. 'beforeConsequent': true,
  27. 'afterConsequent': true,
  28. 'beforeAlternate': true
  29. },
  30. 'requireSpacesInFunctionExpression': {
  31. 'beforeOpeningCurlyBrace': true
  32. },
  33. 'disallowSpacesInFunctionExpression': {
  34. 'beforeOpeningRoundBrace': true
  35. },
  36. 'requireBlocksOnNewline': true,
  37. 'requireSpacesInsideObjectBrackets': 'all',
  38. 'requireSpacesInsideArrayBrackets': 'all',
  39. 'disallowSpaceAfterObjectKeys': true,
  40. 'requireCommaBeforeLineBreak': true,
  41. 'requireOperatorBeforeLineBreak': [
  42. '?', '=', '+', '-', '/', '*', '==', '===', '!=', '!==', '>', '>=', '<', '<=', '|', '||', '&', '&&', '^', '+=', '*=',
  43. '-=', '/=', '^='
  44. ],
  45. 'requireSpaceBeforeBinaryOperators': [
  46. '+', '-', '/', '*', '=', '==', '===', '!=', '!==', '>', '>=', '<', '<=', '|', '||', '&', '&&', '^', '+=', '*=', '-=',
  47. '/=', '^='
  48. ],
  49. 'requireSpaceAfterBinaryOperators': [
  50. '+', '-', '/', '*', '=', '==', '===', '!=', '!==', '>', '>=', '<', '<=', '|', '||', '&', '&&', '^', '+=', '*=', '-=',
  51. '/=', '^='
  52. ],
  53. 'disallowSpaceAfterPrefixUnaryOperators': [
  54. '++', '--', '+', '-', '~', '!'
  55. ],
  56. 'disallowSpaceBeforePostfixUnaryOperators': [
  57. '++', '--'
  58. ],
  59. 'disallowKeywords': [
  60. 'with'
  61. ],
  62. 'validateLineBreaks': 'LF',
  63. 'validateQuoteMarks': {
  64. 'mark': '\'',
  65. 'escape': true
  66. },
  67. 'validateIndentation': '\t',
  68. 'disallowMixedSpacesAndTabs': true,
  69. 'disallowTrailingWhitespace': true,
  70. 'disallowKeywordsOnNewLine': [
  71. 'else', 'catch'
  72. ],
  73. 'maximumLineLength': 120,
  74. 'safeContextKeyword': [
  75. 'that'
  76. ],
  77. 'requireDotNotation': true,
  78. 'disallowYodaConditions': true
  79. };