@borela-tech/eslint-config 2.2.1 → 2.3.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 +3589 -811
- package/dist/index.mjs.map +1 -1
- package/jest.config.ts +19 -0
- package/package.json +17 -8
- 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 -5226
- 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 -19
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type {ReExportDeclaration} from '@lib/ReExportDeclaration'
|
|
2
|
-
import type {TSESTree} from '@typescript-eslint/types'
|
|
3
|
-
|
|
4
|
-
function isReExportDeclaration(
|
|
5
|
-
statement: TSESTree.ProgramStatement,
|
|
6
|
-
): statement is ReExportDeclaration {
|
|
7
|
-
return (statement.type === 'ExportNamedDeclaration' && statement.source !== null)
|
|
8
|
-
|| statement.type === 'ExportAllDeclaration'
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function getReExportGroups(
|
|
12
|
-
programBody: TSESTree.ProgramStatement[],
|
|
13
|
-
): ReExportDeclaration[][] {
|
|
14
|
-
const groups: ReExportDeclaration[][] = []
|
|
15
|
-
let currentGroup: ReExportDeclaration[] = []
|
|
16
|
-
|
|
17
|
-
for (const statement of programBody) {
|
|
18
|
-
if (isReExportDeclaration(statement)) {
|
|
19
|
-
currentGroup.push(statement)
|
|
20
|
-
continue
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (currentGroup.length > 0) {
|
|
24
|
-
groups.push(currentGroup)
|
|
25
|
-
currentGroup = []
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (currentGroup.length > 0)
|
|
30
|
-
groups.push(currentGroup)
|
|
31
|
-
|
|
32
|
-
return groups
|
|
33
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import {categorizeReExport} from './categorizeReExport'
|
|
2
|
-
import type {ReExportDeclaration} from '@lib/ReExportDeclaration'
|
|
3
|
-
|
|
4
|
-
export function getSortKey(declaration: ReExportDeclaration): string {
|
|
5
|
-
const group = categorizeReExport(declaration)
|
|
6
|
-
|
|
7
|
-
if (declaration.type === 'ExportAllDeclaration') {
|
|
8
|
-
if (group === 're-export-namespace') {
|
|
9
|
-
if (declaration.exported?.type === 'Identifier')
|
|
10
|
-
return `*${declaration.exported.name}`
|
|
11
|
-
}
|
|
12
|
-
return declaration.source.value
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const specifier = declaration.specifiers[0]
|
|
16
|
-
if (!specifier)
|
|
17
|
-
return ''
|
|
18
|
-
|
|
19
|
-
return specifier.local.type === 'Identifier'
|
|
20
|
-
? specifier.local.name
|
|
21
|
-
: specifier.local.value
|
|
22
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import {categorizeReExports} from './categorizeReExports'
|
|
2
|
-
import {checkAlphabeticalSorting} from './checkAlphabeticalSorting'
|
|
3
|
-
import {checkGroupOrdering} from './checkGroupOrdering'
|
|
4
|
-
import {checkSpecifiersSorting} from './checkSpecifiersSorting'
|
|
5
|
-
import {createFix} from './createFix'
|
|
6
|
-
import {getReExportGroups} from './getReExportGroups'
|
|
7
|
-
import type {ReExportError} from './ReExportError'
|
|
8
|
-
import type {TSESLint} from '@typescript-eslint/utils'
|
|
9
|
-
|
|
10
|
-
type MessageIds =
|
|
11
|
-
| 'sortedReExports'
|
|
12
|
-
| 'sortedNames'
|
|
13
|
-
| 'wrongGroup'
|
|
14
|
-
|
|
15
|
-
export const sortedReExports: TSESLint.RuleModule<MessageIds, []> = {
|
|
16
|
-
meta: {
|
|
17
|
-
docs: {
|
|
18
|
-
description: 'Enforce sorted exports alphabetically',
|
|
19
|
-
},
|
|
20
|
-
fixable: 'code',
|
|
21
|
-
messages: {
|
|
22
|
-
sortedReExports: 'Exports should be sorted alphabetically',
|
|
23
|
-
sortedNames: 'Named exports should be sorted alphabetically',
|
|
24
|
-
wrongGroup: 'Export is in wrong group',
|
|
25
|
-
},
|
|
26
|
-
schema: [],
|
|
27
|
-
type: 'suggestion',
|
|
28
|
-
},
|
|
29
|
-
create(context) {
|
|
30
|
-
return {
|
|
31
|
-
Program(node) {
|
|
32
|
-
const body = node.body
|
|
33
|
-
const reExportGroups = getReExportGroups(body)
|
|
34
|
-
if (reExportGroups.length === 0)
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
const allErrors: ReExportError[] = []
|
|
38
|
-
|
|
39
|
-
// Check each re-export group independently
|
|
40
|
-
for (const group of reExportGroups) {
|
|
41
|
-
const categorized = categorizeReExports(group)
|
|
42
|
-
const errors: ReExportError[] = [
|
|
43
|
-
...checkGroupOrdering(categorized),
|
|
44
|
-
...checkAlphabeticalSorting(categorized),
|
|
45
|
-
...checkSpecifiersSorting(categorized),
|
|
46
|
-
]
|
|
47
|
-
allErrors.push(...errors)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
for (const error of allErrors) {
|
|
51
|
-
context.report({
|
|
52
|
-
node: error.node,
|
|
53
|
-
messageId: error.messageId,
|
|
54
|
-
fix(fixer) {
|
|
55
|
-
const sourceCode = context.sourceCode
|
|
56
|
-
return createFix(fixer, reExportGroups, sourceCode)
|
|
57
|
-
},
|
|
58
|
-
})
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type {CategorizedNamedReExport} from './CategorizedNamedReExport'
|
|
2
|
-
import type {CategorizedReExport} from './CategorizedReExport'
|
|
3
|
-
|
|
4
|
-
export function isNamedReExport(x: CategorizedReExport): x is CategorizedNamedReExport {
|
|
5
|
-
return x.group !== 're-export-all' && x.group !== 're-export-namespace'
|
|
6
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {compare} from '@lib/compare'
|
|
2
|
-
import {getSpecifierName} from './getSpecifierName'
|
|
3
|
-
import type {TSESLint} from '@typescript-eslint/utils'
|
|
4
|
-
import type {TSESTree} from '@typescript-eslint/utils'
|
|
5
|
-
|
|
6
|
-
export function sortSpecifiersText(
|
|
7
|
-
specifiers: TSESTree.ExportSpecifier[],
|
|
8
|
-
sourceCode: TSESLint.SourceCode,
|
|
9
|
-
): string {
|
|
10
|
-
const sorted = [...specifiers].sort((a, b) => {
|
|
11
|
-
const nameA = getSpecifierName(a)
|
|
12
|
-
const nameB = getSpecifierName(b)
|
|
13
|
-
return compare(nameA, nameB)
|
|
14
|
-
})
|
|
15
|
-
return sorted.map(s => sourceCode.getText(s)).join(', ')
|
|
16
|
-
}
|
package/tsdown.config.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
import {defineConfig} from 'tsdown'
|
|
3
|
-
|
|
4
|
-
export default defineConfig(options => {
|
|
5
|
-
return {
|
|
6
|
-
...options,
|
|
7
|
-
clean: true,
|
|
8
|
-
dts: true,
|
|
9
|
-
entry: {
|
|
10
|
-
index: 'src/index.ts',
|
|
11
|
-
},
|
|
12
|
-
format: ['esm'],
|
|
13
|
-
splitting: false,
|
|
14
|
-
sourcemap: true,
|
|
15
|
-
alias: {
|
|
16
|
-
'@lib': path.resolve(process.cwd(), 'src/lib'),
|
|
17
|
-
},
|
|
18
|
-
}
|
|
19
|
-
})
|