SimenB/stylint

View on GitHub
docs/core_reporter.js.html

Summary

Maintainability
Test Coverage
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Source: core/reporter.js</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Source: core/reporter.js</h1>

    



    
    <section>
        <article>
            <pre class="prettyprint source linenums"><code>'use strict'

var chalk = require( 'chalk' )


/**
 * @description format output message for console (default)
 * @param  {string} msg  error msg from one of the checks
 * @param  {string} done whether or not this is the last message to output
 * @param  {string} kill whether or not we're over one of our limits
 * @return {string | Function} either the formatted msg or done()
 */
var reporter = function( msg, done, kill ) {
    if ( done === 'done' ) {
        // total errors
        this.cache.msg = 'Stylint: ' + this.cache.errs.length + ' Errors.'
        this.cache.msg += this.config.maxErrors ? ' (Max Errors: ' + this.config.maxErrors + ')' : ''
        // total warnings
        this.cache.msg += '\nStylint: ' + this.cache.warnings.length + ' Warnings.'
        this.cache.msg += this.config.maxWarnings ? ' (Max Warnings: ' + this.config.maxWarnings + ')' : ''

        // if you set a max it kills the linter
        if ( kill === 'kill' ) {
            this.cache.msg += '\nStylint: Over Error or Warning Limit.'
        }
        else if ( this.cache.errs.length === 0 &amp;&amp;
            this.cache.warnings.length === 0 ) {
            this.cache.msg = ''
        }

        return this.done()
    }

    var file = chalk.underline( this.cache.file )
    var col = typeof this.cache.col === 'number' &amp;&amp; this.cache.col > 0 ? this.cache.col : null

    var severity = this.state.severity.toLowerCase()
    severity = severity === 'warning' ?
        chalk.yellow( severity ) :
        chalk.red( severity )

    var rule = chalk.grey( this.cache.rule )

    // normal error or warning messages
    var defaultMessage = file + '\n' + this.cache.lineNo + ' ' + rule + ' ' + severity + ' ' + msg

    // if column data available, output slightly different line
    if ( typeof this.cache.col === 'number' &amp;&amp; this.cache.col > -1 ) {
        defaultMessage = file + '\n' + this.cache.lineNo + ':' + this.cache.col + ' ' + rule + ' ' + severity + ' ' + msg
    }

    // weird syntax highlighting issue when this is inside a ternary
    var linePlusCol = this.cache.lineNo + ':' + col
    var messageObj = {
        file: file,
        lineData: col ? linePlusCol : this.cache.lineNo,
        severity: severity,
        description: msg,
        rule: rule
    }

    messageObj[file] = true
    this.cache.messages.push( messageObj )

    return defaultMessage
}

module.exports = reporter
</code></pre>
        </article>
    </section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#blocks">blocks</a></li><li><a href="global.html#brackets">brackets</a></li><li><a href="global.html#checkPrefix">checkPrefix</a></li><li><a href="global.html#checkPseudo">checkPseudo</a></li><li><a href="global.html#colons">colons</a></li><li><a href="global.html#colors">colors</a></li><li><a href="global.html#commaSpace">commaSpace</a></li><li><a href="global.html#commentSpace">commentSpace</a></li><li><a href="global.html#config">config</a></li><li><a href="global.html#cssLiteral">cssLiteral</a></li><li><a href="global.html#depthLimit">depthLimit</a></li><li><a href="global.html#done">done</a></li><li><a href="global.html#duplicates">duplicates</a></li><li><a href="global.html#efficient">efficient</a></li><li><a href="global.html#extendPref">extendPref</a></li><li><a href="global.html#getFiles">getFiles</a></li><li><a href="global.html#hashEnd">hashEnd</a></li><li><a href="global.html#hashStart">hashStart</a></li><li><a href="global.html#indentPref">indentPref</a></li><li><a href="global.html#init">init</a></li><li><a href="global.html#keyframesEnd">keyframesEnd</a></li><li><a href="global.html#keyframesStart">keyframesStart</a></li><li><a href="global.html#leadingZero">leadingZero</a></li><li><a href="global.html#lint">lint</a></li><li><a href="global.html#mixed">mixed</a></li><li><a href="global.html#msg">msg</a></li><li><a href="global.html#namingConvention">namingConvention</a></li><li><a href="global.html#noImportant">noImportant</a></li><li><a href="global.html#none">none</a></li><li><a href="global.html#parenSpace">parenSpace</a></li><li><a href="global.html#parse">parse</a></li><li><a href="global.html#placeholders">placeholders</a></li><li><a href="global.html#prefixVarsWithDollar">prefixVarsWithDollar</a></li><li><a href="global.html#quotePref">quotePref</a></li><li><a href="global.html#read">read</a></li><li><a href="global.html#reporter">reporter</a></li><li><a href="global.html#resetOnChange">resetOnChange</a></li><li><a href="global.html#rootEnd">rootEnd</a></li><li><a href="global.html#rootStart">rootStart</a></li><li><a href="global.html#semicolons">semicolons</a></li><li><a href="global.html#setConfig">setConfig</a></li><li><a href="global.html#setContext">setContext</a></li><li><a href="global.html#setState">setState</a></li><li><a href="global.html#sortOrder">sortOrder</a></li><li><a href="global.html#splitAndStrip">splitAndStrip</a></li><li><a href="global.html#stackedProperties">stackedProperties</a></li><li><a href="global.html#startsWithComment">startsWithComment</a></li><li><a href="global.html#state">state</a></li><li><a href="global.html#stylintOff">stylintOff</a></li><li><a href="global.html#stylintOn">stylintOn</a></li><li><a href="global.html#trailingWhitespace">trailingWhitespace</a></li><li><a href="global.html#trimLine">trimLine</a></li><li><a href="global.html#universal">universal</a></li><li><a href="global.html#watch">watch</a></li><li><a href="global.html#zeroUnits">zeroUnits</a></li><li><a href="global.html#zIndexNormalize">zIndexNormalize</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.2</a> on Sun Oct 09 2016 22:18:45 GMT+0200 (CEST)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>