Stylish reporter for JSHint that enhances output formatting with colorized syntax highlighting and organized table layout
npx @tessl/cli install tessl/npm-jshint-stylish@2.2.0JSHint Stylish is a stylish reporter for JSHint that transforms the default lint output into an elegant, colorized format with organized table layout and visual symbols. It enhances code quality feedback readability by presenting errors and warnings in a clean, structured format with proper categorization and line/column information.
npm install --save-dev jshint-stylishconst stylish = require('jshint-stylish');For use with various JSHint integrations:
// Direct reporter reference
const reporter = require('jshint-stylish');
// Accessing specific methods
const { reporter, toString } = require('jshint-stylish');$ jshint --reporter=node_modules/jshint-stylish file.jsconst gulp = require('gulp');
const jshint = require('gulp-jshint');
gulp.task('lint', () =>
gulp.src(['src/**/*.js'])
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'))
);grunt.initConfig({
jshint: {
options: {
reporter: require('jshint-stylish')
},
target: ['src/**/*.js']
}
});The main reporter function that formats JSHint results with stylish output including colorized text, organized tables, and visual symbols. Categorizes results as errors (codes starting with 'E') or warnings (all other codes).
/**
* Main reporter function that formats JSHint results with stylish output
* @param {Array} result - Array of JSHint result objects containing error/warning data
* @param {Object} config - JSHint configuration object
* @param {Object} [options] - Reporter options
* @param {boolean} [options.beep=false] - Enable system bell sound for warnings/errors
* @param {boolean} [options.verbose=false] - Include error codes in output
* @returns {void} - Outputs formatted results directly to console via console.log
*/
function reporter(result, config, options);Usage Example:
const jshint = require('jshint/src/cli');
const stylish = require('jshint-stylish');
// Use with JSHint programmatically
jshint.run({
args: ['file.js'],
reporter: stylish.reporter
});
// With options
jshint.run({
args: ['file.js'],
reporter: (result, config) => {
stylish.reporter(result, config, { beep: true, verbose: true });
}
});Returns the filename of the module for JSHint internal identification purposes.
/**
* Returns the filename of the module for JSHint internal identification
* @returns {string} - The module's filename
*/
function toString();The result array contains objects with the following structure:
interface ResultItem {
/** File path */
file: string;
/** Error/warning details */
error: {
/** Line number where the issue occurs */
line: number;
/** Column number where the issue occurs */
character: number;
/** Error/warning message */
reason: string;
/** JSHint error code (E=Error, W=Warning, I=Info) */
code: string;
};
}Configuration options for the reporter function:
interface ReporterOptions {
/** Enable system bell sound for warnings/errors */
beep?: boolean;
/** Include error codes in output */
verbose?: boolean;
}beep: true)verbose: true)--reporter flag pointing to the module pathgulp-jshint plugin via reporter name stringgrunt-contrib-jshint by requiring the module