CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-umijs--lint

Comprehensive linting solution for JavaScript and TypeScript projects combining ESLint and Stylelint with unified interface

Pending
Overview
Eval results
Files

main-interface.mddocs/

Main Linting Interface

The primary interface for running linters with automatic file filtering and dual-linter coordination. This function serves as the main entry point that orchestrates both ESLint and Stylelint execution.

Capabilities

Default Export Function

The main linting function that intelligently runs ESLint and/or Stylelint based on provided arguments.

/**
 * Main linting function that runs ESLint and/or Stylelint based on provided arguments
 * Automatically excludes inappropriate file types for each linter
 * @param opts - Linter configuration options including working directory
 * @param args - Linting command-line arguments and control flags
 */
export default function lint(opts: ILinterOpts, args: ILintArgs): void;

Behavior:

  • Runs both ESLint and Stylelint by default
  • Automatically excludes JavaScript/TypeScript files from Stylelint (unless cssinjs is true)
  • Automatically excludes CSS/style files from ESLint
  • Respects eslintOnly and stylelintOnly flags for selective execution
  • Manages child process exit codes properly

Usage Examples:

import lint from "@umijs/lint";
import type { ILintArgs, ILinterOpts } from "@umijs/lint";

// Basic usage - lint all files with both linters
lint(
  { cwd: process.cwd() },
  { _: ["src/**/*"] }
);

// Lint with auto-fix enabled
lint(
  { cwd: process.cwd() },
  { 
    _: ["src/**/*"], 
    fix: true,
    quiet: true
  }
);

// Lint only TypeScript files with ESLint
lint(
  { cwd: process.cwd() },
  { 
    _: ["src/**/*.{ts,tsx}"], 
    eslintOnly: true 
  }
);

// Lint CSS files including CSS-in-JS
lint(
  { cwd: process.cwd() },
  { 
    _: ["src/**/*.{css,less,tsx}"], 
    stylelintOnly: true,
    cssinjs: true
  }
);

Intelligent File Filtering

The main function implements smart file filtering to prevent cross-linting:

For Stylelint:

  • When cssinjs is false (default): Excludes all JavaScript/TypeScript files
  • When cssinjs is true: Allows JavaScript/TypeScript files for CSS-in-JS linting
  • Always includes CSS, Less, Sass, SCSS, and Stylus files

For ESLint:

  • Always excludes CSS/style files to prevent parsing errors
  • Includes JavaScript, JSX, TypeScript, and TSX files

Error Handling:

  • Child process exit codes are properly propagated
  • Linter binary resolution failures throw descriptive errors
  • Process execution errors are handled gracefully

Types

interface ILinterOpts {
  /** Current working directory for linting operations */
  cwd: string;
}

interface ILintArgs {
  /** Array of file patterns/paths to lint */
  _: string[];
  /** Optional flag to suppress non-error output */
  quiet?: boolean;
  /** Optional flag to automatically fix linting issues */
  fix?: boolean;
  /** Optional flag to run only ESLint (skip Stylelint) */
  eslintOnly?: boolean;
  /** Optional flag to run only Stylelint (skip ESLint) */
  stylelintOnly?: boolean;
  /** Optional flag to enable CSS-in-JS linting for Stylelint */
  cssinjs?: boolean;
}

Install with Tessl CLI

npx tessl i tessl/npm-umijs--lint

docs

eslint-config.md

index.md

main-interface.md

stylelint-config.md

tile.json