@borela-tech/eslint-config 2.1.1 → 2.1.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/dist/index.js CHANGED
@@ -38,21 +38,21 @@ function categorizeStatements(statements) {
38
38
  return result;
39
39
  }
40
40
 
41
- // src/rules/importsAndReExportsAtTop/findFirstIndices.ts
42
- function findFirstIndices(statements) {
43
- let firstImport = Infinity;
44
- let firstReExport = Infinity;
45
- let firstOther = -1;
41
+ // src/rules/importsAndReExportsAtTop/findStatementIndices.ts
42
+ function findStatementIndices(statements) {
43
+ let firstRegularStatement = -1;
44
+ let lastImport = -1;
45
+ let lastReExport = -1;
46
46
  for (let i = 0; i < statements.length; i++) {
47
47
  const type = getStatementType(statements[i]);
48
- if (type === "import" && firstImport === Infinity)
49
- firstImport = i;
50
- else if (type === "re-export" && firstReExport === Infinity)
51
- firstReExport = i;
52
- else if (type === "other" && firstOther === -1)
53
- firstOther = i;
48
+ if (type === "import")
49
+ lastImport = i;
50
+ else if (type === "re-export")
51
+ lastReExport = i;
52
+ else if (type === "other" && firstRegularStatement === -1)
53
+ firstRegularStatement = i;
54
54
  }
55
- return { firstImport, firstReExport, firstOther };
55
+ return { firstRegularStatement, lastImport, lastReExport };
56
56
  }
57
57
 
58
58
  // src/rules/importsAndReExportsAtTop/generateSortedText.ts
@@ -69,18 +69,12 @@ function generateSortedText(context, categories) {
69
69
 
70
70
  // src/rules/importsAndReExportsAtTop/hasViolation.ts
71
71
  function hasViolation(indices, categories) {
72
- const {
73
- firstImport,
74
- firstReExport,
75
- firstOther
76
- } = indices;
77
- if (categories.imports.length === 0 || categories.reExports.length === 0)
72
+ const { firstRegularStatement, lastImport, lastReExport } = indices;
73
+ if (categories.imports.length === 0 && categories.reExports.length === 0)
78
74
  return false;
79
- const firstImportOrReExport = Math.min(firstImport, firstReExport);
80
- const hasOtherBeforeImportOrReExport = firstOther !== -1 && firstOther < firstImportOrReExport;
81
- if (hasOtherBeforeImportOrReExport || firstImport > firstReExport)
82
- return true;
83
- return false;
75
+ const hasImportAfterRegularStatement = categories.imports.length > 0 && firstRegularStatement !== -1 && lastImport > firstRegularStatement;
76
+ const hasReExportAfterRegularStatement = categories.reExports.length > 0 && firstRegularStatement !== -1 && lastReExport > firstRegularStatement;
77
+ return hasImportAfterRegularStatement || hasReExportAfterRegularStatement;
84
78
  }
85
79
 
86
80
  // src/rules/importsAndReExportsAtTop/index.ts
@@ -102,7 +96,7 @@ var importsAndReExportsAtTop = {
102
96
  Program(node) {
103
97
  const statements = node.body;
104
98
  const categories = categorizeStatements(statements);
105
- const indices = findFirstIndices(statements);
99
+ const indices = findStatementIndices(statements);
106
100
  if (!hasViolation(indices, categories))
107
101
  return;
108
102
  context.report({
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/rules/importsAndReExportsAtTop/getStatementType.ts","../src/rules/importsAndReExportsAtTop/categorizeStatements.ts","../src/rules/importsAndReExportsAtTop/findFirstIndices.ts","../src/rules/importsAndReExportsAtTop/generateSortedText.ts","../src/rules/importsAndReExportsAtTop/hasViolation.ts","../src/rules/importsAndReExportsAtTop/index.ts","../src/rules/individualImports.ts","../src/rules/individualReExports.ts","../src/rules/sortedImports/categorizeImport.ts","../src/rules/sortedImports/getSortKey.ts","../src/rules/sortedImports/categorizeImports.ts","../src/lib/compare.ts","../src/rules/sortedImports/ImportGroupOrder.ts","../src/rules/sortedImports/checkAlphabeticalSorting.ts","../src/rules/sortedImports/checkGroupOrdering.ts","../src/rules/sortedImports/getSpecifierName.ts","../src/rules/sortedImports/areSpecifiersSorted.ts","../src/rules/sortedImports/getNamedSpecifiers.ts","../src/rules/sortedImports/checkSpecifiersSorting.ts","../src/rules/sortedImports/sortSpecifiersText.ts","../src/rules/sortedImports/createFix/formatNamedImport.ts","../src/rules/sortedImports/createFix/buildSortedCode.ts","../src/rules/sortedImports/createFix/groupImportsByType.ts","../src/rules/sortedImports/createFix/sortImportGroups.ts","../src/rules/sortedImports/createFix/index.ts","../src/rules/sortedImports/getImportGroups.ts","../src/rules/sortedImports/index.ts","../src/rules/sortedReExports/categorizeReExport.ts","../src/rules/sortedReExports/getSortKey.ts","../src/rules/sortedReExports/categorizeReExports.ts","../src/rules/sortedReExports/ReExportGroupOrder.ts","../src/rules/sortedReExports/checkAlphabeticalSorting.ts","../src/rules/sortedReExports/checkGroupOrdering.ts","../src/rules/sortedReExports/getSpecifierName.ts","../src/rules/sortedReExports/areSpecifiersSorted.ts","../src/rules/sortedReExports/getNamedSpecifiers.ts","../src/rules/sortedReExports/isNamedReExport.ts","../src/rules/sortedReExports/checkSpecifiersSorting.ts","../src/rules/sortedReExports/sortSpecifiersText.ts","../src/rules/sortedReExports/createFix/formatNamedReExport.ts","../src/rules/sortedReExports/createFix/buildSortedCode.ts","../src/rules/sortedReExports/createFix/groupReExportsByType.ts","../src/rules/sortedReExports/createFix/sortExportGroups.ts","../src/rules/sortedReExports/createFix/index.ts","../src/rules/sortedReExports/getReExportGroups.ts","../src/rules/sortedReExports/index.ts"],"sourcesContent":["import eslint from '@eslint/js'\nimport react from 'eslint-plugin-react'\nimport reactHooks from 'eslint-plugin-react-hooks'\nimport stylistic from '@stylistic/eslint-plugin'\nimport typescript from 'typescript-eslint'\nimport {defineConfig} from 'eslint/config'\nimport {importsAndReExportsAtTop} from './rules/importsAndReExportsAtTop'\nimport {individualImports} from './rules/individualImports'\nimport {individualReExports} from './rules/individualReExports'\nimport {sortedImports} from './rules/sortedImports'\nimport {sortedReExports} from './rules/sortedReExports'\n\nexport const CONFIG = defineConfig([\n {\n ignores: [\n 'src/graphql/sdk.ts',\n '**/node_modules/**',\n '**/dist/**',\n ],\n },\n {\n settings: {\n react: {\n version: '19',\n },\n },\n },\n eslint.configs.recommended,\n react.configs.flat.recommended,\n stylistic.configs.recommended,\n typescript.configs.recommended,\n typescript.configs.stylistic,\n {\n plugins: {\n 'react-hooks': reactHooks,\n },\n rules: reactHooks.configs.recommended.rules,\n },\n {\n plugins: {\n '@borela-tech': {\n rules: {\n 'imports-and-re-exports-at-top': importsAndReExportsAtTop,\n 'individual-imports': individualImports,\n 'individual-re-exports': individualReExports,\n 'sorted-imports': sortedImports,\n 'sorted-re-exports': sortedReExports,\n },\n },\n },\n rules: {\n '@borela-tech/imports-and-re-exports-at-top': 'error',\n '@borela-tech/individual-imports': 'error',\n '@borela-tech/individual-re-exports': 'error',\n '@borela-tech/sorted-imports': 'error',\n '@borela-tech/sorted-re-exports': 'error',\n },\n },\n {\n rules: {\n 'capitalized-comments': [\n 'error',\n 'always',\n {ignoreConsecutiveComments: true},\n ],\n 'react/react-in-jsx-scope': 'off',\n '@stylistic/arrow-parens': [\n 'error',\n 'as-needed',\n ],\n '@stylistic/array-bracket-newline': [\n 'error',\n 'consistent',\n ],\n '@stylistic/array-bracket-spacing': [\n 'error',\n 'never',\n ],\n '@stylistic/array-element-newline': [\n 'error',\n 'consistent',\n ],\n '@stylistic/block-spacing': 'off',\n '@stylistic/brace-style': [\n 'error',\n '1tbs',\n {allowSingleLine: true},\n ],\n '@stylistic/indent': [\n 'error',\n 2,\n {ignoredNodes: ['TSMappedType > *']},\n ],\n '@stylistic/jsx-tag-spacing': [\n 'error',\n {\n afterOpening: 'never',\n beforeClosing: 'never',\n beforeSelfClosing: 'never',\n closingSlash: 'never',\n },\n ],\n '@stylistic/jsx-wrap-multilines': 'off',\n '@stylistic/lines-between-class-members': 'off',\n '@stylistic/object-curly-newline': [\n 'error',\n {consistent: true},\n ],\n '@stylistic/object-curly-spacing': [\n 'error',\n 'never',\n ],\n '@stylistic/operator-linebreak': [\n 'error',\n 'before',\n {overrides: {'=': 'after'}},\n ],\n '@stylistic/quotes': [\n 'error',\n 'single',\n {avoidEscape: true},\n ],\n '@stylistic/quote-props': [\n 'error',\n 'as-needed',\n ],\n '@stylistic/semi': [\n 'error',\n 'never',\n {beforeStatementContinuationChars: 'always'},\n ],\n '@typescript-eslint/no-empty-function': 'off',\n '@typescript-eslint/consistent-indexed-object-style': 'off',\n },\n },\n])\n","import {StatementType} from './statementType'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function getStatementType(statement: TSESTree.Statement): StatementType {\n if (statement.type === 'ImportDeclaration')\n return 'import'\n\n if (statement.type === 'ExportAllDeclaration')\n return 're-export'\n\n if (statement.type === 'ExportNamedDeclaration') {\n if (statement.source !== null)\n return 're-export'\n }\n\n return 'other'\n}\n","import {getStatementType} from './getStatementType'\nimport {ReExport} from './ReExport'\nimport type {CategorizedStatements} from './CategorizedStatements'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function categorizeStatements(\n statements: TSESTree.Statement[],\n): CategorizedStatements {\n const result: CategorizedStatements = {\n imports: [],\n reExports: [],\n other: [],\n }\n\n for (const statement of statements) {\n const type = getStatementType(statement)\n\n if (type === 'import')\n result.imports.push(statement as TSESTree.ImportDeclaration)\n else if (type === 're-export')\n result.reExports.push(statement as ReExport)\n else\n result.other.push(statement)\n }\n\n return result\n}\n","import {getStatementType} from './getStatementType'\nimport type {StatementIndices} from './StatementIndices'\nimport type {StatementType} from './statementType'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function findFirstIndices(\n statements: TSESTree.Statement[],\n): StatementIndices {\n let firstImport = Infinity\n let firstReExport = Infinity\n let firstOther = -1\n\n for (let i = 0; i < statements.length; i++) {\n const type: StatementType = getStatementType(statements[i])\n\n if (type === 'import' && firstImport === Infinity)\n firstImport = i\n else if (type === 're-export' && firstReExport === Infinity)\n firstReExport = i\n else if (type === 'other' && firstOther === -1)\n firstOther = i\n }\n\n return {firstImport, firstReExport, firstOther}\n}\n","import {Rule} from 'eslint'\nimport type {CategorizedStatements} from './CategorizedStatements'\nimport type {Node as ESTreeNode} from 'estree'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function generateSortedText(\n context: Rule.RuleContext,\n categories: CategorizedStatements,\n): string {\n const allStatements: TSESTree.Node[] = [\n ...categories.imports,\n ...categories.reExports,\n ...categories.other,\n ]\n return allStatements.map(\n node => context.sourceCode.getText(node as ESTreeNode),\n ).join('\\n')\n}\n","import type {CategorizedStatements} from './CategorizedStatements'\nimport type {StatementIndices} from './StatementIndices'\n\nexport function hasViolation(\n indices: StatementIndices,\n categories: CategorizedStatements,\n): boolean {\n const {\n firstImport,\n firstReExport,\n firstOther,\n } = indices\n\n // No imports or no re-exports.\n if (categories.imports.length === 0 || categories.reExports.length === 0)\n return false\n\n const firstImportOrReExport = Math.min(firstImport, firstReExport)\n const hasOtherBeforeImportOrReExport =\n firstOther !== -1 && firstOther < firstImportOrReExport\n\n // Violation if:\n // 1. Other statements appear before imports/re-exports.\n // 2. Re-exports appear before imports.\n if (hasOtherBeforeImportOrReExport || firstImport > firstReExport)\n return true\n\n return false\n}\n","import {categorizeStatements} from './categorizeStatements'\nimport {findFirstIndices} from './findFirstIndices'\nimport {generateSortedText} from './generateSortedText'\nimport {hasViolation} from './hasViolation'\nimport type {Rule} from 'eslint'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport const importsAndReExportsAtTop: Rule.RuleModule = {\n meta: {\n type: 'suggestion',\n docs: {\n description: 'Enforce imports and re-exports at the top of the file',\n recommended: false,\n },\n fixable: 'code',\n messages: {\n importsAndReExportsAtTop:\n 'Imports and re-exports should be at the top of the file.',\n },\n schema: [],\n },\n\n create(context) {\n return {\n Program(node) {\n const statements = node.body as TSESTree.Statement[]\n const categories = categorizeStatements(statements)\n const indices = findFirstIndices(statements)\n\n if (!hasViolation(indices, categories))\n return\n\n context.report({\n node,\n messageId: 'importsAndReExportsAtTop',\n\n fix(fixer) {\n const sortedText = generateSortedText(context, categories)\n return fixer.replaceText(node, sortedText)\n },\n })\n },\n }\n },\n}\n","import type {Rule} from 'eslint'\n\nexport const individualImports: Rule.RuleModule = {\n meta: {\n docs: {\n description: 'Enforce individual imports instead of grouped imports',\n recommended: true,\n },\n fixable: 'code',\n messages: {\n individualImports: 'Use individual imports instead of grouped imports.',\n },\n schema: [],\n type: 'suggestion',\n },\n create(context) {\n return {\n ImportDeclaration(node) {\n if (node.specifiers.length <= 1)\n return\n\n context.report({\n node,\n messageId: 'individualImports',\n fix(fixer) {\n const source = node.source.raw\n const specifiers = node.specifiers\n .filter(s => s.type === 'ImportSpecifier')\n .map(s => `import {${s.local.name}} from ${source}`)\n .join('\\n')\n return fixer.replaceText(node, specifiers)\n },\n })\n },\n }\n },\n}\n","import type {Rule} from 'eslint'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport const individualReExports: Rule.RuleModule = {\n meta: {\n docs: {\n description: 'Enforce individual exports instead of grouped exports',\n recommended: true,\n },\n fixable: 'code',\n messages: {\n individualReExports: 'Use individual exports instead of grouped exports.',\n },\n schema: [],\n type: 'suggestion',\n },\n create(context) {\n return {\n ExportNamedDeclaration(node) {\n const exportNode = node as TSESTree.ExportNamedDeclaration\n if (!exportNode.source || exportNode.specifiers.length <= 1)\n return\n\n context.report({\n node,\n messageId: 'individualReExports',\n fix(fixer) {\n const source = exportNode.source!.value\n const typeKeyword = exportNode.exportKind === 'type'\n ? 'type '\n : ''\n const specifiers = exportNode.specifiers\n .map(s => {\n const localName = s.local.type === 'Identifier'\n ? s.local.name\n : s.local.value\n const exportedName = s.exported.type === 'Identifier'\n ? s.exported.name\n : s.exported.value\n const name = localName === exportedName\n ? localName\n : `${localName} as ${exportedName}`\n return `export ${typeKeyword}{${name}} from '${source}'`\n })\n .join('\\n')\n return fixer.replaceText(node, specifiers)\n },\n })\n },\n }\n },\n}\n","import type {ImportGroup} from './ImportGroup'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function categorizeImport(declaration: TSESTree.ImportDeclaration): ImportGroup {\n // Example: import type {Type} from 'module'\n if (declaration.importKind === 'type')\n return 'type'\n\n // Example: import 'module'\n if (declaration.specifiers.length === 0)\n return 'side-effect'\n\n // Example: import value from 'module'\n if (declaration.specifiers.some(s => s.type === 'ImportDefaultSpecifier'))\n return 'default'\n\n // Example: import {value} from 'module'\n return 'named'\n}\n","import {categorizeImport} from './categorizeImport'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function getSortKey(declaration: TSESTree.ImportDeclaration): string {\n const group = categorizeImport(declaration)\n\n if (group === 'side-effect')\n return declaration.source.value\n\n if (group === 'default') {\n const defaultSpecifier = declaration.specifiers.find(\n s => s.type === 'ImportDefaultSpecifier',\n ) as TSESTree.ImportDefaultSpecifier | undefined\n\n return defaultSpecifier?.local.name ?? ''\n }\n\n const specifier = declaration.specifiers[0]\n return specifier.local.name\n}\n","import {categorizeImport} from './categorizeImport'\nimport {getSortKey} from './getSortKey'\nimport type {CategorizedImport} from './CategorizedImport'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function categorizeImports(declarations: TSESTree.ImportDeclaration[]): CategorizedImport[] {\n return declarations.map(declaration => ({\n declaration,\n group: categorizeImport(declaration),\n sortKey: getSortKey(declaration),\n }))\n}\n","export function compare(a: string, b: string): number {\n return a.localeCompare(b, 'en', {sensitivity: 'case'})\n}\n","import {ImportGroup} from './ImportGroup'\n\nexport const importGroupOrder: ImportGroup[] = [\n 'side-effect',\n 'default',\n 'named',\n 'type',\n]\n","import {compare} from '../../lib/compare'\nimport {importGroupOrder} from './ImportGroupOrder'\nimport type {CategorizedImport} from './CategorizedImport'\nimport type {ImportError} from './ImportError'\n\nexport function checkAlphabeticalSorting(categorized: CategorizedImport[]): ImportError[] {\n const errors: ImportError[] = []\n\n for (const group of importGroupOrder) {\n const groupImports = categorized.filter(c => c.group === group)\n const sorted = [...groupImports].sort((a, b) => compare(a.sortKey, b.sortKey))\n for (let i = 0; i < groupImports.length; i++) {\n if (groupImports[i] !== sorted[i]) {\n errors.push({\n node: groupImports[i].declaration,\n messageId: 'sortedImports',\n })\n }\n }\n }\n\n return errors\n}\n","import {importGroupOrder} from './ImportGroupOrder'\nimport type {CategorizedImport} from './CategorizedImport'\nimport type {ImportError} from './ImportError'\n\nexport function checkGroupOrdering(categorized: CategorizedImport[]): ImportError[] {\n const errors: ImportError[] = []\n\n let currentGroupIndex = -1\n for (const {declaration, group} of categorized) {\n const groupIndex = importGroupOrder.indexOf(group)\n if (groupIndex < currentGroupIndex) {\n errors.push({\n node: declaration,\n messageId: 'wrongGroup',\n })\n } else\n currentGroupIndex = groupIndex\n }\n\n return errors\n}\n","import type {TSESTree} from '@typescript-eslint/types'\n\nexport function getSpecifierName(specifier: TSESTree.ImportSpecifier): string {\n return specifier.imported.type === 'Identifier'\n ? specifier.imported.name\n : String(specifier.imported.value)\n}\n","import {compare} from '../../lib/compare'\nimport {getSpecifierName} from './getSpecifierName'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function areSpecifiersSorted(specifiers: TSESTree.ImportSpecifier[]): boolean {\n const names = specifiers.map(s => getSpecifierName(s))\n const sorted = [...names].sort((a, b) => compare(a, b))\n return names.every((name, i) => name === sorted[i])\n}\n","import type {TSESTree} from '@typescript-eslint/types'\n\nexport function getNamedSpecifiers(declaration: TSESTree.ImportDeclaration): TSESTree.ImportSpecifier[] {\n return declaration.specifiers.filter(\n (s): s is TSESTree.ImportSpecifier => s.type === 'ImportSpecifier',\n )\n}\n","import {areSpecifiersSorted} from './areSpecifiersSorted'\nimport {getNamedSpecifiers} from './getNamedSpecifiers'\nimport type {CategorizedImport} from './CategorizedImport'\nimport type {ImportError} from './ImportError'\n\nexport function checkSpecifiersSorting(categorized: CategorizedImport[]): ImportError[] {\n const errors: ImportError[] = []\n const namedImports = categorized.filter(c => c.group === 'named')\n\n for (const {declaration} of namedImports) {\n const specifiers = getNamedSpecifiers(declaration)\n if (specifiers.length > 1 && !areSpecifiersSorted(specifiers)) {\n errors.push({\n node: declaration,\n messageId: 'sortedNames',\n })\n }\n }\n\n return errors\n}\n","import {compare} from '../../lib/compare'\nimport {getSpecifierName} from './getSpecifierName'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function sortSpecifiersText(\n specifiers: TSESTree.ImportSpecifier[],\n sourceCode: {getText: (node: TSESTree.ImportSpecifier) => string},\n): string {\n const sorted = [...specifiers].sort((a, b) => {\n const nameA = getSpecifierName(a)\n const nameB = getSpecifierName(b)\n return compare(nameA, nameB)\n })\n return sorted.map(s => sourceCode.getText(s)).join(', ')\n}\n","import {areSpecifiersSorted} from '../areSpecifiersSorted'\nimport {getNamedSpecifiers} from '../getNamedSpecifiers'\nimport {sortSpecifiersText} from '../sortSpecifiersText'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function formatNamedImport(\n declaration: TSESTree.ImportDeclaration,\n sourceCode: {getText: (node?: unknown) => string},\n): string {\n const specifiers = getNamedSpecifiers(declaration)\n\n if (specifiers.length > 1 && !areSpecifiersSorted(specifiers)) {\n const sortedSpecifiers = sortSpecifiersText(specifiers, sourceCode)\n const source = declaration.source.value\n const prefix = declaration.importKind === 'type' ? 'import type ' : 'import '\n return `${prefix}{${sortedSpecifiers}} from '${source}'`\n }\n\n return sourceCode.getText(declaration)\n}\n","import {formatNamedImport} from './formatNamedImport'\nimport {importGroupOrder} from '../ImportGroupOrder'\nimport type {CategorizedImport} from '../CategorizedImport'\nimport type {ImportGroup} from '../ImportGroup'\n\nexport function buildSortedCode(\n grouped: Record<ImportGroup, CategorizedImport[]>,\n sourceCode: {getText: (node?: unknown) => string},\n): string[] {\n const sortedCode: string[] = []\n\n for (const group of importGroupOrder) {\n for (const {declaration} of grouped[group]) {\n if (group === 'named' || group === 'type')\n sortedCode.push(formatNamedImport(declaration, sourceCode))\n else\n sortedCode.push(sourceCode.getText(declaration))\n }\n }\n\n return sortedCode\n}\n","import type {CategorizedImport} from '../CategorizedImport'\nimport type {ImportGroup} from '../ImportGroup'\n\nexport function groupImportsByType(\n categorized: CategorizedImport[],\n): Record<ImportGroup, CategorizedImport[]> {\n const grouped: Record<ImportGroup, CategorizedImport[]> = {\n 'side-effect': [],\n default: [],\n named: [],\n type: [],\n }\n\n for (const item of categorized)\n grouped[item.group].push(item)\n\n return grouped\n}\n","import {compare} from '../../../lib/compare'\nimport type {CategorizedImport} from '../CategorizedImport'\nimport type {ImportGroup} from '../ImportGroup'\n\nexport function sortImportGroups(\n grouped: Record<ImportGroup, CategorizedImport[]>,\n): void {\n grouped['side-effect'].sort((a, b) => compare(a.sortKey, b.sortKey))\n grouped['default'].sort((a, b) => compare(a.sortKey, b.sortKey))\n grouped['named'].sort((a, b) => compare(a.sortKey, b.sortKey))\n grouped['type'].sort((a, b) => compare(a.sortKey, b.sortKey))\n}\n","import {buildSortedCode} from './buildSortedCode'\nimport {categorizeImports} from '../categorizeImports'\nimport {groupImportsByType} from './groupImportsByType'\nimport {sortImportGroups} from './sortImportGroups'\nimport type {Rule} from 'eslint'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nfunction createFixForGroup(\n fixer: Rule.RuleFixer,\n importDeclarations: TSESTree.ImportDeclaration[],\n sourceCode: {getText: (node?: unknown) => string},\n): Rule.Fix | null {\n if (importDeclarations.length === 0) {\n return null\n }\n\n const categorized = categorizeImports(importDeclarations)\n const grouped = groupImportsByType(categorized)\n\n sortImportGroups(grouped)\n\n const sortedCode = buildSortedCode(grouped, sourceCode)\n .join('\\n')\n\n const firstImport = importDeclarations[0]\n const lastImport = importDeclarations[importDeclarations.length - 1]\n\n return fixer.replaceTextRange(\n [firstImport.range![0], lastImport.range![1]],\n sortedCode,\n )\n}\n\nexport function createFix(\n fixer: Rule.RuleFixer,\n importGroups: TSESTree.ImportDeclaration[][],\n sourceCode: {getText: (node?: unknown) => string},\n): Rule.Fix[] {\n const fixes: Rule.Fix[] = []\n\n for (const group of importGroups) {\n const fix = createFixForGroup(fixer, group, sourceCode)\n if (fix)\n fixes.push(fix)\n }\n\n return fixes\n}\n","import type {TSESTree} from '@typescript-eslint/types'\n\nexport function getImportGroups(programBody: TSESTree.ProgramStatement[]): TSESTree.ImportDeclaration[][] {\n const groups: TSESTree.ImportDeclaration[][] = []\n let currentGroup: TSESTree.ImportDeclaration[] = []\n\n for (const statement of programBody) {\n if (statement.type === 'ImportDeclaration') {\n currentGroup.push(statement)\n continue\n }\n\n if (currentGroup.length > 0) {\n groups.push(currentGroup)\n currentGroup = []\n }\n }\n\n if (currentGroup.length > 0)\n groups.push(currentGroup)\n\n return groups\n}\n","import {categorizeImports} from './categorizeImports'\nimport {checkAlphabeticalSorting} from './checkAlphabeticalSorting'\nimport {checkGroupOrdering} from './checkGroupOrdering'\nimport {checkSpecifiersSorting} from './checkSpecifiersSorting'\nimport {createFix} from './createFix'\nimport {getImportGroups} from './getImportGroups'\nimport type {ImportError} from './ImportError'\nimport type {Rule} from 'eslint'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport const sortedImports: Rule.RuleModule = {\n meta: {\n docs: {\n description: 'Enforce sorted imports alphabetically',\n recommended: true,\n },\n fixable: 'code',\n messages: {\n sortedImports: 'Imports should be sorted alphabetically',\n sortedNames: 'Named imports should be sorted alphabetically',\n wrongGroup: 'Import is in wrong group',\n },\n schema: [],\n type: 'suggestion',\n },\n create(context) {\n return {\n Program(node) {\n const body = node.body as TSESTree.ProgramStatement[]\n const importGroups = getImportGroups(body)\n if (importGroups.length === 0)\n return\n\n const allErrors: ImportError[] = []\n\n // Check each import group independently\n for (const group of importGroups) {\n const categorized = categorizeImports(group)\n const errors: ImportError[] = [\n ...checkGroupOrdering(categorized),\n ...checkAlphabeticalSorting(categorized),\n ...checkSpecifiersSorting(categorized),\n ]\n allErrors.push(...errors)\n }\n\n for (const error of allErrors) {\n context.report({\n node: error.node,\n messageId: error.messageId,\n fix(fixer) {\n const sourceCode = context.sourceCode\n return createFix(fixer, importGroups, sourceCode)\n },\n })\n }\n },\n }\n },\n}\n","import type {ReExportGroup} from './ReExportGroup'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function categorizeReExport(\n declaration: TSESTree.ExportNamedDeclaration | TSESTree.ExportAllDeclaration,\n): ReExportGroup {\n // Example: export * from 'module'\n if (declaration.type === 'ExportAllDeclaration')\n return 're-export-all'\n\n // Example: export type {Type} from 'module'\n if (declaration.exportKind === 'type')\n return 're-export-type'\n\n // Example: export {value} from 'module'\n return 're-export-named'\n}\n","import type {TSESTree} from '@typescript-eslint/types'\n\nexport function getSortKey(\n declaration: TSESTree.ExportNamedDeclaration | TSESTree.ExportAllDeclaration,\n): string {\n if (declaration.type === 'ExportAllDeclaration')\n return declaration.source.value\n\n const specifier = declaration.specifiers[0]\n if (!specifier)\n return ''\n\n return specifier.local.type === 'Identifier'\n ? specifier.local.name\n : specifier.local.value\n}\n","import {categorizeReExport} from './categorizeReExport'\nimport {getSortKey} from './getSortKey'\nimport {ReExportDeclaration} from './ReExportDeclaration'\nimport type {CategorizedReExport} from './CategorizedReExport'\n\nexport function categorizeReExports(declarations: ReExportDeclaration[]): CategorizedReExport[] {\n return declarations.map(declaration => {\n return {\n declaration,\n group: categorizeReExport(declaration),\n sortKey: getSortKey(declaration),\n } as CategorizedReExport\n })\n}\n","import {ReExportGroup} from './ReExportGroup'\n\nexport const reExportGroupOrder: ReExportGroup[] = [\n 're-export-all',\n 're-export-named',\n 're-export-type',\n]\n","import {compare} from '../../lib/compare'\nimport {reExportGroupOrder} from './ReExportGroupOrder'\nimport type {CategorizedReExport} from './CategorizedReExport'\nimport type {ReExportError} from './ReExportError'\n\nexport function checkAlphabeticalSorting(categorized: CategorizedReExport[]): ReExportError[] {\n const errors: ReExportError[] = []\n\n for (const group of reExportGroupOrder) {\n const groupReExports = categorized.filter(c => c.group === group)\n const sorted = [...groupReExports].sort((a, b) =>\n compare(a.sortKey, b.sortKey),\n )\n for (let i = 0; i < groupReExports.length; i++) {\n if (groupReExports[i] !== sorted[i]) {\n errors.push({\n node: groupReExports[i].declaration,\n messageId: 'sortedReExports',\n })\n }\n }\n }\n\n return errors\n}\n","import {reExportGroupOrder} from './ReExportGroupOrder'\nimport type {CategorizedReExport} from './CategorizedReExport'\nimport type {ReExportError} from './ReExportError'\n\nexport function checkGroupOrdering(categorized: CategorizedReExport[]): ReExportError[] {\n const errors: ReExportError[] = []\n\n let currentGroupIndex = -1\n for (const {declaration, group} of categorized) {\n const groupIndex = reExportGroupOrder.indexOf(group)\n if (groupIndex < currentGroupIndex) {\n errors.push({\n node: declaration,\n messageId: 'wrongGroup',\n })\n } else\n currentGroupIndex = groupIndex\n }\n\n return errors\n}\n","import type {TSESTree} from '@typescript-eslint/types'\n\nexport function getSpecifierName(specifier: TSESTree.ExportSpecifier): string {\n return specifier.local.type === 'Identifier'\n ? specifier.local.name\n : String(specifier.local.value)\n}\n","import {compare} from '../../lib/compare'\nimport {getSpecifierName} from './getSpecifierName'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function areSpecifiersSorted(specifiers: TSESTree.ExportSpecifier[]): boolean {\n const names = specifiers.map(s => getSpecifierName(s))\n const sorted = [...names].sort((a, b) => compare(a, b))\n return names.every((name, i) => name === sorted[i])\n}\n","import type {TSESTree} from '@typescript-eslint/types'\n\nexport function getNamedSpecifiers(\n declaration: TSESTree.ExportNamedDeclaration,\n): TSESTree.ExportSpecifier[] {\n return declaration.specifiers.filter(\n s => s.type === 'ExportSpecifier' && s.local.type === 'Identifier',\n ) as TSESTree.ExportSpecifier[]\n}\n","import {CategorizedNamedReExport} from './CategorizedNamedReExport'\nimport type {CategorizedReExport} from './CategorizedReExport'\n\nexport function isNamedReExport(x: CategorizedReExport): x is CategorizedNamedReExport {\n return x.group !== 're-export-all'\n}\n","import {areSpecifiersSorted} from './areSpecifiersSorted'\nimport {getNamedSpecifiers} from './getNamedSpecifiers'\nimport {isNamedReExport} from './isNamedReExport'\nimport type {CategorizedReExport} from './CategorizedReExport'\nimport type {ReExportError} from './ReExportError'\n\nexport function checkSpecifiersSorting(categorized: CategorizedReExport[]): ReExportError[] {\n const errors: ReExportError[] = []\n const namedReExports = categorized.filter(isNamedReExport)\n\n for (const {declaration} of namedReExports) {\n const specifiers = getNamedSpecifiers(declaration)\n const isSorted = areSpecifiersSorted(specifiers)\n if (specifiers.length > 1 && !isSorted) {\n errors.push({\n node: declaration,\n messageId: 'sortedNames',\n })\n }\n }\n\n return errors\n}\n","import {compare} from '../../lib/compare'\nimport {getSpecifierName} from './getSpecifierName'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function sortSpecifiersText(\n specifiers: TSESTree.ExportSpecifier[],\n sourceCode: {getText: (node?: unknown) => string},\n): string {\n const sorted = [...specifiers].sort((a, b) => {\n const nameA = getSpecifierName(a)\n const nameB = getSpecifierName(b)\n return compare(nameA, nameB)\n })\n return sorted.map(s => sourceCode.getText(s)).join(', ')\n}\n","import {areSpecifiersSorted} from '../areSpecifiersSorted'\nimport {getNamedSpecifiers} from '../getNamedSpecifiers'\nimport {sortSpecifiersText} from '../sortSpecifiersText'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function formatNamedReExport(\n declaration: TSESTree.ExportNamedDeclaration,\n sourceCode: {getText: (node?: unknown) => string},\n): string {\n const specifiers = getNamedSpecifiers(declaration)\n\n if (specifiers.length > 1 && !areSpecifiersSorted(specifiers)) {\n const sortedSpecifiers = sortSpecifiersText(specifiers, sourceCode)\n const source = declaration.source!.value\n const prefix = declaration.exportKind === 'type' ? 'export type ' : 'export '\n return `${prefix}{${sortedSpecifiers}} from '${source}'`\n }\n\n return sourceCode.getText(declaration)\n}\n","import {formatNamedReExport} from './formatNamedReExport'\nimport {isNamedReExport} from '../isNamedReExport'\nimport {reExportGroupOrder} from '../ReExportGroupOrder'\nimport type {CategorizedReExport} from '../CategorizedReExport'\nimport type {ReExportGroup} from '../ReExportGroup'\n\nexport function buildSortedCode(\n grouped: Record<ReExportGroup, CategorizedReExport[]>,\n sourceCode: {getText: (node?: unknown) => string},\n): string[] {\n const sortedCode: string[] = []\n\n for (const group of reExportGroupOrder) {\n for (const item of grouped[group]) {\n if (isNamedReExport(item)) {\n sortedCode.push(\n formatNamedReExport(\n item.declaration,\n sourceCode,\n ),\n )\n } else\n sortedCode.push(sourceCode.getText(item.declaration))\n }\n }\n\n return sortedCode\n}\n","import type {CategorizedReExport} from '../CategorizedReExport'\nimport type {ReExportGroup} from '../ReExportGroup'\n\nexport function groupReExportsByType(\n categorized: CategorizedReExport[],\n): Record<ReExportGroup, CategorizedReExport[]> {\n const grouped: Record<ReExportGroup, CategorizedReExport[]> = {\n 're-export-all': [],\n 're-export-named': [],\n 're-export-type': [],\n }\n\n for (const item of categorized)\n grouped[item.group].push(item)\n\n return grouped\n}\n","import {compare} from '../../../lib/compare'\nimport type {CategorizedReExport} from '../CategorizedReExport'\nimport type {ReExportGroup} from '../ReExportGroup'\n\nexport function sortExportGroups(\n grouped: Record<ReExportGroup, CategorizedReExport[]>,\n): void {\n grouped['re-export-all'].sort((a, b) => compare(a.sortKey, b.sortKey))\n grouped['re-export-named'].sort((a, b) => compare(a.sortKey, b.sortKey))\n grouped['re-export-type'].sort((a, b) => compare(a.sortKey, b.sortKey))\n}\n","import {buildSortedCode} from './buildSortedCode'\nimport {categorizeReExports} from '../categorizeReExports'\nimport {groupReExportsByType} from './groupReExportsByType'\nimport {ReExportDeclaration} from '../ReExportDeclaration'\nimport {sortExportGroups} from './sortExportGroups'\nimport type {Rule} from 'eslint'\n\nfunction createFixForGroup(\n fixer: Rule.RuleFixer,\n reExportDeclarations: ReExportDeclaration[],\n sourceCode: {getText: (node?: unknown) => string},\n): Rule.Fix | null {\n if (reExportDeclarations.length === 0) {\n return null\n }\n\n const categorized = categorizeReExports(reExportDeclarations)\n const grouped = groupReExportsByType(categorized)\n\n sortExportGroups(grouped)\n\n const sortedCode = buildSortedCode(grouped, sourceCode)\n .join('\\n')\n\n const firstReExport = reExportDeclarations[0]\n const lastReExport = reExportDeclarations[reExportDeclarations.length - 1]\n\n return fixer.replaceTextRange(\n [firstReExport.range![0], lastReExport.range![1]],\n sortedCode,\n )\n}\n\nexport function createFix(\n fixer: Rule.RuleFixer,\n reExportGroups: ReExportDeclaration[][],\n sourceCode: {getText: (node?: unknown) => string},\n): Rule.Fix[] {\n const fixes: Rule.Fix[] = []\n\n for (const group of reExportGroups) {\n const fix = createFixForGroup(fixer, group, sourceCode)\n if (fix)\n fixes.push(fix)\n }\n\n return fixes\n}\n","import type {ReExportDeclaration} from './ReExportDeclaration'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nfunction isReExportDeclaration(\n statement: TSESTree.ProgramStatement,\n): statement is ReExportDeclaration {\n return (statement.type === 'ExportNamedDeclaration' && statement.source !== null)\n || statement.type === 'ExportAllDeclaration'\n}\n\nexport function getReExportGroups(\n programBody: TSESTree.ProgramStatement[],\n): ReExportDeclaration[][] {\n const groups: ReExportDeclaration[][] = []\n let currentGroup: ReExportDeclaration[] = []\n\n for (const statement of programBody) {\n if (isReExportDeclaration(statement)) {\n currentGroup.push(statement)\n continue\n }\n\n if (currentGroup.length > 0) {\n groups.push(currentGroup)\n currentGroup = []\n }\n }\n\n if (currentGroup.length > 0)\n groups.push(currentGroup)\n\n return groups\n}\n","import {categorizeReExports} from './categorizeReExports'\nimport {checkAlphabeticalSorting} from './checkAlphabeticalSorting'\nimport {checkGroupOrdering} from './checkGroupOrdering'\nimport {checkSpecifiersSorting} from './checkSpecifiersSorting'\nimport {createFix} from './createFix'\nimport {getReExportGroups} from './getReExportGroups'\nimport type {ReExportError} from './ReExportError'\nimport type {Rule} from 'eslint'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport const sortedReExports: Rule.RuleModule = {\n meta: {\n docs: {\n description: 'Enforce sorted exports alphabetically',\n recommended: true,\n },\n fixable: 'code',\n messages: {\n sortedReExports: 'Exports should be sorted alphabetically',\n sortedNames: 'Named exports should be sorted alphabetically',\n wrongGroup: 'Export is in wrong group',\n },\n schema: [],\n type: 'suggestion',\n },\n create(context) {\n return {\n Program(node) {\n const body = node.body as TSESTree.ProgramStatement[]\n const reExportGroups = getReExportGroups(body)\n if (reExportGroups.length === 0)\n return\n\n const allErrors: ReExportError[] = []\n\n // Check each re-export group independently\n for (const group of reExportGroups) {\n const categorized = categorizeReExports(group)\n const errors: ReExportError[] = [\n ...checkGroupOrdering(categorized),\n ...checkAlphabeticalSorting(categorized),\n ...checkSpecifiersSorting(categorized),\n ]\n allErrors.push(...errors)\n }\n\n for (const error of allErrors) {\n context.report({\n node: error.node,\n messageId: error.messageId,\n fix(fixer) {\n const sourceCode = context.sourceCode\n return createFix(fixer, reExportGroups, sourceCode)\n },\n })\n }\n },\n }\n },\n}\n"],"mappings":";AAAA,OAAO,YAAY;AACnB,OAAO,WAAW;AAClB,OAAO,gBAAgB;AACvB,OAAO,eAAe;AACtB,OAAO,gBAAgB;AACvB,SAAQ,oBAAmB;;;ACFpB,SAAS,iBAAiB,WAA8C;AAC7E,MAAI,UAAU,SAAS;AACrB,WAAO;AAET,MAAI,UAAU,SAAS;AACrB,WAAO;AAET,MAAI,UAAU,SAAS,0BAA0B;AAC/C,QAAI,UAAU,WAAW;AACvB,aAAO;AAAA,EACX;AAEA,SAAO;AACT;;;ACXO,SAAS,qBACd,YACuB;AACvB,QAAM,SAAgC;AAAA,IACpC,SAAS,CAAC;AAAA,IACV,WAAW,CAAC;AAAA,IACZ,OAAO,CAAC;AAAA,EACV;AAEA,aAAW,aAAa,YAAY;AAClC,UAAM,OAAO,iBAAiB,SAAS;AAEvC,QAAI,SAAS;AACX,aAAO,QAAQ,KAAK,SAAuC;AAAA,aACpD,SAAS;AAChB,aAAO,UAAU,KAAK,SAAqB;AAAA;AAE3C,aAAO,MAAM,KAAK,SAAS;AAAA,EAC/B;AAEA,SAAO;AACT;;;ACrBO,SAAS,iBACd,YACkB;AAClB,MAAI,cAAc;AAClB,MAAI,gBAAgB;AACpB,MAAI,aAAa;AAEjB,WAAS,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;AAC1C,UAAM,OAAsB,iBAAiB,WAAW,CAAC,CAAC;AAE1D,QAAI,SAAS,YAAY,gBAAgB;AACvC,oBAAc;AAAA,aACP,SAAS,eAAe,kBAAkB;AACjD,sBAAgB;AAAA,aACT,SAAS,WAAW,eAAe;AAC1C,mBAAa;AAAA,EACjB;AAEA,SAAO,EAAC,aAAa,eAAe,WAAU;AAChD;;;ACnBO,SAAS,mBACd,SACA,YAC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AA,MACF;AAAA,MACA,iCAAiC;AAAA,QAC/B;AAAA,QACA;AAAA,QACA,EAAC,WAAW,EAAC,KAAK,QAAO,EAAC;AAAA,MAC5B;AAAA,MACA,qBAAqB;AAAA,QACnB;AAAA,QACA;AAAA,QACA,EAAC,aAAa,KAAI;AAAA,MACpB;AAAA,MACA,0BAA0B;AAAA,QACxB;AAAA,QACA;AAAA,MACF;AAAA,MACA,mBAAmB;AAAA,QACjB;AAAA,QACA;AAAA,QACA,EAAC,kCAAkC,SAAQ;AAAA,MAC7C;AAAA,MACA,wCAAwC;AAAA,MACxC,sDAAsD;AAAA,IACxD;AAAA,EACF;AACF,CAAC;","names":["getSortKey","getSortKey","checkAlphabeticalSorting","checkGroupOrdering","getSpecifierName","areSpecifiersSorted","getSpecifierName","getNamedSpecifiers","checkSpecifiersSorting","getNamedSpecifiers","areSpecifiersSorted","sortSpecifiersText","getSpecifierName","getNamedSpecifiers","areSpecifiersSorted","sortSpecifiersText","buildSortedCode","createFixForGroup","buildSortedCode","createFix","checkGroupOrdering","checkAlphabeticalSorting","checkSpecifiersSorting","createFix"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/rules/importsAndReExportsAtTop/getStatementType.ts","../src/rules/importsAndReExportsAtTop/categorizeStatements.ts","../src/rules/importsAndReExportsAtTop/findStatementIndices.ts","../src/rules/importsAndReExportsAtTop/generateSortedText.ts","../src/rules/importsAndReExportsAtTop/hasViolation.ts","../src/rules/importsAndReExportsAtTop/index.ts","../src/rules/individualImports.ts","../src/rules/individualReExports.ts","../src/rules/sortedImports/categorizeImport.ts","../src/rules/sortedImports/getSortKey.ts","../src/rules/sortedImports/categorizeImports.ts","../src/lib/compare.ts","../src/rules/sortedImports/ImportGroupOrder.ts","../src/rules/sortedImports/checkAlphabeticalSorting.ts","../src/rules/sortedImports/checkGroupOrdering.ts","../src/rules/sortedImports/getSpecifierName.ts","../src/rules/sortedImports/areSpecifiersSorted.ts","../src/rules/sortedImports/getNamedSpecifiers.ts","../src/rules/sortedImports/checkSpecifiersSorting.ts","../src/rules/sortedImports/sortSpecifiersText.ts","../src/rules/sortedImports/createFix/formatNamedImport.ts","../src/rules/sortedImports/createFix/buildSortedCode.ts","../src/rules/sortedImports/createFix/groupImportsByType.ts","../src/rules/sortedImports/createFix/sortImportGroups.ts","../src/rules/sortedImports/createFix/index.ts","../src/rules/sortedImports/getImportGroups.ts","../src/rules/sortedImports/index.ts","../src/rules/sortedReExports/categorizeReExport.ts","../src/rules/sortedReExports/getSortKey.ts","../src/rules/sortedReExports/categorizeReExports.ts","../src/rules/sortedReExports/ReExportGroupOrder.ts","../src/rules/sortedReExports/checkAlphabeticalSorting.ts","../src/rules/sortedReExports/checkGroupOrdering.ts","../src/rules/sortedReExports/getSpecifierName.ts","../src/rules/sortedReExports/areSpecifiersSorted.ts","../src/rules/sortedReExports/getNamedSpecifiers.ts","../src/rules/sortedReExports/isNamedReExport.ts","../src/rules/sortedReExports/checkSpecifiersSorting.ts","../src/rules/sortedReExports/sortSpecifiersText.ts","../src/rules/sortedReExports/createFix/formatNamedReExport.ts","../src/rules/sortedReExports/createFix/buildSortedCode.ts","../src/rules/sortedReExports/createFix/groupReExportsByType.ts","../src/rules/sortedReExports/createFix/sortExportGroups.ts","../src/rules/sortedReExports/createFix/index.ts","../src/rules/sortedReExports/getReExportGroups.ts","../src/rules/sortedReExports/index.ts"],"sourcesContent":["import eslint from '@eslint/js'\nimport react from 'eslint-plugin-react'\nimport reactHooks from 'eslint-plugin-react-hooks'\nimport stylistic from '@stylistic/eslint-plugin'\nimport typescript from 'typescript-eslint'\nimport {defineConfig} from 'eslint/config'\nimport {importsAndReExportsAtTop} from './rules/importsAndReExportsAtTop'\nimport {individualImports} from './rules/individualImports'\nimport {individualReExports} from './rules/individualReExports'\nimport {sortedImports} from './rules/sortedImports'\nimport {sortedReExports} from './rules/sortedReExports'\n\nexport const CONFIG = defineConfig([\n {\n ignores: [\n 'src/graphql/sdk.ts',\n '**/node_modules/**',\n '**/dist/**',\n ],\n },\n {\n settings: {\n react: {\n version: '19',\n },\n },\n },\n eslint.configs.recommended,\n react.configs.flat.recommended,\n stylistic.configs.recommended,\n typescript.configs.recommended,\n typescript.configs.stylistic,\n {\n plugins: {\n 'react-hooks': reactHooks,\n },\n rules: reactHooks.configs.recommended.rules,\n },\n {\n plugins: {\n '@borela-tech': {\n rules: {\n 'imports-and-re-exports-at-top': importsAndReExportsAtTop,\n 'individual-imports': individualImports,\n 'individual-re-exports': individualReExports,\n 'sorted-imports': sortedImports,\n 'sorted-re-exports': sortedReExports,\n },\n },\n },\n rules: {\n '@borela-tech/imports-and-re-exports-at-top': 'error',\n '@borela-tech/individual-imports': 'error',\n '@borela-tech/individual-re-exports': 'error',\n '@borela-tech/sorted-imports': 'error',\n '@borela-tech/sorted-re-exports': 'error',\n },\n },\n {\n rules: {\n 'capitalized-comments': [\n 'error',\n 'always',\n {ignoreConsecutiveComments: true},\n ],\n 'react/react-in-jsx-scope': 'off',\n '@stylistic/arrow-parens': [\n 'error',\n 'as-needed',\n ],\n '@stylistic/array-bracket-newline': [\n 'error',\n 'consistent',\n ],\n '@stylistic/array-bracket-spacing': [\n 'error',\n 'never',\n ],\n '@stylistic/array-element-newline': [\n 'error',\n 'consistent',\n ],\n '@stylistic/block-spacing': 'off',\n '@stylistic/brace-style': [\n 'error',\n '1tbs',\n {allowSingleLine: true},\n ],\n '@stylistic/indent': [\n 'error',\n 2,\n {ignoredNodes: ['TSMappedType > *']},\n ],\n '@stylistic/jsx-tag-spacing': [\n 'error',\n {\n afterOpening: 'never',\n beforeClosing: 'never',\n beforeSelfClosing: 'never',\n closingSlash: 'never',\n },\n ],\n '@stylistic/jsx-wrap-multilines': 'off',\n '@stylistic/lines-between-class-members': 'off',\n '@stylistic/object-curly-newline': [\n 'error',\n {consistent: true},\n ],\n '@stylistic/object-curly-spacing': [\n 'error',\n 'never',\n ],\n '@stylistic/operator-linebreak': [\n 'error',\n 'before',\n {overrides: {'=': 'after'}},\n ],\n '@stylistic/quotes': [\n 'error',\n 'single',\n {avoidEscape: true},\n ],\n '@stylistic/quote-props': [\n 'error',\n 'as-needed',\n ],\n '@stylistic/semi': [\n 'error',\n 'never',\n {beforeStatementContinuationChars: 'always'},\n ],\n '@typescript-eslint/no-empty-function': 'off',\n '@typescript-eslint/consistent-indexed-object-style': 'off',\n },\n },\n])\n","import {StatementType} from './statementType'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function getStatementType(statement: TSESTree.Statement): StatementType {\n if (statement.type === 'ImportDeclaration')\n return 'import'\n\n if (statement.type === 'ExportAllDeclaration')\n return 're-export'\n\n if (statement.type === 'ExportNamedDeclaration') {\n if (statement.source !== null)\n return 're-export'\n }\n\n return 'other'\n}\n","import {getStatementType} from './getStatementType'\nimport {ReExport} from './ReExport'\nimport type {CategorizedStatements} from './CategorizedStatements'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function categorizeStatements(\n statements: TSESTree.Statement[],\n): CategorizedStatements {\n const result: CategorizedStatements = {\n imports: [],\n reExports: [],\n other: [],\n }\n\n for (const statement of statements) {\n const type = getStatementType(statement)\n\n if (type === 'import')\n result.imports.push(statement as TSESTree.ImportDeclaration)\n else if (type === 're-export')\n result.reExports.push(statement as ReExport)\n else\n result.other.push(statement)\n }\n\n return result\n}\n","import {getStatementType} from './getStatementType'\nimport type {StatementIndices} from './StatementIndices'\nimport type {StatementType} from './statementType'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function findStatementIndices(\n statements: TSESTree.Statement[],\n): StatementIndices {\n let firstRegularStatement = -1\n let lastImport = -1\n let lastReExport = -1\n\n for (let i = 0; i < statements.length; i++) {\n const type: StatementType = getStatementType(statements[i])\n\n if (type === 'import')\n lastImport = i\n else if (type === 're-export')\n lastReExport = i\n else if (type === 'other' && firstRegularStatement === -1)\n firstRegularStatement = i\n }\n\n return {firstRegularStatement, lastImport, lastReExport}\n}\n","import {Rule} from 'eslint'\nimport type {CategorizedStatements} from './CategorizedStatements'\nimport type {Node as ESTreeNode} from 'estree'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function generateSortedText(\n context: Rule.RuleContext,\n categories: CategorizedStatements,\n): string {\n const allStatements: TSESTree.Node[] = [\n ...categories.imports,\n ...categories.reExports,\n ...categories.other,\n ]\n return allStatements.map(\n node => context.sourceCode.getText(node as ESTreeNode),\n ).join('\\n')\n}\n","import type {CategorizedStatements} from './CategorizedStatements'\nimport type {StatementIndices} from './StatementIndices'\n\nexport function hasViolation(\n indices: StatementIndices,\n categories: CategorizedStatements,\n): boolean {\n const {firstRegularStatement, lastImport, lastReExport} = indices\n\n if (categories.imports.length === 0 && categories.reExports.length === 0)\n return false\n\n const hasImportAfterRegularStatement = (\n categories.imports.length > 0\n && firstRegularStatement !== -1\n && lastImport > firstRegularStatement\n )\n const hasReExportAfterRegularStatement = (\n categories.reExports.length > 0\n && firstRegularStatement !== -1\n && lastReExport > firstRegularStatement\n )\n\n return hasImportAfterRegularStatement || hasReExportAfterRegularStatement\n}\n","import {categorizeStatements} from './categorizeStatements'\nimport {findStatementIndices} from './findStatementIndices'\nimport {generateSortedText} from './generateSortedText'\nimport {hasViolation} from './hasViolation'\nimport type {Rule} from 'eslint'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport const importsAndReExportsAtTop: Rule.RuleModule = {\n meta: {\n type: 'suggestion',\n docs: {\n description: 'Enforce imports and re-exports at the top of the file',\n recommended: false,\n },\n fixable: 'code',\n messages: {\n importsAndReExportsAtTop:\n 'Imports and re-exports should be at the top of the file.',\n },\n schema: [],\n },\n\n create(context) {\n return {\n Program(node) {\n const statements = node.body as TSESTree.Statement[]\n const categories = categorizeStatements(statements)\n const indices = findStatementIndices(statements)\n\n if (!hasViolation(indices, categories))\n return\n\n context.report({\n node,\n messageId: 'importsAndReExportsAtTop',\n\n fix(fixer) {\n const sortedText = generateSortedText(context, categories)\n return fixer.replaceText(node, sortedText)\n },\n })\n },\n }\n },\n}\n","import type {Rule} from 'eslint'\n\nexport const individualImports: Rule.RuleModule = {\n meta: {\n docs: {\n description: 'Enforce individual imports instead of grouped imports',\n recommended: true,\n },\n fixable: 'code',\n messages: {\n individualImports: 'Use individual imports instead of grouped imports.',\n },\n schema: [],\n type: 'suggestion',\n },\n create(context) {\n return {\n ImportDeclaration(node) {\n if (node.specifiers.length <= 1)\n return\n\n context.report({\n node,\n messageId: 'individualImports',\n fix(fixer) {\n const source = node.source.raw\n const specifiers = node.specifiers\n .filter(s => s.type === 'ImportSpecifier')\n .map(s => `import {${s.local.name}} from ${source}`)\n .join('\\n')\n return fixer.replaceText(node, specifiers)\n },\n })\n },\n }\n },\n}\n","import type {Rule} from 'eslint'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport const individualReExports: Rule.RuleModule = {\n meta: {\n docs: {\n description: 'Enforce individual exports instead of grouped exports',\n recommended: true,\n },\n fixable: 'code',\n messages: {\n individualReExports: 'Use individual exports instead of grouped exports.',\n },\n schema: [],\n type: 'suggestion',\n },\n create(context) {\n return {\n ExportNamedDeclaration(node) {\n const exportNode = node as TSESTree.ExportNamedDeclaration\n if (!exportNode.source || exportNode.specifiers.length <= 1)\n return\n\n context.report({\n node,\n messageId: 'individualReExports',\n fix(fixer) {\n const source = exportNode.source!.value\n const typeKeyword = exportNode.exportKind === 'type'\n ? 'type '\n : ''\n const specifiers = exportNode.specifiers\n .map(s => {\n const localName = s.local.type === 'Identifier'\n ? s.local.name\n : s.local.value\n const exportedName = s.exported.type === 'Identifier'\n ? s.exported.name\n : s.exported.value\n const name = localName === exportedName\n ? localName\n : `${localName} as ${exportedName}`\n return `export ${typeKeyword}{${name}} from '${source}'`\n })\n .join('\\n')\n return fixer.replaceText(node, specifiers)\n },\n })\n },\n }\n },\n}\n","import type {ImportGroup} from './ImportGroup'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function categorizeImport(declaration: TSESTree.ImportDeclaration): ImportGroup {\n // Example: import type {Type} from 'module'\n if (declaration.importKind === 'type')\n return 'type'\n\n // Example: import 'module'\n if (declaration.specifiers.length === 0)\n return 'side-effect'\n\n // Example: import value from 'module'\n if (declaration.specifiers.some(s => s.type === 'ImportDefaultSpecifier'))\n return 'default'\n\n // Example: import {value} from 'module'\n return 'named'\n}\n","import {categorizeImport} from './categorizeImport'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function getSortKey(declaration: TSESTree.ImportDeclaration): string {\n const group = categorizeImport(declaration)\n\n if (group === 'side-effect')\n return declaration.source.value\n\n if (group === 'default') {\n const defaultSpecifier = declaration.specifiers.find(\n s => s.type === 'ImportDefaultSpecifier',\n ) as TSESTree.ImportDefaultSpecifier | undefined\n\n return defaultSpecifier?.local.name ?? ''\n }\n\n const specifier = declaration.specifiers[0]\n return specifier.local.name\n}\n","import {categorizeImport} from './categorizeImport'\nimport {getSortKey} from './getSortKey'\nimport type {CategorizedImport} from './CategorizedImport'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function categorizeImports(declarations: TSESTree.ImportDeclaration[]): CategorizedImport[] {\n return declarations.map(declaration => ({\n declaration,\n group: categorizeImport(declaration),\n sortKey: getSortKey(declaration),\n }))\n}\n","export function compare(a: string, b: string): number {\n return a.localeCompare(b, 'en', {sensitivity: 'case'})\n}\n","import {ImportGroup} from './ImportGroup'\n\nexport const importGroupOrder: ImportGroup[] = [\n 'side-effect',\n 'default',\n 'named',\n 'type',\n]\n","import {compare} from '../../lib/compare'\nimport {importGroupOrder} from './ImportGroupOrder'\nimport type {CategorizedImport} from './CategorizedImport'\nimport type {ImportError} from './ImportError'\n\nexport function checkAlphabeticalSorting(categorized: CategorizedImport[]): ImportError[] {\n const errors: ImportError[] = []\n\n for (const group of importGroupOrder) {\n const groupImports = categorized.filter(c => c.group === group)\n const sorted = [...groupImports].sort((a, b) => compare(a.sortKey, b.sortKey))\n for (let i = 0; i < groupImports.length; i++) {\n if (groupImports[i] !== sorted[i]) {\n errors.push({\n node: groupImports[i].declaration,\n messageId: 'sortedImports',\n })\n }\n }\n }\n\n return errors\n}\n","import {importGroupOrder} from './ImportGroupOrder'\nimport type {CategorizedImport} from './CategorizedImport'\nimport type {ImportError} from './ImportError'\n\nexport function checkGroupOrdering(categorized: CategorizedImport[]): ImportError[] {\n const errors: ImportError[] = []\n\n let currentGroupIndex = -1\n for (const {declaration, group} of categorized) {\n const groupIndex = importGroupOrder.indexOf(group)\n if (groupIndex < currentGroupIndex) {\n errors.push({\n node: declaration,\n messageId: 'wrongGroup',\n })\n } else\n currentGroupIndex = groupIndex\n }\n\n return errors\n}\n","import type {TSESTree} from '@typescript-eslint/types'\n\nexport function getSpecifierName(specifier: TSESTree.ImportSpecifier): string {\n return specifier.imported.type === 'Identifier'\n ? specifier.imported.name\n : String(specifier.imported.value)\n}\n","import {compare} from '../../lib/compare'\nimport {getSpecifierName} from './getSpecifierName'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function areSpecifiersSorted(specifiers: TSESTree.ImportSpecifier[]): boolean {\n const names = specifiers.map(s => getSpecifierName(s))\n const sorted = [...names].sort((a, b) => compare(a, b))\n return names.every((name, i) => name === sorted[i])\n}\n","import type {TSESTree} from '@typescript-eslint/types'\n\nexport function getNamedSpecifiers(declaration: TSESTree.ImportDeclaration): TSESTree.ImportSpecifier[] {\n return declaration.specifiers.filter(\n (s): s is TSESTree.ImportSpecifier => s.type === 'ImportSpecifier',\n )\n}\n","import {areSpecifiersSorted} from './areSpecifiersSorted'\nimport {getNamedSpecifiers} from './getNamedSpecifiers'\nimport type {CategorizedImport} from './CategorizedImport'\nimport type {ImportError} from './ImportError'\n\nexport function checkSpecifiersSorting(categorized: CategorizedImport[]): ImportError[] {\n const errors: ImportError[] = []\n const namedImports = categorized.filter(c => c.group === 'named')\n\n for (const {declaration} of namedImports) {\n const specifiers = getNamedSpecifiers(declaration)\n if (specifiers.length > 1 && !areSpecifiersSorted(specifiers)) {\n errors.push({\n node: declaration,\n messageId: 'sortedNames',\n })\n }\n }\n\n return errors\n}\n","import {compare} from '../../lib/compare'\nimport {getSpecifierName} from './getSpecifierName'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function sortSpecifiersText(\n specifiers: TSESTree.ImportSpecifier[],\n sourceCode: {getText: (node: TSESTree.ImportSpecifier) => string},\n): string {\n const sorted = [...specifiers].sort((a, b) => {\n const nameA = getSpecifierName(a)\n const nameB = getSpecifierName(b)\n return compare(nameA, nameB)\n })\n return sorted.map(s => sourceCode.getText(s)).join(', ')\n}\n","import {areSpecifiersSorted} from '../areSpecifiersSorted'\nimport {getNamedSpecifiers} from '../getNamedSpecifiers'\nimport {sortSpecifiersText} from '../sortSpecifiersText'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function formatNamedImport(\n declaration: TSESTree.ImportDeclaration,\n sourceCode: {getText: (node?: unknown) => string},\n): string {\n const specifiers = getNamedSpecifiers(declaration)\n\n if (specifiers.length > 1 && !areSpecifiersSorted(specifiers)) {\n const sortedSpecifiers = sortSpecifiersText(specifiers, sourceCode)\n const source = declaration.source.value\n const prefix = declaration.importKind === 'type' ? 'import type ' : 'import '\n return `${prefix}{${sortedSpecifiers}} from '${source}'`\n }\n\n return sourceCode.getText(declaration)\n}\n","import {formatNamedImport} from './formatNamedImport'\nimport {importGroupOrder} from '../ImportGroupOrder'\nimport type {CategorizedImport} from '../CategorizedImport'\nimport type {ImportGroup} from '../ImportGroup'\n\nexport function buildSortedCode(\n grouped: Record<ImportGroup, CategorizedImport[]>,\n sourceCode: {getText: (node?: unknown) => string},\n): string[] {\n const sortedCode: string[] = []\n\n for (const group of importGroupOrder) {\n for (const {declaration} of grouped[group]) {\n if (group === 'named' || group === 'type')\n sortedCode.push(formatNamedImport(declaration, sourceCode))\n else\n sortedCode.push(sourceCode.getText(declaration))\n }\n }\n\n return sortedCode\n}\n","import type {CategorizedImport} from '../CategorizedImport'\nimport type {ImportGroup} from '../ImportGroup'\n\nexport function groupImportsByType(\n categorized: CategorizedImport[],\n): Record<ImportGroup, CategorizedImport[]> {\n const grouped: Record<ImportGroup, CategorizedImport[]> = {\n 'side-effect': [],\n default: [],\n named: [],\n type: [],\n }\n\n for (const item of categorized)\n grouped[item.group].push(item)\n\n return grouped\n}\n","import {compare} from '../../../lib/compare'\nimport type {CategorizedImport} from '../CategorizedImport'\nimport type {ImportGroup} from '../ImportGroup'\n\nexport function sortImportGroups(\n grouped: Record<ImportGroup, CategorizedImport[]>,\n): void {\n grouped['side-effect'].sort((a, b) => compare(a.sortKey, b.sortKey))\n grouped['default'].sort((a, b) => compare(a.sortKey, b.sortKey))\n grouped['named'].sort((a, b) => compare(a.sortKey, b.sortKey))\n grouped['type'].sort((a, b) => compare(a.sortKey, b.sortKey))\n}\n","import {buildSortedCode} from './buildSortedCode'\nimport {categorizeImports} from '../categorizeImports'\nimport {groupImportsByType} from './groupImportsByType'\nimport {sortImportGroups} from './sortImportGroups'\nimport type {Rule} from 'eslint'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nfunction createFixForGroup(\n fixer: Rule.RuleFixer,\n importDeclarations: TSESTree.ImportDeclaration[],\n sourceCode: {getText: (node?: unknown) => string},\n): Rule.Fix | null {\n if (importDeclarations.length === 0) {\n return null\n }\n\n const categorized = categorizeImports(importDeclarations)\n const grouped = groupImportsByType(categorized)\n\n sortImportGroups(grouped)\n\n const sortedCode = buildSortedCode(grouped, sourceCode)\n .join('\\n')\n\n const firstImport = importDeclarations[0]\n const lastImport = importDeclarations[importDeclarations.length - 1]\n\n return fixer.replaceTextRange(\n [firstImport.range![0], lastImport.range![1]],\n sortedCode,\n )\n}\n\nexport function createFix(\n fixer: Rule.RuleFixer,\n importGroups: TSESTree.ImportDeclaration[][],\n sourceCode: {getText: (node?: unknown) => string},\n): Rule.Fix[] {\n const fixes: Rule.Fix[] = []\n\n for (const group of importGroups) {\n const fix = createFixForGroup(fixer, group, sourceCode)\n if (fix)\n fixes.push(fix)\n }\n\n return fixes\n}\n","import type {TSESTree} from '@typescript-eslint/types'\n\nexport function getImportGroups(programBody: TSESTree.ProgramStatement[]): TSESTree.ImportDeclaration[][] {\n const groups: TSESTree.ImportDeclaration[][] = []\n let currentGroup: TSESTree.ImportDeclaration[] = []\n\n for (const statement of programBody) {\n if (statement.type === 'ImportDeclaration') {\n currentGroup.push(statement)\n continue\n }\n\n if (currentGroup.length > 0) {\n groups.push(currentGroup)\n currentGroup = []\n }\n }\n\n if (currentGroup.length > 0)\n groups.push(currentGroup)\n\n return groups\n}\n","import {categorizeImports} from './categorizeImports'\nimport {checkAlphabeticalSorting} from './checkAlphabeticalSorting'\nimport {checkGroupOrdering} from './checkGroupOrdering'\nimport {checkSpecifiersSorting} from './checkSpecifiersSorting'\nimport {createFix} from './createFix'\nimport {getImportGroups} from './getImportGroups'\nimport type {ImportError} from './ImportError'\nimport type {Rule} from 'eslint'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport const sortedImports: Rule.RuleModule = {\n meta: {\n docs: {\n description: 'Enforce sorted imports alphabetically',\n recommended: true,\n },\n fixable: 'code',\n messages: {\n sortedImports: 'Imports should be sorted alphabetically',\n sortedNames: 'Named imports should be sorted alphabetically',\n wrongGroup: 'Import is in wrong group',\n },\n schema: [],\n type: 'suggestion',\n },\n create(context) {\n return {\n Program(node) {\n const body = node.body as TSESTree.ProgramStatement[]\n const importGroups = getImportGroups(body)\n if (importGroups.length === 0)\n return\n\n const allErrors: ImportError[] = []\n\n // Check each import group independently\n for (const group of importGroups) {\n const categorized = categorizeImports(group)\n const errors: ImportError[] = [\n ...checkGroupOrdering(categorized),\n ...checkAlphabeticalSorting(categorized),\n ...checkSpecifiersSorting(categorized),\n ]\n allErrors.push(...errors)\n }\n\n for (const error of allErrors) {\n context.report({\n node: error.node,\n messageId: error.messageId,\n fix(fixer) {\n const sourceCode = context.sourceCode\n return createFix(fixer, importGroups, sourceCode)\n },\n })\n }\n },\n }\n },\n}\n","import type {ReExportGroup} from './ReExportGroup'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function categorizeReExport(\n declaration: TSESTree.ExportNamedDeclaration | TSESTree.ExportAllDeclaration,\n): ReExportGroup {\n // Example: export * from 'module'\n if (declaration.type === 'ExportAllDeclaration')\n return 're-export-all'\n\n // Example: export type {Type} from 'module'\n if (declaration.exportKind === 'type')\n return 're-export-type'\n\n // Example: export {value} from 'module'\n return 're-export-named'\n}\n","import type {TSESTree} from '@typescript-eslint/types'\n\nexport function getSortKey(\n declaration: TSESTree.ExportNamedDeclaration | TSESTree.ExportAllDeclaration,\n): string {\n if (declaration.type === 'ExportAllDeclaration')\n return declaration.source.value\n\n const specifier = declaration.specifiers[0]\n if (!specifier)\n return ''\n\n return specifier.local.type === 'Identifier'\n ? specifier.local.name\n : specifier.local.value\n}\n","import {categorizeReExport} from './categorizeReExport'\nimport {getSortKey} from './getSortKey'\nimport {ReExportDeclaration} from './ReExportDeclaration'\nimport type {CategorizedReExport} from './CategorizedReExport'\n\nexport function categorizeReExports(declarations: ReExportDeclaration[]): CategorizedReExport[] {\n return declarations.map(declaration => {\n return {\n declaration,\n group: categorizeReExport(declaration),\n sortKey: getSortKey(declaration),\n } as CategorizedReExport\n })\n}\n","import {ReExportGroup} from './ReExportGroup'\n\nexport const reExportGroupOrder: ReExportGroup[] = [\n 're-export-all',\n 're-export-named',\n 're-export-type',\n]\n","import {compare} from '../../lib/compare'\nimport {reExportGroupOrder} from './ReExportGroupOrder'\nimport type {CategorizedReExport} from './CategorizedReExport'\nimport type {ReExportError} from './ReExportError'\n\nexport function checkAlphabeticalSorting(categorized: CategorizedReExport[]): ReExportError[] {\n const errors: ReExportError[] = []\n\n for (const group of reExportGroupOrder) {\n const groupReExports = categorized.filter(c => c.group === group)\n const sorted = [...groupReExports].sort((a, b) =>\n compare(a.sortKey, b.sortKey),\n )\n for (let i = 0; i < groupReExports.length; i++) {\n if (groupReExports[i] !== sorted[i]) {\n errors.push({\n node: groupReExports[i].declaration,\n messageId: 'sortedReExports',\n })\n }\n }\n }\n\n return errors\n}\n","import {reExportGroupOrder} from './ReExportGroupOrder'\nimport type {CategorizedReExport} from './CategorizedReExport'\nimport type {ReExportError} from './ReExportError'\n\nexport function checkGroupOrdering(categorized: CategorizedReExport[]): ReExportError[] {\n const errors: ReExportError[] = []\n\n let currentGroupIndex = -1\n for (const {declaration, group} of categorized) {\n const groupIndex = reExportGroupOrder.indexOf(group)\n if (groupIndex < currentGroupIndex) {\n errors.push({\n node: declaration,\n messageId: 'wrongGroup',\n })\n } else\n currentGroupIndex = groupIndex\n }\n\n return errors\n}\n","import type {TSESTree} from '@typescript-eslint/types'\n\nexport function getSpecifierName(specifier: TSESTree.ExportSpecifier): string {\n return specifier.local.type === 'Identifier'\n ? specifier.local.name\n : String(specifier.local.value)\n}\n","import {compare} from '../../lib/compare'\nimport {getSpecifierName} from './getSpecifierName'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function areSpecifiersSorted(specifiers: TSESTree.ExportSpecifier[]): boolean {\n const names = specifiers.map(s => getSpecifierName(s))\n const sorted = [...names].sort((a, b) => compare(a, b))\n return names.every((name, i) => name === sorted[i])\n}\n","import type {TSESTree} from '@typescript-eslint/types'\n\nexport function getNamedSpecifiers(\n declaration: TSESTree.ExportNamedDeclaration,\n): TSESTree.ExportSpecifier[] {\n return declaration.specifiers.filter(\n s => s.type === 'ExportSpecifier' && s.local.type === 'Identifier',\n ) as TSESTree.ExportSpecifier[]\n}\n","import {CategorizedNamedReExport} from './CategorizedNamedReExport'\nimport type {CategorizedReExport} from './CategorizedReExport'\n\nexport function isNamedReExport(x: CategorizedReExport): x is CategorizedNamedReExport {\n return x.group !== 're-export-all'\n}\n","import {areSpecifiersSorted} from './areSpecifiersSorted'\nimport {getNamedSpecifiers} from './getNamedSpecifiers'\nimport {isNamedReExport} from './isNamedReExport'\nimport type {CategorizedReExport} from './CategorizedReExport'\nimport type {ReExportError} from './ReExportError'\n\nexport function checkSpecifiersSorting(categorized: CategorizedReExport[]): ReExportError[] {\n const errors: ReExportError[] = []\n const namedReExports = categorized.filter(isNamedReExport)\n\n for (const {declaration} of namedReExports) {\n const specifiers = getNamedSpecifiers(declaration)\n const isSorted = areSpecifiersSorted(specifiers)\n if (specifiers.length > 1 && !isSorted) {\n errors.push({\n node: declaration,\n messageId: 'sortedNames',\n })\n }\n }\n\n return errors\n}\n","import {compare} from '../../lib/compare'\nimport {getSpecifierName} from './getSpecifierName'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function sortSpecifiersText(\n specifiers: TSESTree.ExportSpecifier[],\n sourceCode: {getText: (node?: unknown) => string},\n): string {\n const sorted = [...specifiers].sort((a, b) => {\n const nameA = getSpecifierName(a)\n const nameB = getSpecifierName(b)\n return compare(nameA, nameB)\n })\n return sorted.map(s => sourceCode.getText(s)).join(', ')\n}\n","import {areSpecifiersSorted} from '../areSpecifiersSorted'\nimport {getNamedSpecifiers} from '../getNamedSpecifiers'\nimport {sortSpecifiersText} from '../sortSpecifiersText'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport function formatNamedReExport(\n declaration: TSESTree.ExportNamedDeclaration,\n sourceCode: {getText: (node?: unknown) => string},\n): string {\n const specifiers = getNamedSpecifiers(declaration)\n\n if (specifiers.length > 1 && !areSpecifiersSorted(specifiers)) {\n const sortedSpecifiers = sortSpecifiersText(specifiers, sourceCode)\n const source = declaration.source!.value\n const prefix = declaration.exportKind === 'type' ? 'export type ' : 'export '\n return `${prefix}{${sortedSpecifiers}} from '${source}'`\n }\n\n return sourceCode.getText(declaration)\n}\n","import {formatNamedReExport} from './formatNamedReExport'\nimport {isNamedReExport} from '../isNamedReExport'\nimport {reExportGroupOrder} from '../ReExportGroupOrder'\nimport type {CategorizedReExport} from '../CategorizedReExport'\nimport type {ReExportGroup} from '../ReExportGroup'\n\nexport function buildSortedCode(\n grouped: Record<ReExportGroup, CategorizedReExport[]>,\n sourceCode: {getText: (node?: unknown) => string},\n): string[] {\n const sortedCode: string[] = []\n\n for (const group of reExportGroupOrder) {\n for (const item of grouped[group]) {\n if (isNamedReExport(item)) {\n sortedCode.push(\n formatNamedReExport(\n item.declaration,\n sourceCode,\n ),\n )\n } else\n sortedCode.push(sourceCode.getText(item.declaration))\n }\n }\n\n return sortedCode\n}\n","import type {CategorizedReExport} from '../CategorizedReExport'\nimport type {ReExportGroup} from '../ReExportGroup'\n\nexport function groupReExportsByType(\n categorized: CategorizedReExport[],\n): Record<ReExportGroup, CategorizedReExport[]> {\n const grouped: Record<ReExportGroup, CategorizedReExport[]> = {\n 're-export-all': [],\n 're-export-named': [],\n 're-export-type': [],\n }\n\n for (const item of categorized)\n grouped[item.group].push(item)\n\n return grouped\n}\n","import {compare} from '../../../lib/compare'\nimport type {CategorizedReExport} from '../CategorizedReExport'\nimport type {ReExportGroup} from '../ReExportGroup'\n\nexport function sortExportGroups(\n grouped: Record<ReExportGroup, CategorizedReExport[]>,\n): void {\n grouped['re-export-all'].sort((a, b) => compare(a.sortKey, b.sortKey))\n grouped['re-export-named'].sort((a, b) => compare(a.sortKey, b.sortKey))\n grouped['re-export-type'].sort((a, b) => compare(a.sortKey, b.sortKey))\n}\n","import {buildSortedCode} from './buildSortedCode'\nimport {categorizeReExports} from '../categorizeReExports'\nimport {groupReExportsByType} from './groupReExportsByType'\nimport {ReExportDeclaration} from '../ReExportDeclaration'\nimport {sortExportGroups} from './sortExportGroups'\nimport type {Rule} from 'eslint'\n\nfunction createFixForGroup(\n fixer: Rule.RuleFixer,\n reExportDeclarations: ReExportDeclaration[],\n sourceCode: {getText: (node?: unknown) => string},\n): Rule.Fix | null {\n if (reExportDeclarations.length === 0) {\n return null\n }\n\n const categorized = categorizeReExports(reExportDeclarations)\n const grouped = groupReExportsByType(categorized)\n\n sortExportGroups(grouped)\n\n const sortedCode = buildSortedCode(grouped, sourceCode)\n .join('\\n')\n\n const firstReExport = reExportDeclarations[0]\n const lastReExport = reExportDeclarations[reExportDeclarations.length - 1]\n\n return fixer.replaceTextRange(\n [firstReExport.range![0], lastReExport.range![1]],\n sortedCode,\n )\n}\n\nexport function createFix(\n fixer: Rule.RuleFixer,\n reExportGroups: ReExportDeclaration[][],\n sourceCode: {getText: (node?: unknown) => string},\n): Rule.Fix[] {\n const fixes: Rule.Fix[] = []\n\n for (const group of reExportGroups) {\n const fix = createFixForGroup(fixer, group, sourceCode)\n if (fix)\n fixes.push(fix)\n }\n\n return fixes\n}\n","import type {ReExportDeclaration} from './ReExportDeclaration'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nfunction isReExportDeclaration(\n statement: TSESTree.ProgramStatement,\n): statement is ReExportDeclaration {\n return (statement.type === 'ExportNamedDeclaration' && statement.source !== null)\n || statement.type === 'ExportAllDeclaration'\n}\n\nexport function getReExportGroups(\n programBody: TSESTree.ProgramStatement[],\n): ReExportDeclaration[][] {\n const groups: ReExportDeclaration[][] = []\n let currentGroup: ReExportDeclaration[] = []\n\n for (const statement of programBody) {\n if (isReExportDeclaration(statement)) {\n currentGroup.push(statement)\n continue\n }\n\n if (currentGroup.length > 0) {\n groups.push(currentGroup)\n currentGroup = []\n }\n }\n\n if (currentGroup.length > 0)\n groups.push(currentGroup)\n\n return groups\n}\n","import {categorizeReExports} from './categorizeReExports'\nimport {checkAlphabeticalSorting} from './checkAlphabeticalSorting'\nimport {checkGroupOrdering} from './checkGroupOrdering'\nimport {checkSpecifiersSorting} from './checkSpecifiersSorting'\nimport {createFix} from './createFix'\nimport {getReExportGroups} from './getReExportGroups'\nimport type {ReExportError} from './ReExportError'\nimport type {Rule} from 'eslint'\nimport type {TSESTree} from '@typescript-eslint/types'\n\nexport const sortedReExports: Rule.RuleModule = {\n meta: {\n docs: {\n description: 'Enforce sorted exports alphabetically',\n recommended: true,\n },\n fixable: 'code',\n messages: {\n sortedReExports: 'Exports should be sorted alphabetically',\n sortedNames: 'Named exports should be sorted alphabetically',\n wrongGroup: 'Export is in wrong group',\n },\n schema: [],\n type: 'suggestion',\n },\n create(context) {\n return {\n Program(node) {\n const body = node.body as TSESTree.ProgramStatement[]\n const reExportGroups = getReExportGroups(body)\n if (reExportGroups.length === 0)\n return\n\n const allErrors: ReExportError[] = []\n\n // Check each re-export group independently\n for (const group of reExportGroups) {\n const categorized = categorizeReExports(group)\n const errors: ReExportError[] = [\n ...checkGroupOrdering(categorized),\n ...checkAlphabeticalSorting(categorized),\n ...checkSpecifiersSorting(categorized),\n ]\n allErrors.push(...errors)\n }\n\n for (const error of allErrors) {\n context.report({\n node: error.node,\n messageId: error.messageId,\n fix(fixer) {\n const sourceCode = context.sourceCode\n return createFix(fixer, reExportGroups, sourceCode)\n },\n })\n }\n },\n }\n },\n}\n"],"mappings":";AAAA,OAAO,YAAY;AACnB,OAAO,WAAW;AAClB,OAAO,gBAAgB;AACvB,OAAO,eAAe;AACtB,OAAO,gBAAgB;AACvB,SAAQ,oBAAmB;;;ACFpB,SAAS,iBAAiB,WAA8C;AAC7E,MAAI,UAAU,SAAS;AACrB,WAAO;AAET,MAAI,UAAU,SAAS;AACrB,WAAO;AAET,MAAI,UAAU,SAAS,0BAA0B;AAC/C,QAAI,UAAU,WAAW;AACvB,aAAO;AAAA,EACX;AAEA,SAAO;AACT;;;ACXO,SAAS,qBACd,YACuB;AACvB,QAAM,SAAgC;AAAA,IACpC,SAAS,CAAC;AAAA,IACV,WAAW,CAAC;AAAA,IACZ,OAAO,CAAC;AAAA,EACV;AAEA,aAAW,aAAa,YAAY;AAClC,UAAM,OAAO,iBAAiB,SAAS;AAEvC,QAAI,SAAS;AACX,aAAO,QAAQ,KAAK,SAAuC;AAAA,aACpD,SAAS;AAChB,aAAO,UAAU,KAAK,SAAqB;AAAA;AAE3C,aAAO,MAAM,KAAK,SAAS;AAAA,EAC/B;AAEA,SAAO;AACT;;;ACrBO,SAAS,qBACd,YACkB;AAClB,MAAI,wBAAwB;AAC5B,MAAI,aAAa;AACjB,MAAI,eAAe;AAEnB,WAAS,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;AAC1C,UAAM,OAAsB,iBAAiB,WAAW,CAAC,CAAC;AAE1D,QAAI,SAAS;AACX,mBAAa;AAAA,aACN,SAAS;AAChB,qBAAe;AAAA,aACR,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0CAA0C;AAAA,MAC1C,mCAAmC;AAAA,QACjC;AAAA,QACA,EAAC,YAAY,KAAI;AAAA,MACnB;AAAA,MACA,mCAAmC;AAAA,QACjC;AAAA,QACA;AAAA,MACF;AAAA,MACA,iCAAiC;AAAA,QAC/B;AAAA,QACA;AAAA,QACA,EAAC,WAAW,EAAC,KAAK,QAAO,EAAC;AAAA,MAC5B;AAAA,MACA,qBAAqB;AAAA,QACnB;AAAA,QACA;AAAA,QACA,EAAC,aAAa,KAAI;AAAA,MACpB;AAAA,MACA,0BAA0B;AAAA,QACxB;AAAA,QACA;AAAA,MACF;AAAA,MACA,mBAAmB;AAAA,QACjB;AAAA,QACA;AAAA,QACA,EAAC,kCAAkC,SAAQ;AAAA,MAC7C;AAAA,MACA,wCAAwC;AAAA,MACxC,sDAAsD;AAAA,IACxD;AAAA,EACF;AACF,CAAC;","names":["getSortKey","getSortKey","checkAlphabeticalSorting","checkGroupOrdering","getSpecifierName","areSpecifiersSorted","getSpecifierName","getNamedSpecifiers","checkSpecifiersSorting","getNamedSpecifiers","areSpecifiersSorted","sortSpecifiersText","getSpecifierName","getNamedSpecifiers","areSpecifiersSorted","sortSpecifiersText","buildSortedCode","createFixForGroup","buildSortedCode","createFix","checkGroupOrdering","checkAlphabeticalSorting","checkSpecifiersSorting","createFix"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@borela-tech/eslint-config",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "ESLint config used in Borela Tech projects.",
5
5
  "scripts": {
6
6
  "build": "./bin/build",
@@ -55,28 +55,6 @@ ruleTester.run('imports-and-re-exports-at-top', importsAndReExportsAtTop, {
55
55
  code: '',
56
56
  }],
57
57
  invalid: [{
58
- code: dedent`
59
- export {a} from 'aaa'
60
- import {b} from 'bbb'
61
- const c = 1
62
- `,
63
- errors: [{messageId: 'importsAndReExportsAtTop'}],
64
- output: dedent`
65
- import {b} from 'bbb'
66
- export {a} from 'aaa'
67
- const c = 1
68
- `,
69
- }, {
70
- code: dedent`
71
- export * from 'aaa'
72
- import {b} from 'bbb'
73
- `,
74
- errors: [{messageId: 'importsAndReExportsAtTop'}],
75
- output: dedent`
76
- import {b} from 'bbb'
77
- export * from 'aaa'
78
- `,
79
- }, {
80
58
  code: dedent`
81
59
  export {z} from 'zzz'
82
60
  const c = 1
@@ -104,15 +82,5 @@ ruleTester.run('imports-and-re-exports-at-top', importsAndReExportsAtTop, {
104
82
  export {c} from 'ccc'
105
83
  const a = 1
106
84
  `,
107
- }, {
108
- code: dedent`
109
- export type {a} from 'aaa'
110
- import {b} from 'bbb'
111
- `,
112
- errors: [{messageId: 'importsAndReExportsAtTop'}],
113
- output: dedent`
114
- import {b} from 'bbb'
115
- export type {a} from 'aaa'
116
- `,
117
85
  }],
118
86
  })
@@ -1,5 +1,5 @@
1
1
  export interface StatementIndices {
2
- firstImport: number
3
- firstReExport: number
4
- firstOther: number
2
+ firstRegularStatement: number
3
+ lastImport: number
4
+ lastReExport: number
5
5
  }
@@ -0,0 +1,25 @@
1
+ import {getStatementType} from './getStatementType'
2
+ import type {StatementIndices} from './StatementIndices'
3
+ import type {StatementType} from './statementType'
4
+ import type {TSESTree} from '@typescript-eslint/types'
5
+
6
+ export function findStatementIndices(
7
+ statements: TSESTree.Statement[],
8
+ ): StatementIndices {
9
+ let firstRegularStatement = -1
10
+ let lastImport = -1
11
+ let lastReExport = -1
12
+
13
+ for (let i = 0; i < statements.length; i++) {
14
+ const type: StatementType = getStatementType(statements[i])
15
+
16
+ if (type === 'import')
17
+ lastImport = i
18
+ else if (type === 're-export')
19
+ lastReExport = i
20
+ else if (type === 'other' && firstRegularStatement === -1)
21
+ firstRegularStatement = i
22
+ }
23
+
24
+ return {firstRegularStatement, lastImport, lastReExport}
25
+ }
@@ -5,25 +5,21 @@ export function hasViolation(
5
5
  indices: StatementIndices,
6
6
  categories: CategorizedStatements,
7
7
  ): boolean {
8
- const {
9
- firstImport,
10
- firstReExport,
11
- firstOther,
12
- } = indices
8
+ const {firstRegularStatement, lastImport, lastReExport} = indices
13
9
 
14
- // No imports or no re-exports.
15
- if (categories.imports.length === 0 || categories.reExports.length === 0)
10
+ if (categories.imports.length === 0 && categories.reExports.length === 0)
16
11
  return false
17
12
 
18
- const firstImportOrReExport = Math.min(firstImport, firstReExport)
19
- const hasOtherBeforeImportOrReExport =
20
- firstOther !== -1 && firstOther < firstImportOrReExport
13
+ const hasImportAfterRegularStatement = (
14
+ categories.imports.length > 0
15
+ && firstRegularStatement !== -1
16
+ && lastImport > firstRegularStatement
17
+ )
18
+ const hasReExportAfterRegularStatement = (
19
+ categories.reExports.length > 0
20
+ && firstRegularStatement !== -1
21
+ && lastReExport > firstRegularStatement
22
+ )
21
23
 
22
- // Violation if:
23
- // 1. Other statements appear before imports/re-exports.
24
- // 2. Re-exports appear before imports.
25
- if (hasOtherBeforeImportOrReExport || firstImport > firstReExport)
26
- return true
27
-
28
- return false
24
+ return hasImportAfterRegularStatement || hasReExportAfterRegularStatement
29
25
  }
@@ -1,5 +1,5 @@
1
1
  import {categorizeStatements} from './categorizeStatements'
2
- import {findFirstIndices} from './findFirstIndices'
2
+ import {findStatementIndices} from './findStatementIndices'
3
3
  import {generateSortedText} from './generateSortedText'
4
4
  import {hasViolation} from './hasViolation'
5
5
  import type {Rule} from 'eslint'
@@ -25,7 +25,7 @@ export const importsAndReExportsAtTop: Rule.RuleModule = {
25
25
  Program(node) {
26
26
  const statements = node.body as TSESTree.Statement[]
27
27
  const categories = categorizeStatements(statements)
28
- const indices = findFirstIndices(statements)
28
+ const indices = findStatementIndices(statements)
29
29
 
30
30
  if (!hasViolation(indices, categories))
31
31
  return
@@ -1,25 +0,0 @@
1
- import {getStatementType} from './getStatementType'
2
- import type {StatementIndices} from './StatementIndices'
3
- import type {StatementType} from './statementType'
4
- import type {TSESTree} from '@typescript-eslint/types'
5
-
6
- export function findFirstIndices(
7
- statements: TSESTree.Statement[],
8
- ): StatementIndices {
9
- let firstImport = Infinity
10
- let firstReExport = Infinity
11
- let firstOther = -1
12
-
13
- for (let i = 0; i < statements.length; i++) {
14
- const type: StatementType = getStatementType(statements[i])
15
-
16
- if (type === 'import' && firstImport === Infinity)
17
- firstImport = i
18
- else if (type === 're-export' && firstReExport === Infinity)
19
- firstReExport = i
20
- else if (type === 'other' && firstOther === -1)
21
- firstOther = i
22
- }
23
-
24
- return {firstImport, firstReExport, firstOther}
25
- }