gruntfile.js 2.4 KB

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