@borela-tech/eslint-config 2.2.2 → 2.4.0
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 +308 -19
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +3864 -811
- package/dist/index.mjs.map +1 -1
- package/jest.config.ts +19 -0
- package/package.json +15 -9
- package/vite.config.ts +41 -0
- package/bin/build +0 -9
- package/bin/lint +0 -14
- package/bin/publish +0 -12
- package/bin/test +0 -12
- package/bin/typecheck +0 -8
- package/dist/index.d.mts +0 -7
- package/src/index.ts +0 -149
- package/src/lib/ReExportDeclaration.ts +0 -5
- package/src/lib/ReplacementRange.ts +0 -4
- package/src/lib/compare.ts +0 -3
- package/src/rules/__tests__/dedent/countLeadingSpaces.ts +0 -4
- package/src/rules/__tests__/dedent/findMinIndent.ts +0 -7
- package/src/rules/__tests__/dedent/index.ts +0 -17
- package/src/rules/__tests__/dedent/interpolate.ts +0 -11
- package/src/rules/__tests__/dedent/removeEmptyPrefix.ts +0 -6
- package/src/rules/__tests__/dedent/removeEmptySuffix.ts +0 -6
- package/src/rules/__tests__/dedent/removeIndent.ts +0 -3
- package/src/rules/__tests__/importsAndReExportsAtTop.test.ts +0 -88
- package/src/rules/__tests__/individualImports.test.ts +0 -44
- package/src/rules/__tests__/individualReExports.test.ts +0 -64
- package/src/rules/__tests__/multilineUnionTypes.test.ts +0 -75
- package/src/rules/__tests__/singleLineImports.test.ts +0 -129
- package/src/rules/__tests__/singleLineReExports.test.ts +0 -100
- package/src/rules/__tests__/sortedImports.test.ts +0 -227
- package/src/rules/__tests__/sortedReExports.test.ts +0 -220
- package/src/rules/importsAndReExportsAtTop/CategorizedStatements.ts +0 -8
- package/src/rules/importsAndReExportsAtTop/StatementIndices.ts +0 -5
- package/src/rules/importsAndReExportsAtTop/categorizeStatements.ts +0 -28
- package/src/rules/importsAndReExportsAtTop/findStatementIndices.ts +0 -25
- package/src/rules/importsAndReExportsAtTop/generateSortedText.ts +0 -16
- package/src/rules/importsAndReExportsAtTop/getStatementType.ts +0 -17
- package/src/rules/importsAndReExportsAtTop/hasViolation.ts +0 -25
- package/src/rules/importsAndReExportsAtTop/index.ts +0 -45
- package/src/rules/importsAndReExportsAtTop/isImportDeclaration.ts +0 -7
- package/src/rules/importsAndReExportsAtTop/isReExport.ts +0 -12
- package/src/rules/importsAndReExportsAtTop/statementType.ts +0 -4
- package/src/rules/individualImports.ts +0 -38
- package/src/rules/individualReExports.ts +0 -51
- package/src/rules/multilineUnionTypes/createFix.ts +0 -13
- package/src/rules/multilineUnionTypes/index.ts +0 -52
- package/src/rules/multilineUnionTypes/isMultiline.ts +0 -6
- package/src/rules/singleLineImports/createFix.ts +0 -23
- package/src/rules/singleLineImports/formatAttributes.ts +0 -20
- package/src/rules/singleLineImports/formatNamed.ts +0 -9
- package/src/rules/singleLineImports/formatSpecifiers.ts +0 -32
- package/src/rules/singleLineImports/index.ts +0 -34
- package/src/rules/singleLineImports/isMultiline.ts +0 -6
- package/src/rules/singleLineReExports/createFix.ts +0 -29
- package/src/rules/singleLineReExports/index.ts +0 -48
- package/src/rules/singleLineReExports/isMultiline.ts +0 -6
- package/src/rules/sortedImports/CategorizedImport.ts +0 -8
- package/src/rules/sortedImports/ImportError.ts +0 -9
- package/src/rules/sortedImports/ImportGroup.ts +0 -6
- package/src/rules/sortedImports/ImportGroupOrder.ts +0 -9
- package/src/rules/sortedImports/areSpecifiersSorted.ts +0 -9
- package/src/rules/sortedImports/categorizeImport.ts +0 -23
- package/src/rules/sortedImports/categorizeImports.ts +0 -12
- package/src/rules/sortedImports/checkAlphabeticalSorting.ts +0 -23
- package/src/rules/sortedImports/checkGroupOrdering.ts +0 -21
- package/src/rules/sortedImports/checkSpecifiersSorting.ts +0 -21
- package/src/rules/sortedImports/createFix/buildSortedCode.ts +0 -23
- package/src/rules/sortedImports/createFix/findLastImportIndex.ts +0 -12
- package/src/rules/sortedImports/createFix/formatNamedImport.ts +0 -21
- package/src/rules/sortedImports/createFix/getReplacementRange.ts +0 -14
- package/src/rules/sortedImports/createFix/groupImportsByType.ts +0 -19
- package/src/rules/sortedImports/createFix/index.ts +0 -47
- package/src/rules/sortedImports/createFix/sortImportGroups.ts +0 -13
- package/src/rules/sortedImports/getImportGroups.ts +0 -23
- package/src/rules/sortedImports/getNamedSpecifiers.ts +0 -7
- package/src/rules/sortedImports/getSortKey.ts +0 -26
- package/src/rules/sortedImports/getSpecifierName.ts +0 -7
- package/src/rules/sortedImports/index.ts +0 -63
- package/src/rules/sortedImports/sortSpecifiersText.ts +0 -16
- package/src/rules/sortedReExports/CategorizedNamedReExport.ts +0 -6
- package/src/rules/sortedReExports/CategorizedReExport.ts +0 -26
- package/src/rules/sortedReExports/ReExportError.ts +0 -9
- package/src/rules/sortedReExports/ReExportGroup.ts +0 -5
- package/src/rules/sortedReExports/ReExportGroupOrder.ts +0 -8
- package/src/rules/sortedReExports/areSpecifiersSorted.ts +0 -9
- package/src/rules/sortedReExports/categorizeReExport.ts +0 -21
- package/src/rules/sortedReExports/categorizeReExports.ts +0 -14
- package/src/rules/sortedReExports/checkAlphabeticalSorting.ts +0 -25
- package/src/rules/sortedReExports/checkGroupOrdering.ts +0 -21
- package/src/rules/sortedReExports/checkSpecifiersSorting.ts +0 -23
- package/src/rules/sortedReExports/createFix/buildSortedCode.ts +0 -29
- package/src/rules/sortedReExports/createFix/findFirstExportIndex.ts +0 -11
- package/src/rules/sortedReExports/createFix/findLastExportIndex.ts +0 -12
- package/src/rules/sortedReExports/createFix/formatNamedReExport.ts +0 -21
- package/src/rules/sortedReExports/createFix/getReplacementRange.ts +0 -22
- package/src/rules/sortedReExports/createFix/groupReExportsByType.ts +0 -18
- package/src/rules/sortedReExports/createFix/index.ts +0 -47
- package/src/rules/sortedReExports/createFix/sortExportGroups.ts +0 -12
- package/src/rules/sortedReExports/getNamedSpecifiers.ts +0 -9
- package/src/rules/sortedReExports/getReExportGroups.ts +0 -33
- package/src/rules/sortedReExports/getSortKey.ts +0 -22
- package/src/rules/sortedReExports/getSpecifierName.ts +0 -7
- package/src/rules/sortedReExports/index.ts +0 -63
- package/src/rules/sortedReExports/isNamedReExport.ts +0 -6
- package/src/rules/sortedReExports/sortSpecifiersText.ts +0 -16
- package/tsdown.config.ts +0 -22
package/README.md
CHANGED
|
@@ -10,11 +10,32 @@ Shared ESLint configuration for Borela Tech projects.
|
|
|
10
10
|
## Features
|
|
11
11
|
|
|
12
12
|
- Preconfigured ESLint rules
|
|
13
|
-
- Includes
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
-
|
|
13
|
+
- Includes some rules from:
|
|
14
|
+
- [ESLint](https://eslint.org/)
|
|
15
|
+
- [Perfectionist](https://github.com/azat-io/eslint-plugin-perfectionist)
|
|
16
|
+
- [React](https://github.com/jsx-eslint/eslint-plugin-react)
|
|
17
|
+
- [React Hooks](https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks)
|
|
18
|
+
- [Stylistic](https://github.com/eslint-stylistic/eslint-stylistic)
|
|
19
|
+
- [TypeScript ESLint](https://typescript-eslint.io/)
|
|
20
|
+
- [Unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) (53 rules)
|
|
21
|
+
- 17 custom rules for consistent code organization:
|
|
22
|
+
- [`brace-style-control-statements`](#brace-style-control-statements)
|
|
23
|
+
- [`export-filename-match`](#export-filename-match)
|
|
24
|
+
- [`function-call-argument-line-break`](#function-call-argument-line-break)
|
|
25
|
+
- [`function-parameter-line-break`](#function-parameter-line-break)
|
|
26
|
+
- [`imports-and-re-exports-at-top`](#imports-and-re-exports-at-top)
|
|
27
|
+
- [`individual-imports`](#individual-imports)
|
|
28
|
+
- [`individual-re-exports`](#individual-re-exports)
|
|
29
|
+
- [`interface-property-line-break`](#interface-property-line-break)
|
|
30
|
+
- [`multiline-union-type-aliases`](#multiline-union-type-aliases)
|
|
31
|
+
- [`no-inline-object-type-parameters`](#no-inline-object-type-parameters)
|
|
32
|
+
- [`no-unnecessary-braces`](#no-unnecessary-braces)
|
|
33
|
+
- [`one-export-per-file`](#one-export-per-file)
|
|
34
|
+
- [`prefer-inline-export`](#prefer-inline-export)
|
|
35
|
+
- [`single-line-imports`](#single-line-imports)
|
|
36
|
+
- [`single-line-re-exports`](#single-line-re-exports)
|
|
37
|
+
- [`sorted-imports`](#sorted-imports)
|
|
38
|
+
- [`sorted-re-exports`](#sorted-re-exports)
|
|
18
39
|
|
|
19
40
|
## Installation
|
|
20
41
|
|
|
@@ -34,33 +55,96 @@ export default CONFIG
|
|
|
34
55
|
|
|
35
56
|
## Custom Rules
|
|
36
57
|
|
|
37
|
-
This package includes
|
|
58
|
+
This package includes 17 custom ESLint rules to enforce consistent code organization. All custom rules are auto-fixable.
|
|
38
59
|
|
|
39
|
-
### `
|
|
60
|
+
### `brace-style-control-statements`
|
|
40
61
|
|
|
41
|
-
Enforces
|
|
62
|
+
Enforces control statement bodies to be on a separate line from the condition.
|
|
42
63
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
64
|
+
**Bad:**
|
|
65
|
+
```typescript
|
|
66
|
+
if (foo) return
|
|
67
|
+
if (foo) {return}
|
|
68
|
+
```
|
|
47
69
|
|
|
48
|
-
|
|
70
|
+
**Good:**
|
|
71
|
+
```typescript
|
|
72
|
+
if (foo)
|
|
73
|
+
return
|
|
49
74
|
|
|
50
|
-
|
|
75
|
+
if (foo) {
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
```
|
|
51
79
|
|
|
52
|
-
|
|
80
|
+
### `export-filename-match`
|
|
53
81
|
|
|
54
|
-
|
|
55
|
-
2. **Re-export named** (e.g., `export {foo, bar} from 'module'`)
|
|
56
|
-
3. **Re-export type** (e.g., `export type {Type1, Type2} from 'module'`)
|
|
82
|
+
Enforces exported filenames match the default export name. Allows exceptions for `index.ts`, `.test.ts`, and `.spec.ts` files.
|
|
57
83
|
|
|
58
|
-
|
|
84
|
+
**Bad:**
|
|
85
|
+
```typescript
|
|
86
|
+
// file: utils.ts
|
|
87
|
+
export default function helper() {}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Good:**
|
|
91
|
+
```typescript
|
|
92
|
+
// file: helper.ts
|
|
93
|
+
export default function helper() {}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### `function-call-argument-line-break`
|
|
97
|
+
|
|
98
|
+
Enforces line breaks in function call arguments when the line exceeds 80 characters.
|
|
99
|
+
|
|
100
|
+
**Bad:**
|
|
101
|
+
```typescript
|
|
102
|
+
const result = someFunctionWithAVeryLongName(arg1, arg2, arg3)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Good:**
|
|
106
|
+
```typescript
|
|
107
|
+
const result = someFunctionWithAVeryLongName(
|
|
108
|
+
arg1,
|
|
109
|
+
arg2,
|
|
110
|
+
arg3,
|
|
111
|
+
)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### `function-parameter-line-break`
|
|
115
|
+
|
|
116
|
+
Enforces line breaks in function parameters when the line exceeds 80 characters.
|
|
117
|
+
|
|
118
|
+
**Bad:**
|
|
119
|
+
```typescript
|
|
120
|
+
function myFunctionWithAVeryLongName(param1, param2, param3) {}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Good:**
|
|
124
|
+
```typescript
|
|
125
|
+
function myFunctionWithAVeryLongName(
|
|
126
|
+
param1,
|
|
127
|
+
param2,
|
|
128
|
+
param3,
|
|
129
|
+
) {}
|
|
130
|
+
```
|
|
59
131
|
|
|
60
132
|
### `imports-and-re-exports-at-top`
|
|
61
133
|
|
|
62
134
|
Ensures all imports and re-exports appear at the top of the file before any other statements.
|
|
63
135
|
|
|
136
|
+
**Bad:**
|
|
137
|
+
```typescript
|
|
138
|
+
const foo = 'bar'
|
|
139
|
+
import {baz} from 'module'
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Good:**
|
|
143
|
+
```typescript
|
|
144
|
+
import {baz} from 'module'
|
|
145
|
+
const foo = 'bar'
|
|
146
|
+
```
|
|
147
|
+
|
|
64
148
|
### `individual-imports`
|
|
65
149
|
|
|
66
150
|
Enforces one import per statement instead of grouped imports:
|
|
@@ -92,3 +176,208 @@ export {foo} from 'module'
|
|
|
92
176
|
export {bar} from 'module'
|
|
93
177
|
export {baz} from 'module'
|
|
94
178
|
```
|
|
179
|
+
|
|
180
|
+
### `interface-property-line-break`
|
|
181
|
+
|
|
182
|
+
Enforces line breaks in interface properties when the line exceeds 80 characters.
|
|
183
|
+
|
|
184
|
+
**Bad:**
|
|
185
|
+
```typescript
|
|
186
|
+
interface Config {foo: string; bar: number; baz: boolean}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**Good:**
|
|
190
|
+
```typescript
|
|
191
|
+
interface Config {
|
|
192
|
+
foo: string
|
|
193
|
+
bar: number
|
|
194
|
+
baz: boolean
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### `multiline-union-type-aliases`
|
|
199
|
+
|
|
200
|
+
Enforces multiline union type aliases.
|
|
201
|
+
|
|
202
|
+
**Bad:**
|
|
203
|
+
```typescript
|
|
204
|
+
type Status = 'pending' | 'active' | 'completed'
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**Good:**
|
|
208
|
+
```typescript
|
|
209
|
+
type Status =
|
|
210
|
+
| 'pending'
|
|
211
|
+
| 'active'
|
|
212
|
+
| 'completed'
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### `no-inline-object-types`
|
|
216
|
+
|
|
217
|
+
Disallows inline object types in function parameters and return types. Converts them to named interfaces.
|
|
218
|
+
|
|
219
|
+
**Bad:**
|
|
220
|
+
```typescript
|
|
221
|
+
function foo(x: {a: string}) {}
|
|
222
|
+
let x: {a: string} = {a: ''}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**Good:**
|
|
226
|
+
```typescript
|
|
227
|
+
interface X {a: string}
|
|
228
|
+
function foo(x: X) {}
|
|
229
|
+
|
|
230
|
+
interface InlineType {a: string}
|
|
231
|
+
let x: InlineType = {a: ''}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### `no-unnecessary-braces`
|
|
235
|
+
|
|
236
|
+
Removes braces from single-line statements and adds braces to multi-line statements without braces.
|
|
237
|
+
|
|
238
|
+
**Bad:**
|
|
239
|
+
```typescript
|
|
240
|
+
if (condition) {
|
|
241
|
+
doSomething()
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (condition)
|
|
245
|
+
return {
|
|
246
|
+
a: 1,
|
|
247
|
+
b: 2,
|
|
248
|
+
c: 3,
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**Good:**
|
|
253
|
+
```typescript
|
|
254
|
+
if (condition)
|
|
255
|
+
doSomething()
|
|
256
|
+
|
|
257
|
+
if (condition) {
|
|
258
|
+
return {
|
|
259
|
+
a: 1,
|
|
260
|
+
b: 2,
|
|
261
|
+
c: 3,
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### `one-export-per-file`
|
|
267
|
+
|
|
268
|
+
Enforces one export per file. Allows exceptions for `index.ts`,
|
|
269
|
+
`.test.ts`, and `.spec.ts` files.
|
|
270
|
+
|
|
271
|
+
**Bad:**
|
|
272
|
+
```typescript
|
|
273
|
+
export const foo = 'bar'
|
|
274
|
+
export const baz = 'qux'
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
**Good:**
|
|
278
|
+
```typescript
|
|
279
|
+
// file: foo.ts
|
|
280
|
+
export const foo = 'bar'
|
|
281
|
+
|
|
282
|
+
// file: index.ts
|
|
283
|
+
export const foo = 'bar'
|
|
284
|
+
export const baz = 'qux'
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### `prefer-inline-export`
|
|
288
|
+
|
|
289
|
+
Prefers inline exports.
|
|
290
|
+
|
|
291
|
+
**Bad:**
|
|
292
|
+
```typescript
|
|
293
|
+
class Foo {}
|
|
294
|
+
export {foo}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
**Good:**
|
|
298
|
+
```typescript
|
|
299
|
+
export class Foo {}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### `single-line-imports`
|
|
303
|
+
|
|
304
|
+
Ensures imports are on a single line (converts multiline imports to single line).
|
|
305
|
+
|
|
306
|
+
**Bad:**
|
|
307
|
+
```typescript
|
|
308
|
+
import {
|
|
309
|
+
foo,
|
|
310
|
+
bar,
|
|
311
|
+
} from 'module'
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
**Good:**
|
|
315
|
+
```typescript
|
|
316
|
+
import {foo, bar} from 'module'
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### `single-line-re-exports`
|
|
320
|
+
|
|
321
|
+
Ensures re-exports are on a single line (converts multiline re-exports to single line).
|
|
322
|
+
|
|
323
|
+
**Bad:**
|
|
324
|
+
```typescript
|
|
325
|
+
export {
|
|
326
|
+
foo,
|
|
327
|
+
bar,
|
|
328
|
+
} from 'module'
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
**Good:**
|
|
332
|
+
```typescript
|
|
333
|
+
export {foo, bar} from 'module'
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### `sorted-imports`
|
|
337
|
+
|
|
338
|
+
Enforces imports are sorted alphabetically within their respective groups:
|
|
339
|
+
|
|
340
|
+
1. **Side-effect imports** (e.g., `import 'module'`)
|
|
341
|
+
2. **Default imports** (e.g., `import React from 'react'`)
|
|
342
|
+
3. **Named imports** (e.g., `import {useState} from 'react'`)
|
|
343
|
+
4. **Type imports** (e.g., `import type {Config} from 'module'`)
|
|
344
|
+
|
|
345
|
+
Within each group, imports are sorted alphabetically by module source. Named import specifiers within each import are also sorted alphabetically.
|
|
346
|
+
|
|
347
|
+
**Bad:**
|
|
348
|
+
```typescript
|
|
349
|
+
import {z, a} from 'module'
|
|
350
|
+
import type {Config} from 'config'
|
|
351
|
+
import React from 'react'
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
**Good:**
|
|
355
|
+
```typescript
|
|
356
|
+
import React from 'react'
|
|
357
|
+
import {a, z} from 'module'
|
|
358
|
+
import type {Config} from 'config'
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### `sorted-re-exports`
|
|
362
|
+
|
|
363
|
+
Enforces re-exports are sorted alphabetically within their respective groups:
|
|
364
|
+
|
|
365
|
+
1. **Re-export all** (e.g., `export * from 'module'`)
|
|
366
|
+
2. **Re-export named** (e.g., `export {foo, bar} from 'module'`)
|
|
367
|
+
3. **Re-export type** (e.g., `export type {Type1, Type2} from 'module'`)
|
|
368
|
+
|
|
369
|
+
Within each group, re-exports are sorted alphabetically by module source. Named export specifiers are also sorted alphabetically.
|
|
370
|
+
|
|
371
|
+
**Bad:**
|
|
372
|
+
```typescript
|
|
373
|
+
export {bar} from 'module'
|
|
374
|
+
export * from 'another'
|
|
375
|
+
export type {TypeB} from 'types'
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
**Good:**
|
|
379
|
+
```typescript
|
|
380
|
+
export * from 'another'
|
|
381
|
+
export {bar} from 'module'
|
|
382
|
+
export type {TypeB} from 'types'
|
|
383
|
+
```
|