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
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

index.mddocs/

@umijs/lint

@umijs/lint is a comprehensive linting solution for JavaScript and TypeScript projects within the Umi.js ecosystem. It combines ESLint for JavaScript/TypeScript code analysis with Stylelint for CSS preprocessing, offering a unified interface to lint both code and styles with intelligent file filtering and extensive configuration options.

Package Information

  • Package Name: @umijs/lint
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install @umijs/lint

Core Imports

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

Basic Usage

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

// Lint both JavaScript/TypeScript and CSS files
lint(
  { cwd: process.cwd() },
  { 
    _: ["src/**/*"], 
    fix: true 
  }
);

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

// Lint only CSS files
lint(
  { cwd: process.cwd() },
  { 
    _: ["src/**/*.{css,less,scss}"], 
    stylelintOnly: true,
    fix: true 
  }
);

Architecture

@umijs/lint is built around several key components:

  • Unified Interface: Single function that orchestrates both ESLint and Stylelint execution
  • Smart File Filtering: Automatic exclusion of inappropriate file types for each linter
  • Linter Classes: Object-oriented wrappers around ESLint and Stylelint binaries
  • Configuration System: Pre-configured rules for React, TypeScript, and modern CSS
  • Process Management: Child process execution with proper exit code handling

Capabilities

Main Linting Function

The primary interface for running linters with automatic file filtering and dual-linter coordination.

/**
 * Main linting function that runs ESLint and/or Stylelint based on provided arguments
 * @param opts - Linter configuration options
 * @param args - Linting command-line arguments and flags
 */
export default function lint(opts: ILinterOpts, args: ILintArgs): void;

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

Main Linting Interface

ESLint Configuration

Pre-configured ESLint setup with React, TypeScript, and Jest support, plus legacy fabric configuration compatibility. These configurations can be used directly in ESLint config files.

// .eslintrc.js
module.exports = require("@umijs/lint/dist/config/eslint");

// Legacy configuration
module.exports = require("@umijs/lint/dist/config/eslint/legacy");

ESLint Configuration

Stylelint Configuration

Pre-configured Stylelint setup with CSS modules, Prettier integration, and CSS-in-JS support. This configuration can be used directly in Stylelint config files.

// stylelint.config.js  
module.exports = require("@umijs/lint/dist/config/stylelint");

Stylelint Configuration

docs

eslint-config.md

index.md

main-interface.md

stylelint-config.md

tile.json