or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-jshint-stylish

Stylish reporter for JSHint that enhances output formatting with colorized syntax highlighting and organized table layout

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/jshint-stylish@2.2.x

To install, run

npx @tessl/cli install tessl/npm-jshint-stylish@2.2.0

index.mddocs/

JSHint Stylish

JSHint 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.

Package Information

  • Package Name: jshint-stylish
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install --save-dev jshint-stylish

Core Imports

const 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');

Basic Usage

JSHint CLI Integration

$ jshint --reporter=node_modules/jshint-stylish file.js

Gulp Integration

const gulp = require('gulp');
const jshint = require('gulp-jshint');

gulp.task('lint', () =>
  gulp.src(['src/**/*.js'])
    .pipe(jshint('.jshintrc'))
    .pipe(jshint.reporter('jshint-stylish'))
);

Grunt Integration

grunt.initConfig({
  jshint: {
    options: {
      reporter: require('jshint-stylish')
    },
    target: ['src/**/*.js']
  }
});

Capabilities

Reporter Function

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 });
  }
});

Module Identification

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();

Types

Result Object Structure

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;
  };
}

Options Object

Configuration options for the reporter function:

interface ReporterOptions {
  /** Enable system bell sound for warnings/errors */
  beep?: boolean;
  /** Include error codes in output */
  verbose?: boolean;
}

Output Features

  • Colorized Output: Errors in red, warnings in blue, file paths underlined
  • Table Format: Organized columns for line numbers, column numbers, and messages
  • Visual Symbols: Cross-platform symbols for errors, warnings, and success
  • Summary Statistics: Count of errors and warnings (note: warning pluralization uses total count)
  • File Grouping: Results grouped by file with clear separation
  • System Bell: Optional audio notification for issues (when beep: true)
  • Verbose Mode: Optional error code display (when verbose: true)

Integration Notes

  • JSHint CLI: Use with --reporter flag pointing to the module path
  • Gulp: Works with gulp-jshint plugin via reporter name string
  • Grunt: Works with grunt-contrib-jshint by requiring the module
  • Build Tools: Compatible with any tool that supports JSHint custom reporters
  • Zero Configuration: Works out of the box with default settings