8
0

gruntfile.js 2.4 KB

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