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.00
# @umijs/lint
1
2
@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.
3
4
## Package Information
5
6
- **Package Name**: @umijs/lint
7
- **Package Type**: npm
8
- **Language**: TypeScript
9
- **Installation**: `npm install @umijs/lint`
10
11
## Core Imports
12
13
```typescript
14
import lint from "@umijs/lint";
15
import type { ILintArgs, ILinterOpts } from "@umijs/lint";
16
```
17
18
## Basic Usage
19
20
```typescript
21
import lint from "@umijs/lint";
22
import type { ILintArgs, ILinterOpts } from "@umijs/lint";
23
24
// Lint both JavaScript/TypeScript and CSS files
25
lint(
26
{ cwd: process.cwd() },
27
{
28
_: ["src/**/*"],
29
fix: true
30
}
31
);
32
33
// Lint only JavaScript/TypeScript files
34
lint(
35
{ cwd: process.cwd() },
36
{
37
_: ["src/**/*.{js,ts,jsx,tsx}"],
38
eslintOnly: true,
39
fix: true
40
}
41
);
42
43
// Lint only CSS files
44
lint(
45
{ cwd: process.cwd() },
46
{
47
_: ["src/**/*.{css,less,scss}"],
48
stylelintOnly: true,
49
fix: true
50
}
51
);
52
```
53
54
## Architecture
55
56
@umijs/lint is built around several key components:
57
58
- **Unified Interface**: Single function that orchestrates both ESLint and Stylelint execution
59
- **Smart File Filtering**: Automatic exclusion of inappropriate file types for each linter
60
- **Linter Classes**: Object-oriented wrappers around ESLint and Stylelint binaries
61
- **Configuration System**: Pre-configured rules for React, TypeScript, and modern CSS
62
- **Process Management**: Child process execution with proper exit code handling
63
64
## Capabilities
65
66
### Main Linting Function
67
68
The primary interface for running linters with automatic file filtering and dual-linter coordination.
69
70
```typescript { .api }
71
/**
72
* Main linting function that runs ESLint and/or Stylelint based on provided arguments
73
* @param opts - Linter configuration options
74
* @param args - Linting command-line arguments and flags
75
*/
76
export default function lint(opts: ILinterOpts, args: ILintArgs): void;
77
78
interface ILinterOpts {
79
/** Current working directory for linting operations */
80
cwd: string;
81
}
82
83
interface ILintArgs {
84
/** Array of file patterns/paths to lint */
85
_: string[];
86
/** Optional flag to suppress non-error output */
87
quiet?: boolean;
88
/** Optional flag to automatically fix linting issues */
89
fix?: boolean;
90
/** Optional flag to run only ESLint (skip Stylelint) */
91
eslintOnly?: boolean;
92
/** Optional flag to run only Stylelint (skip ESLint) */
93
stylelintOnly?: boolean;
94
/** Optional flag to enable CSS-in-JS linting for Stylelint */
95
cssinjs?: boolean;
96
}
97
```
98
99
[Main Linting Interface](./main-interface.md)
100
101
### ESLint Configuration
102
103
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.
104
105
```javascript { .api }
106
// .eslintrc.js
107
module.exports = require("@umijs/lint/dist/config/eslint");
108
109
// Legacy configuration
110
module.exports = require("@umijs/lint/dist/config/eslint/legacy");
111
```
112
113
[ESLint Configuration](./eslint-config.md)
114
115
### Stylelint Configuration
116
117
Pre-configured Stylelint setup with CSS modules, Prettier integration, and CSS-in-JS support. This configuration can be used directly in Stylelint config files.
118
119
```javascript { .api }
120
// stylelint.config.js
121
module.exports = require("@umijs/lint/dist/config/stylelint");
122
```
123
124
[Stylelint Configuration](./stylelint-config.md)