Comprehensive linting solution for JavaScript and TypeScript projects combining ESLint and Stylelint with unified interface
npx @tessl/cli install tessl/npm-umijs--lint@4.4.0@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.
npm install @umijs/lintimport lint from "@umijs/lint";
import type { ILintArgs, ILinterOpts } from "@umijs/lint";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
}
);@umijs/lint is built around several key components:
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;
}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");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");