eslint-config-typed 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +499 -0
- package/dist/types/rules/index.d.mts +0 -1
- package/dist/types/rules/index.d.mts.map +1 -1
- package/package.json +1 -1
- package/src/types/rules/index.mts +0 -1
- package/dist/types/rules/eslint-deprecation-rules.d.mts +0 -21
- package/dist/types/rules/eslint-deprecation-rules.d.mts.map +0 -1
- package/dist/types/rules/eslint-deprecation-rules.mjs +0 -2
- package/dist/types/rules/eslint-deprecation-rules.mjs.map +0 -1
- package/src/types/rules/eslint-deprecation-rules.mts +0 -22
package/README.md
CHANGED
|
@@ -4,3 +4,502 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/eslint-config-typed)
|
|
5
5
|
[](./LICENSE)
|
|
6
6
|
[](https://codecov.io/gh/noshiro-pf/eslint-config-typed)
|
|
7
|
+
|
|
8
|
+
A comprehensive ESLint configuration package with strongly-typed rule definitions and pre-configured setups for TypeScript, React, testing frameworks, and more.
|
|
9
|
+
|
|
10
|
+
## Table of Contents
|
|
11
|
+
|
|
12
|
+
- [Features](#features)
|
|
13
|
+
- [Requirements](#requirements)
|
|
14
|
+
- [Installation](#installation)
|
|
15
|
+
- [Quick Start](#quick-start)
|
|
16
|
+
- [Configuration Examples](#configuration-examples)
|
|
17
|
+
- [TypeScript + React Project](#typescript--react-project)
|
|
18
|
+
- [Node.js TypeScript Project](#nodejs-typescript-project)
|
|
19
|
+
- [React + Testing Libraries](#react--testing-libraries)
|
|
20
|
+
- [VS Code Integration](#vs-code-integration)
|
|
21
|
+
- [API Reference](#api-reference)
|
|
22
|
+
- [Configuration Functions](#configuration-functions)
|
|
23
|
+
- [Rule Collections](#rule-collections)
|
|
24
|
+
- [Utility Exports](#utility-exports)
|
|
25
|
+
- [Custom Plugins](#custom-plugins)
|
|
26
|
+
- [Custom Rules](#custom-rules)
|
|
27
|
+
- [Type Definitions](#type-definitions)
|
|
28
|
+
- [Customization](#customization)
|
|
29
|
+
- [Override Specific Rules](#override-specific-rules)
|
|
30
|
+
- [Use Type-Safe Rule Options](#use-type-safe-rule-options)
|
|
31
|
+
- [Target Specific Files](#target-specific-files)
|
|
32
|
+
- [Troubleshooting](#troubleshooting)
|
|
33
|
+
- [Contributing](#contributing)
|
|
34
|
+
- [License](#license)
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
- 🎯 **Type-Safe Configuration**: Fully typed ESLint rules and configurations for better IDE support
|
|
39
|
+
- 📦 **Pre-configured Setups**: Ready-to-use configurations for TypeScript, React, Preact, and popular testing frameworks
|
|
40
|
+
- 🔧 **Custom Rules**: Additional custom ESLint rules for enhanced code quality
|
|
41
|
+
- 🚀 **Zero Configuration**: Works out of the box with sensible defaults
|
|
42
|
+
- 🔄 **ESLint Flat Config Support**: Built for the modern ESLint flat configuration system
|
|
43
|
+
- 📝 **Comprehensive Type Definitions**: Complete TypeScript types for all ESLint rules and options
|
|
44
|
+
|
|
45
|
+
## Requirements
|
|
46
|
+
|
|
47
|
+
- Node.js >= 18.0.0
|
|
48
|
+
- ESLint >= 9.0.0
|
|
49
|
+
- TypeScript >= 5.0.0 (for TypeScript projects)
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
npm install --save-dev eslint-config-typed
|
|
55
|
+
# or
|
|
56
|
+
yarn add -D eslint-config-typed
|
|
57
|
+
# or
|
|
58
|
+
pnpm add -D eslint-config-typed
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
All required ESLint plugins and dependencies are automatically installed.
|
|
62
|
+
|
|
63
|
+
## Quick Start
|
|
64
|
+
|
|
65
|
+
Create an `eslint.config.js` file in your project root:
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
import {
|
|
69
|
+
eslintFlatConfigForTypeScript,
|
|
70
|
+
eslintFlatConfigForVitest,
|
|
71
|
+
} from 'eslint-config-typed';
|
|
72
|
+
import * as path from 'node:path';
|
|
73
|
+
import * as url from 'node:url';
|
|
74
|
+
|
|
75
|
+
const thisDir = import.meta.dirname;
|
|
76
|
+
// or path.dirname(url.fileURLToPath(import.meta.url));
|
|
77
|
+
|
|
78
|
+
/** @returns {readonly import('eslint-config-typed').FlatConfig[]} */
|
|
79
|
+
const defineConfig = () => [
|
|
80
|
+
{
|
|
81
|
+
// config with just ignores is the replacement for `.eslintignore`
|
|
82
|
+
ignores: ['**/build/**', '**/dist/**', 'src/some/file/to/ignore.ts'],
|
|
83
|
+
},
|
|
84
|
+
...eslintFlatConfigForTypeScript({
|
|
85
|
+
tsconfigRootDir: thisDir,
|
|
86
|
+
tsconfigFileName: './tsconfig.json',
|
|
87
|
+
packageDirs: [path.resolve(thisDir, '../../..'), thisDir],
|
|
88
|
+
}),
|
|
89
|
+
...eslintFlatConfigForReact(),
|
|
90
|
+
eslintFlatConfigForVitest(),
|
|
91
|
+
|
|
92
|
+
// You can override per-rule settings if necessary.
|
|
93
|
+
{
|
|
94
|
+
rules: {
|
|
95
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
96
|
+
'@typescript-eslint/prefer-readonly-parameter-types': 'off',
|
|
97
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
98
|
+
'functional/no-let': ['error', noLetOptions],
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
/** @type {import('eslint-config-typed').EslintFunctionalRulesOption['functional/no-let']} */
|
|
104
|
+
const noLetOptions = {
|
|
105
|
+
allowInForLoopInit: false,
|
|
106
|
+
allowInFunctions: false,
|
|
107
|
+
ignoreIdentifierPattern: ignorePattern.filter((p) => p !== '^draft'),
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default defineConfig();
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Add a lint script to your `package.json`:
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"scripts": {
|
|
118
|
+
"lint": "eslint './src/**/*'",
|
|
119
|
+
"lint:fix": "eslint './src/**/*' --fix"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Run the linter:
|
|
125
|
+
|
|
126
|
+
```sh
|
|
127
|
+
npm run lint
|
|
128
|
+
# or auto-fix issues
|
|
129
|
+
npm run lint:fix
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Configuration Examples
|
|
133
|
+
|
|
134
|
+
### TypeScript + React Project
|
|
135
|
+
|
|
136
|
+
```js
|
|
137
|
+
import {
|
|
138
|
+
eslintFlatConfigForTypeScript,
|
|
139
|
+
eslintFlatConfigForReact,
|
|
140
|
+
} from 'eslint-config-typed';
|
|
141
|
+
import * as path from 'node:path';
|
|
142
|
+
import * as url from 'node:url';
|
|
143
|
+
|
|
144
|
+
const thisDir = import.meta.dirname;
|
|
145
|
+
|
|
146
|
+
export default [
|
|
147
|
+
{ ignores: ['**/dist/**', '**/build/**', '**/.next/**'] },
|
|
148
|
+
...eslintFlatConfigForTypeScript({
|
|
149
|
+
tsconfigRootDir: thisDir,
|
|
150
|
+
tsconfigFileName: './tsconfig.json',
|
|
151
|
+
packageDirs: [thisDir],
|
|
152
|
+
}),
|
|
153
|
+
...eslintFlatConfigForReact(),
|
|
154
|
+
];
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Node.js TypeScript Project
|
|
158
|
+
|
|
159
|
+
```js
|
|
160
|
+
import { eslintFlatConfigForTypeScript } from 'eslint-config-typed';
|
|
161
|
+
import * as path from 'node:path';
|
|
162
|
+
import * as url from 'node:url';
|
|
163
|
+
|
|
164
|
+
const thisDir = import.meta.dirname;
|
|
165
|
+
|
|
166
|
+
export default [
|
|
167
|
+
{ ignores: ['**/dist/**', '**/node_modules/**'] },
|
|
168
|
+
...eslintFlatConfigForTypeScript({
|
|
169
|
+
tsconfigRootDir: thisDir,
|
|
170
|
+
tsconfigFileName: './tsconfig.json',
|
|
171
|
+
packageDirs: [thisDir],
|
|
172
|
+
}),
|
|
173
|
+
{
|
|
174
|
+
rules: {
|
|
175
|
+
// Allow console in Node.js
|
|
176
|
+
'no-console': 'off',
|
|
177
|
+
// Allow process.env access
|
|
178
|
+
'no-process-env': 'off',
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
];
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### React + Testing Libraries
|
|
185
|
+
|
|
186
|
+
```js
|
|
187
|
+
import {
|
|
188
|
+
eslintFlatConfigForTypeScript,
|
|
189
|
+
eslintFlatConfigForReact,
|
|
190
|
+
eslintFlatConfigForVitest,
|
|
191
|
+
eslintFlatConfigForTestingLibrary,
|
|
192
|
+
} from 'eslint-config-typed';
|
|
193
|
+
import * as path from 'node:path';
|
|
194
|
+
import * as url from 'node:url';
|
|
195
|
+
|
|
196
|
+
const thisDir = import.meta.dirname;
|
|
197
|
+
|
|
198
|
+
export default [
|
|
199
|
+
{ ignores: ['**/dist/**', '**/coverage/**'] },
|
|
200
|
+
...eslintFlatConfigForTypeScript({
|
|
201
|
+
tsconfigRootDir: thisDir,
|
|
202
|
+
tsconfigFileName: './tsconfig.json',
|
|
203
|
+
packageDirs: [thisDir],
|
|
204
|
+
}),
|
|
205
|
+
...eslintFlatConfigForReact(),
|
|
206
|
+
eslintFlatConfigForVitest(),
|
|
207
|
+
eslintFlatConfigForTestingLibrary(),
|
|
208
|
+
];
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## VS Code Integration
|
|
212
|
+
|
|
213
|
+
Add the following to `.vscode/settings.json` for proper ESLint integration:
|
|
214
|
+
|
|
215
|
+
```json
|
|
216
|
+
{
|
|
217
|
+
"eslint.workingDirectories": [
|
|
218
|
+
{
|
|
219
|
+
"mode": "auto"
|
|
220
|
+
}
|
|
221
|
+
],
|
|
222
|
+
"eslint.experimental.useFlatConfig": true,
|
|
223
|
+
"editor.codeActionsOnSave": {
|
|
224
|
+
"source.fixAll.eslint": "explicit"
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## API Reference
|
|
230
|
+
|
|
231
|
+
### Configuration Functions
|
|
232
|
+
|
|
233
|
+
These functions return arrays of ESLint flat configurations:
|
|
234
|
+
|
|
235
|
+
#### Framework Configurations
|
|
236
|
+
|
|
237
|
+
- **`eslintFlatConfigForTypeScript(options)`** - TypeScript configuration with strict type checking rules
|
|
238
|
+
- `options.tsconfigRootDir`: Root directory containing tsconfig.json
|
|
239
|
+
- `options.tsconfigFileName`: Path to tsconfig.json file
|
|
240
|
+
- `options.packageDirs`: Array of package directories for import resolution
|
|
241
|
+
- **`eslintFlatConfigForReact(options?)`** - React configuration with hooks and JSX rules
|
|
242
|
+
- **`eslintFlatConfigForPreact(options?)`** - Preact configuration (lighter React alternative)
|
|
243
|
+
- **`eslintFlatConfigForReactBase(options?)`** - Base React configuration without specific framework rules
|
|
244
|
+
|
|
245
|
+
#### Testing Framework Configurations
|
|
246
|
+
|
|
247
|
+
- **`eslintFlatConfigForVitest(options?)`** - Vitest testing framework configuration
|
|
248
|
+
- **`eslintFlatConfigForJest(options?)`** - Jest testing framework configuration
|
|
249
|
+
- **`eslintFlatConfigForCypress(options?)`** - Cypress E2E testing configuration
|
|
250
|
+
- **`eslintFlatConfigForPlaywright(options?)`** - Playwright E2E testing configuration
|
|
251
|
+
- **`eslintFlatConfigForTestingLibrary(options?)`** - Testing Library configuration
|
|
252
|
+
|
|
253
|
+
#### Utility Configurations
|
|
254
|
+
|
|
255
|
+
- **`eslintFlatConfigForTypeScriptWithoutRules(options)`** - TypeScript parser setup without any rules
|
|
256
|
+
|
|
257
|
+
### Rule Collections
|
|
258
|
+
|
|
259
|
+
Pre-configured rule sets that can be imported and customized:
|
|
260
|
+
|
|
261
|
+
- **`eslintRules`** - Core ESLint rules
|
|
262
|
+
- **`typescriptEslintRules`** - TypeScript-specific ESLint rules
|
|
263
|
+
- **`eslintReactRules`** - React-specific rules
|
|
264
|
+
- **`eslintReactHooksRules`** - React Hooks rules
|
|
265
|
+
- **`eslintReactPerfRules`** - React performance optimization rules
|
|
266
|
+
- **`eslintReactRefreshRules`** - React Refresh (HMR) rules
|
|
267
|
+
- **`eslintJsxA11yRules`** - Accessibility rules for JSX
|
|
268
|
+
- **`eslintFunctionalRules`** - Functional programming style rules
|
|
269
|
+
- **`eslintImportsRules`** - Import/export rules
|
|
270
|
+
- **`eslintUnicornRules`** - Unicorn plugin rules for better code
|
|
271
|
+
- **`eslintPromiseRules`** - Promise handling rules
|
|
272
|
+
- **`eslintSecurityRules`** - Security best practices
|
|
273
|
+
- **`eslintArrayFuncRules`** - Array function preference rules
|
|
274
|
+
- **`eslintPreferArrowFunctionRules`** - Arrow function preference rules
|
|
275
|
+
- **`eslintTotalFunctionsRules`** - Total functions (no partial functions) rules
|
|
276
|
+
- **`eslintTreeShakableRules`** - Tree-shaking optimization rules
|
|
277
|
+
- **`eslintVitestRules`** - Vitest-specific rules
|
|
278
|
+
- **`eslintJestRules`** - Jest-specific rules
|
|
279
|
+
- **`eslintCypressRules`** - Cypress-specific rules
|
|
280
|
+
- **`eslintPlaywrightRules`** - Playwright-specific rules
|
|
281
|
+
- **`eslintTestingLibraryRules`** - Testing Library rules
|
|
282
|
+
- **`eslintStrictDependenciesRules`** - Strict dependency checking rules
|
|
283
|
+
- **`eslintPluginRules`** - Additional plugin rules
|
|
284
|
+
|
|
285
|
+
### Utility Exports
|
|
286
|
+
|
|
287
|
+
- **`restrictedSyntax`** - Array of restricted JavaScript syntax patterns
|
|
288
|
+
- **`restrictedGlobals`** - Array of restricted global variables
|
|
289
|
+
- **`restrictedGlobalsForFrontend`** - Frontend-specific restricted globals
|
|
290
|
+
- **`restrictedImportsOption`** - Configuration for restricted imports
|
|
291
|
+
- **`banTypes`** - TypeScript types that should be banned
|
|
292
|
+
- **`ignoredMutablePattern`** - Patterns for allowed mutable variables
|
|
293
|
+
- **`immutableDataOptions`** - Options for functional/immutable-data rule
|
|
294
|
+
- **`noLetOptions`** - Options for functional/no-let rule
|
|
295
|
+
|
|
296
|
+
### Custom Plugins
|
|
297
|
+
|
|
298
|
+
- **`eslintPluginCustom`** - Custom ESLint plugin with additional rules
|
|
299
|
+
- **`eslintPluginTotalFunctions`** - Plugin for enforcing total functions
|
|
300
|
+
- **`eslintPluginTreeShakable`** - Plugin for tree-shaking optimizations
|
|
301
|
+
- **`plugins`** - Collection of all available plugins
|
|
302
|
+
|
|
303
|
+
### Custom Rules
|
|
304
|
+
|
|
305
|
+
- **`noRestrictedSyntax`** - Enhanced restricted syntax rule
|
|
306
|
+
- **`importStarRule`** - Rule for controlling import \* usage
|
|
307
|
+
- **`noUnsafeOptionalPropertyAssignment`** - Prevent unsafe optional property assignments
|
|
308
|
+
- **`noPrematureFpTsEffects`** - Prevent premature fp-ts effect usage
|
|
309
|
+
- **`noPartialStringNormalize`** - Prevent partial string normalization
|
|
310
|
+
- **`noUnsafeMutableReadonlyAssignment`** - Prevent unsafe mutable/readonly assignments
|
|
311
|
+
- **`noPartialDivision`** - Prevent division by zero possibilities
|
|
312
|
+
- **`requireStrictMode`** - Enforce strict mode
|
|
313
|
+
- **`noEnums`** - Disallow TypeScript enums
|
|
314
|
+
- **`noPartialUrlConstructor`** - Prevent partial URL constructor usage
|
|
315
|
+
- **`noUnsafeTypeAssertion`** - Prevent unsafe type assertions
|
|
316
|
+
- **`noUnsafeEnumAssignment`** - Prevent unsafe enum assignments
|
|
317
|
+
- **`noUnsafeReadonlyMutableAssignment`** - Prevent readonly/mutable mismatches
|
|
318
|
+
- **`noNestedFpTsEffects`** - Prevent nested fp-ts effects
|
|
319
|
+
- **`noPartialArrayReduce`** - Prevent partial array reduce operations
|
|
320
|
+
- **`noHiddenTypeAssertions`** - Prevent hidden type assertions
|
|
321
|
+
|
|
322
|
+
### Type Definitions
|
|
323
|
+
|
|
324
|
+
All rules and configurations come with complete TypeScript type definitions:
|
|
325
|
+
|
|
326
|
+
#### Core Types
|
|
327
|
+
|
|
328
|
+
- **`FlatConfig`** - ESLint flat configuration type
|
|
329
|
+
- **`ESLintPlugin`** - ESLint plugin type
|
|
330
|
+
- **`Rule`** - ESLint rule definition type
|
|
331
|
+
- **`Rules`** - Collection of rules type
|
|
332
|
+
- **`RestrictedImportsOption`** - Type for restricted imports configuration
|
|
333
|
+
|
|
334
|
+
#### Rule Types
|
|
335
|
+
|
|
336
|
+
Each plugin provides typed rule definitions:
|
|
337
|
+
|
|
338
|
+
- **`EslintRules`** & **`EslintRulesOption`**
|
|
339
|
+
- **`TypeScriptEslintRules`** & **`TypeScriptEslintRulesOption`**
|
|
340
|
+
- **`EslintReactRules`** & **`EslintReactRulesOption`**
|
|
341
|
+
- **`EslintReactHooksRules`** & **`EslintReactHooksRulesOption`**
|
|
342
|
+
- **`EslintReactPerfRules`** & **`EslintReactPerfRulesOption`**
|
|
343
|
+
- **`EslintReactRefreshRules`** & **`EslintReactRefreshRulesOption`**
|
|
344
|
+
- **`EslintJsxA11yRules`** & **`EslintJsxA11yRulesOption`**
|
|
345
|
+
- **`EslintFunctionalRules`** & **`EslintFunctionalRulesOption`**
|
|
346
|
+
- **`EslintImportsRules`** & **`EslintImportsRulesOption`**
|
|
347
|
+
- **`EslintUnicornRules`** & **`EslintUnicornRulesOption`**
|
|
348
|
+
- **`EslintPromiseRules`** & **`EslintPromiseRulesOption`**
|
|
349
|
+
- **`EslintSecurityRules`** (no options)
|
|
350
|
+
- **`EslintArrayFuncRules`** (no options)
|
|
351
|
+
- **`EslintPreferArrowFunctionRules`** & **`EslintPreferArrowFunctionRulesOption`**
|
|
352
|
+
- **`EslintTotalFunctionsRules`** (no options)
|
|
353
|
+
- **`EslintTreeShakableRules`** (no options)
|
|
354
|
+
- **`EslintVitestRules`** & **`EslintVitestRulesOption`**
|
|
355
|
+
- **`EslintJestRules`** & **`EslintJestRulesOption`**
|
|
356
|
+
- **`EslintCypressRules`** & **`EslintCypressRulesOption`**
|
|
357
|
+
- **`EslintPlaywrightRules`** & **`EslintPlaywrightRulesOption`**
|
|
358
|
+
- **`EslintTestingLibraryRules`** & **`EslintTestingLibraryRulesOption`**
|
|
359
|
+
- **`EslintStrictDependenciesRules`** & **`EslintStrictDependenciesRulesOption`**
|
|
360
|
+
- **`EslintPluginRules`** & **`EslintPluginRulesOption`**
|
|
361
|
+
- **`EslintDeprecationRules`** (no options)
|
|
362
|
+
|
|
363
|
+
## Customization
|
|
364
|
+
|
|
365
|
+
### Override Specific Rules
|
|
366
|
+
|
|
367
|
+
You can override any rule by adding a configuration object after the preset configurations:
|
|
368
|
+
|
|
369
|
+
```js
|
|
370
|
+
export default [
|
|
371
|
+
...eslintFlatConfigForTypeScript(options),
|
|
372
|
+
{
|
|
373
|
+
rules: {
|
|
374
|
+
// Downgrade to warning
|
|
375
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
376
|
+
// Disable a rule
|
|
377
|
+
'@typescript-eslint/prefer-readonly-parameter-types': 'off',
|
|
378
|
+
// Configure with options
|
|
379
|
+
'functional/no-let': [
|
|
380
|
+
'error',
|
|
381
|
+
{
|
|
382
|
+
allowInForLoopInit: true,
|
|
383
|
+
allowInFunctions: false,
|
|
384
|
+
},
|
|
385
|
+
],
|
|
386
|
+
},
|
|
387
|
+
},
|
|
388
|
+
];
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
### Use Type-Safe Rule Options
|
|
392
|
+
|
|
393
|
+
Leverage TypeScript for type-safe rule configuration:
|
|
394
|
+
|
|
395
|
+
```js
|
|
396
|
+
/** @type {import('eslint-config-typed').EslintFunctionalRulesOption['functional/no-let']} */
|
|
397
|
+
const noLetOptions = {
|
|
398
|
+
allowInForLoopInit: false,
|
|
399
|
+
allowInFunctions: false,
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
export default [
|
|
403
|
+
...eslintFlatConfigForTypeScript(options),
|
|
404
|
+
{
|
|
405
|
+
rules: {
|
|
406
|
+
'functional/no-let': ['error', noLetOptions],
|
|
407
|
+
},
|
|
408
|
+
},
|
|
409
|
+
];
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
### Target Specific Files
|
|
413
|
+
|
|
414
|
+
Apply different rules to different file patterns:
|
|
415
|
+
|
|
416
|
+
```js
|
|
417
|
+
export default [
|
|
418
|
+
...eslintFlatConfigForTypeScript(options),
|
|
419
|
+
{
|
|
420
|
+
files: ['**/*.test.ts', '**/*.spec.ts'],
|
|
421
|
+
rules: {
|
|
422
|
+
// Allow any in tests
|
|
423
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
424
|
+
// Allow console in tests
|
|
425
|
+
'no-console': 'off',
|
|
426
|
+
},
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
files: ['**/scripts/**/*.ts'],
|
|
430
|
+
rules: {
|
|
431
|
+
// Allow console in scripts
|
|
432
|
+
'no-console': 'off',
|
|
433
|
+
'no-process-exit': 'off',
|
|
434
|
+
},
|
|
435
|
+
},
|
|
436
|
+
];
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
## Troubleshooting
|
|
440
|
+
|
|
441
|
+
### Common Issues
|
|
442
|
+
|
|
443
|
+
#### 1. ESLint can't find tsconfig.json
|
|
444
|
+
|
|
445
|
+
Ensure the paths are correct:
|
|
446
|
+
|
|
447
|
+
```js
|
|
448
|
+
const thisDir = import.meta.dirname;
|
|
449
|
+
|
|
450
|
+
...eslintFlatConfigForTypeScript({
|
|
451
|
+
tsconfigRootDir: thisDir, // Must be absolute path
|
|
452
|
+
tsconfigFileName: './tsconfig.json', // Relative to tsconfigRootDir
|
|
453
|
+
packageDirs: [thisDir],
|
|
454
|
+
})
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
#### 2. Import resolution errors
|
|
458
|
+
|
|
459
|
+
The `packageDirs` option helps ESLint resolve imports correctly in monorepos:
|
|
460
|
+
|
|
461
|
+
```js
|
|
462
|
+
...eslintFlatConfigForTypeScript({
|
|
463
|
+
tsconfigRootDir: thisDir,
|
|
464
|
+
tsconfigFileName: './tsconfig.json',
|
|
465
|
+
packageDirs: [
|
|
466
|
+
path.resolve(thisDir, '../../..'), // Monorepo root
|
|
467
|
+
thisDir, // Current package
|
|
468
|
+
],
|
|
469
|
+
})
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
#### 3. Rule conflicts
|
|
473
|
+
|
|
474
|
+
If you encounter rule conflicts, the last configuration wins. Place your overrides after the preset configurations.
|
|
475
|
+
|
|
476
|
+
#### 4. Performance issues
|
|
477
|
+
|
|
478
|
+
For large projects, consider:
|
|
479
|
+
|
|
480
|
+
- Using `.eslintignore` or `ignores` patterns to skip generated files
|
|
481
|
+
- Running ESLint with `--cache` flag
|
|
482
|
+
- Limiting the scope of type-aware rules
|
|
483
|
+
|
|
484
|
+
### Known Limitations
|
|
485
|
+
|
|
486
|
+
- The `import/no-unused-modules` rule does not function properly with Native ESM
|
|
487
|
+
- Some type-aware rules may have performance impacts on very large codebases
|
|
488
|
+
- Flat config requires ESLint 9.0+ and may not be compatible with older tools
|
|
489
|
+
|
|
490
|
+
## Contributing
|
|
491
|
+
|
|
492
|
+
Contributions are welcome! Please check our [GitHub repository](https://github.com/noshiro-pf/eslint-config-typed) for:
|
|
493
|
+
|
|
494
|
+
- Issue reporting
|
|
495
|
+
- Feature requests
|
|
496
|
+
- Pull requests
|
|
497
|
+
|
|
498
|
+
## License
|
|
499
|
+
|
|
500
|
+
This project is licensed under the [Apache License 2.0](./LICENSE).
|
|
501
|
+
|
|
502
|
+
## Future Updates
|
|
503
|
+
|
|
504
|
+
- Enhanced support for `eslint-plugin-functional`
|
|
505
|
+
- Migration from `functional/prefer-readonly-type` to `functional/prefer-immutable-types` and `functional/type-declaration-immutability`
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './eslint-array-func-rules.mjs';
|
|
2
2
|
export * from './eslint-cypress-rules.mjs';
|
|
3
|
-
export * from './eslint-deprecation-rules.mjs';
|
|
4
3
|
export * from './eslint-functional-rules.mjs';
|
|
5
4
|
export * from './eslint-import-rules.mjs';
|
|
6
5
|
export * from './eslint-jest-rules.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/types/rules/index.mts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/types/rules/index.mts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './eslint-array-func-rules.mjs';
|
|
2
2
|
export * from './eslint-cypress-rules.mjs';
|
|
3
|
-
export * from './eslint-deprecation-rules.mjs';
|
|
4
3
|
export * from './eslint-functional-rules.mjs';
|
|
5
4
|
export * from './eslint-import-rules.mjs';
|
|
6
5
|
export * from './eslint-jest-rules.mjs';
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type Linter } from 'eslint';
|
|
2
|
-
/**
|
|
3
|
-
* Do not use deprecated APIs.
|
|
4
|
-
*
|
|
5
|
-
* @link https://github.com/gund/eslint-plugin-deprecation
|
|
6
|
-
*
|
|
7
|
-
* ```md
|
|
8
|
-
* | key | value |
|
|
9
|
-
* | :------------------- | :------ |
|
|
10
|
-
* | type | problem |
|
|
11
|
-
* | requiresTypeChecking | true |
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
declare namespace Deprecation {
|
|
15
|
-
type RuleEntry = Linter.RuleSeverity;
|
|
16
|
-
}
|
|
17
|
-
export type EslintDeprecationRules = {
|
|
18
|
-
readonly 'deprecation/deprecation': Deprecation.RuleEntry;
|
|
19
|
-
};
|
|
20
|
-
export {};
|
|
21
|
-
//# sourceMappingURL=eslint-deprecation-rules.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eslint-deprecation-rules.d.mts","sourceRoot":"","sources":["../../../src/types/rules/eslint-deprecation-rules.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;;;;;;;;;;GAWG;AACH,kBAAU,WAAW,CAAC;IACpB,KAAY,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC;CAC7C;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,yBAAyB,EAAE,WAAW,CAAC,SAAS,CAAC;CAC3D,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eslint-deprecation-rules.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/* cSpell:disable */
|
|
2
|
-
import { type Linter } from 'eslint';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Do not use deprecated APIs.
|
|
6
|
-
*
|
|
7
|
-
* @link https://github.com/gund/eslint-plugin-deprecation
|
|
8
|
-
*
|
|
9
|
-
* ```md
|
|
10
|
-
* | key | value |
|
|
11
|
-
* | :------------------- | :------ |
|
|
12
|
-
* | type | problem |
|
|
13
|
-
* | requiresTypeChecking | true |
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
namespace Deprecation {
|
|
17
|
-
export type RuleEntry = Linter.RuleSeverity;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type EslintDeprecationRules = {
|
|
21
|
-
readonly 'deprecation/deprecation': Deprecation.RuleEntry;
|
|
22
|
-
};
|