gruntfile.js 2.5 KB

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