/ script / lint
lint
 1  #!/usr/bin/env node
 2  
 3  'use strict'
 4  
 5  require('colors')
 6  
 7  const lintCoffeeScriptPaths = require('./lib/lint-coffee-script-paths')
 8  const lintJavaScriptPaths = require('./lib/lint-java-script-paths')
 9  const lintLessPaths = require('./lib/lint-less-paths')
10  const path = require('path')
11  
12  const CONFIG = require('./config')
13  
14  process.on('unhandledRejection', function (e) {
15    console.error(e.stack || e)
16    process.exit(1)
17  })
18  
19  Promise.all([lintCoffeeScriptPaths(), lintJavaScriptPaths(), lintLessPaths()])
20    .then((lintResults) => {
21      let hasLintErrors = false
22      for (let errors of lintResults) {
23        for (let error of errors) {
24          hasLintErrors = true
25          const relativePath = path.relative(CONFIG.repositoryRootPath, error.path)
26          console.log(`${relativePath}:${error.lineNumber}`.yellow + ` ${error.message} (${error.rule})`.red)
27        }
28      }
29      if (hasLintErrors) {
30        process.exit(1)
31      } else {
32        console.log('No lint errors!'.green)
33        process.exit(0)
34      }
35    })