@borela-tech/eslint-config 2.2.2 → 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.
Files changed (107) hide show
  1. package/README.md +308 -19
  2. package/dist/index.d.ts +5 -0
  3. package/dist/index.mjs +3589 -811
  4. package/dist/index.mjs.map +1 -1
  5. package/jest.config.ts +19 -0
  6. package/package.json +17 -8
  7. package/vite.config.ts +41 -0
  8. package/bin/build +0 -9
  9. package/bin/lint +0 -14
  10. package/bin/publish +0 -12
  11. package/bin/test +0 -12
  12. package/bin/typecheck +0 -8
  13. package/dist/index.d.mts +0 -7
  14. package/src/index.ts +0 -149
  15. package/src/lib/ReExportDeclaration.ts +0 -5
  16. package/src/lib/ReplacementRange.ts +0 -4
  17. package/src/lib/compare.ts +0 -3
  18. package/src/rules/__tests__/dedent/countLeadingSpaces.ts +0 -4
  19. package/src/rules/__tests__/dedent/findMinIndent.ts +0 -7
  20. package/src/rules/__tests__/dedent/index.ts +0 -17
  21. package/src/rules/__tests__/dedent/interpolate.ts +0 -11
  22. package/src/rules/__tests__/dedent/removeEmptyPrefix.ts +0 -6
  23. package/src/rules/__tests__/dedent/removeEmptySuffix.ts +0 -6
  24. package/src/rules/__tests__/dedent/removeIndent.ts +0 -3
  25. package/src/rules/__tests__/importsAndReExportsAtTop.test.ts +0 -88
  26. package/src/rules/__tests__/individualImports.test.ts +0 -44
  27. package/src/rules/__tests__/individualReExports.test.ts +0 -64
  28. package/src/rules/__tests__/multilineUnionTypes.test.ts +0 -75
  29. package/src/rules/__tests__/singleLineImports.test.ts +0 -129
  30. package/src/rules/__tests__/singleLineReExports.test.ts +0 -100
  31. package/src/rules/__tests__/sortedImports.test.ts +0 -227
  32. package/src/rules/__tests__/sortedReExports.test.ts +0 -220
  33. package/src/rules/importsAndReExportsAtTop/CategorizedStatements.ts +0 -8
  34. package/src/rules/importsAndReExportsAtTop/StatementIndices.ts +0 -5
  35. package/src/rules/importsAndReExportsAtTop/categorizeStatements.ts +0 -28
  36. package/src/rules/importsAndReExportsAtTop/findStatementIndices.ts +0 -25
  37. package/src/rules/importsAndReExportsAtTop/generateSortedText.ts +0 -16
  38. package/src/rules/importsAndReExportsAtTop/getStatementType.ts +0 -17
  39. package/src/rules/importsAndReExportsAtTop/hasViolation.ts +0 -25
  40. package/src/rules/importsAndReExportsAtTop/index.ts +0 -45
  41. package/src/rules/importsAndReExportsAtTop/isImportDeclaration.ts +0 -7
  42. package/src/rules/importsAndReExportsAtTop/isReExport.ts +0 -12
  43. package/src/rules/importsAndReExportsAtTop/statementType.ts +0 -4
  44. package/src/rules/individualImports.ts +0 -38
  45. package/src/rules/individualReExports.ts +0 -51
  46. package/src/rules/multilineUnionTypes/createFix.ts +0 -13
  47. package/src/rules/multilineUnionTypes/index.ts +0 -52
  48. package/src/rules/multilineUnionTypes/isMultiline.ts +0 -6
  49. package/src/rules/singleLineImports/createFix.ts +0 -23
  50. package/src/rules/singleLineImports/formatAttributes.ts +0 -20
  51. package/src/rules/singleLineImports/formatNamed.ts +0 -9
  52. package/src/rules/singleLineImports/formatSpecifiers.ts +0 -32
  53. package/src/rules/singleLineImports/index.ts +0 -34
  54. package/src/rules/singleLineImports/isMultiline.ts +0 -6
  55. package/src/rules/singleLineReExports/createFix.ts +0 -29
  56. package/src/rules/singleLineReExports/index.ts +0 -48
  57. package/src/rules/singleLineReExports/isMultiline.ts +0 -6
  58. package/src/rules/sortedImports/CategorizedImport.ts +0 -8
  59. package/src/rules/sortedImports/ImportError.ts +0 -9
  60. package/src/rules/sortedImports/ImportGroup.ts +0 -6
  61. package/src/rules/sortedImports/ImportGroupOrder.ts +0 -9
  62. package/src/rules/sortedImports/areSpecifiersSorted.ts +0 -9
  63. package/src/rules/sortedImports/categorizeImport.ts +0 -23
  64. package/src/rules/sortedImports/categorizeImports.ts +0 -12
  65. package/src/rules/sortedImports/checkAlphabeticalSorting.ts +0 -23
  66. package/src/rules/sortedImports/checkGroupOrdering.ts +0 -21
  67. package/src/rules/sortedImports/checkSpecifiersSorting.ts +0 -21
  68. package/src/rules/sortedImports/createFix/buildSortedCode.ts +0 -23
  69. package/src/rules/sortedImports/createFix/findLastImportIndex.ts +0 -12
  70. package/src/rules/sortedImports/createFix/formatNamedImport.ts +0 -21
  71. package/src/rules/sortedImports/createFix/getReplacementRange.ts +0 -14
  72. package/src/rules/sortedImports/createFix/groupImportsByType.ts +0 -19
  73. package/src/rules/sortedImports/createFix/index.ts +0 -47
  74. package/src/rules/sortedImports/createFix/sortImportGroups.ts +0 -13
  75. package/src/rules/sortedImports/getImportGroups.ts +0 -23
  76. package/src/rules/sortedImports/getNamedSpecifiers.ts +0 -7
  77. package/src/rules/sortedImports/getSortKey.ts +0 -26
  78. package/src/rules/sortedImports/getSpecifierName.ts +0 -7
  79. package/src/rules/sortedImports/index.ts +0 -63
  80. package/src/rules/sortedImports/sortSpecifiersText.ts +0 -16
  81. package/src/rules/sortedReExports/CategorizedNamedReExport.ts +0 -6
  82. package/src/rules/sortedReExports/CategorizedReExport.ts +0 -26
  83. package/src/rules/sortedReExports/ReExportError.ts +0 -9
  84. package/src/rules/sortedReExports/ReExportGroup.ts +0 -5
  85. package/src/rules/sortedReExports/ReExportGroupOrder.ts +0 -8
  86. package/src/rules/sortedReExports/areSpecifiersSorted.ts +0 -9
  87. package/src/rules/sortedReExports/categorizeReExport.ts +0 -21
  88. package/src/rules/sortedReExports/categorizeReExports.ts +0 -14
  89. package/src/rules/sortedReExports/checkAlphabeticalSorting.ts +0 -25
  90. package/src/rules/sortedReExports/checkGroupOrdering.ts +0 -21
  91. package/src/rules/sortedReExports/checkSpecifiersSorting.ts +0 -23
  92. package/src/rules/sortedReExports/createFix/buildSortedCode.ts +0 -29
  93. package/src/rules/sortedReExports/createFix/findFirstExportIndex.ts +0 -11
  94. package/src/rules/sortedReExports/createFix/findLastExportIndex.ts +0 -12
  95. package/src/rules/sortedReExports/createFix/formatNamedReExport.ts +0 -21
  96. package/src/rules/sortedReExports/createFix/getReplacementRange.ts +0 -22
  97. package/src/rules/sortedReExports/createFix/groupReExportsByType.ts +0 -18
  98. package/src/rules/sortedReExports/createFix/index.ts +0 -47
  99. package/src/rules/sortedReExports/createFix/sortExportGroups.ts +0 -12
  100. package/src/rules/sortedReExports/getNamedSpecifiers.ts +0 -9
  101. package/src/rules/sortedReExports/getReExportGroups.ts +0 -33
  102. package/src/rules/sortedReExports/getSortKey.ts +0 -22
  103. package/src/rules/sortedReExports/getSpecifierName.ts +0 -7
  104. package/src/rules/sortedReExports/index.ts +0 -63
  105. package/src/rules/sortedReExports/isNamedReExport.ts +0 -6
  106. package/src/rules/sortedReExports/sortSpecifiersText.ts +0 -16
  107. package/tsdown.config.ts +0 -22
package/jest.config.ts ADDED
@@ -0,0 +1,19 @@
1
+ import type {Config} from 'jest'
2
+
3
+ const config: Config = {
4
+ extensionsToTreatAsEsm: ['.ts'],
5
+ moduleNameMapper: {
6
+ '^@lib/(.*)$': '<rootDir>/src/lib/$1',
7
+ },
8
+ preset: 'ts-jest/presets/default-esm',
9
+ testEnvironment: 'node',
10
+ testMatch: ['**/__tests__/**/*.test.ts'],
11
+ transform: {
12
+ '^.+\\.tsx?$': [
13
+ 'ts-jest',
14
+ {useESM: true},
15
+ ],
16
+ },
17
+ }
18
+
19
+ export {config as default}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@borela-tech/eslint-config",
3
- "version": "2.2.2",
3
+ "version": "2.3.0",
4
4
  "description": "ESLint config used in Borela Tech projects.",
5
5
  "scripts": {
6
6
  "build": "./bin/build",
@@ -10,10 +10,10 @@
10
10
  "typecheck": "./bin/typecheck"
11
11
  },
12
12
  "type": "module",
13
- "main": "src/index.ts",
13
+ "main": "dist/index.mjs",
14
14
  "exports": {
15
15
  "import": {
16
- "types": "./dist/index.d.mts",
16
+ "types": "./dist/index.d.ts",
17
17
  "default": "./dist/index.mjs"
18
18
  }
19
19
  },
@@ -36,20 +36,29 @@
36
36
  "dependencies": {
37
37
  "@eslint/js": "^9.24.0",
38
38
  "@stylistic/eslint-plugin": "^4.2.0",
39
+ "eslint-plugin-perfectionist": "^5.6.0",
39
40
  "eslint-plugin-react": "^7.37.5",
40
41
  "eslint-plugin-react-hooks": "^5.2.0",
42
+ "eslint-plugin-unicorn": "^63.0.0",
41
43
  "typescript-eslint": "^8.56.1"
42
44
  },
43
45
  "devDependencies": {
44
46
  "@swc-node/register": "^1.11.1",
45
47
  "@swc/core": "^1.15.18",
46
- "@types/node": "^25.3.3",
48
+ "@types/jest": "^30.0.0",
49
+ "@types/node": "^22.0.0",
50
+ "@typescript-eslint/rule-tester": "^8.57.1",
51
+ "@typescript-eslint/utils": "^8.57.1",
47
52
  "eslint": "^9.24.0",
48
- "tsdown": "^0.21.0",
49
- "typescript": "^5.8.3"
53
+ "jest": "^30.3.0",
54
+ "ts-jest": "^29.4.6",
55
+ "typescript": "~5.8.3",
56
+ "vite": "^6.3.5",
57
+ "vite-plugin-dts": "^4.5.3"
50
58
  },
51
59
  "peerDependencies": {
52
60
  "eslint": "^9.24.0",
53
- "typescript": "^5.8.3"
54
- }
61
+ "typescript": "~5.8.3"
62
+ },
63
+ "packageManager": "pnpm@10.20.0+sha512.cf9998222162dd85864d0a8102e7892e7ba4ceadebbf5a31f9c2fce48dfce317a9c53b9f6464d1ef9042cba2e02ae02a9f7c143a2b438cd93c91840f0192b9dd"
55
64
  }
package/vite.config.ts ADDED
@@ -0,0 +1,41 @@
1
+ import dts from 'vite-plugin-dts'
2
+ import path from 'path'
3
+ import {defineConfig} from 'vite'
4
+
5
+ const config = defineConfig({
6
+ build: {
7
+ lib: {
8
+ entry: path.resolve(__dirname, 'src/index.ts'),
9
+ fileName: 'index',
10
+ formats: ['es'],
11
+ },
12
+ minify: false,
13
+ rollupOptions: {
14
+ external: [
15
+ /^@?eslint/,
16
+ /^@?typescript/,
17
+ /^@?stylistic/,
18
+ /^@?react/,
19
+ 'path',
20
+ ],
21
+ output: {
22
+ entryFileNames: 'index.mjs',
23
+ },
24
+ },
25
+ sourcemap: true,
26
+ target: 'node18',
27
+ },
28
+ plugins: [dts({
29
+ exclude: ['src/**/__tests__/**'],
30
+ include: ['src/'],
31
+ rollupTypes: true,
32
+ tsconfigPath: './tsconfig.json',
33
+ })],
34
+ resolve: {
35
+ alias: {
36
+ '@lib': path.resolve(__dirname, 'src/lib'),
37
+ },
38
+ },
39
+ })
40
+
41
+ export {config as default}
package/bin/build DELETED
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env -S bash -e -o pipefail
2
-
3
- SCRIPT_DIR=$(dirname -- "${BASH_SOURCE[0]}")
4
- pushd "$SCRIPT_DIR/.." > /dev/null
5
-
6
- rm -rf dist
7
- npx tsdown
8
-
9
- popd > /dev/null
package/bin/lint DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env -S bash -e -o pipefail
2
-
3
- SCRIPT_DIR=$(dirname -- "${BASH_SOURCE[0]}")
4
- pushd "$SCRIPT_DIR/.." > /dev/null
5
-
6
- ./bin/build
7
- npx eslint \
8
- --ext ts \
9
- --max-warnings 0 \
10
- --report-unused-disable-directives \
11
- . \
12
- $@
13
-
14
- popd > /dev/null
package/bin/publish DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env -S bash -e -o pipefail
2
-
3
- SCRIPT_DIR=$(dirname -- "${BASH_SOURCE[0]}")
4
- pushd "$SCRIPT_DIR/.." > /dev/null
5
-
6
- ./bin/build
7
- npm publish \
8
- --access public \
9
- --registry https://registry.npmjs.org/ \
10
- --tag latest
11
-
12
- popd > /dev/null
package/bin/test DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env -S bash -e -o pipefail
2
-
3
- SCRIPT_DIR=$(dirname -- "${BASH_SOURCE[0]}")
4
- pushd "$SCRIPT_DIR/.." > /dev/null
5
-
6
- ./bin/build
7
- node \
8
- --import @swc-node/register/esm-register \
9
- --test \
10
- src/rules/__tests__/*.test.ts
11
-
12
- popd > /dev/null
package/bin/typecheck DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env -S bash -e -o pipefail
2
-
3
- SCRIPT_DIR=$(dirname -- "${BASH_SOURCE[0]}")
4
- pushd "$SCRIPT_DIR/.." > /dev/null
5
-
6
- npx tsc --noEmit
7
-
8
- popd > /dev/null
package/dist/index.d.mts DELETED
@@ -1,7 +0,0 @@
1
- import { TSESLint } from "@typescript-eslint/utils";
2
-
3
- //#region src/index.d.ts
4
- declare const CONFIG: TSESLint.FlatConfig.ConfigArray;
5
- //#endregion
6
- export { CONFIG };
7
- //# sourceMappingURL=index.d.mts.map
package/src/index.ts DELETED
@@ -1,149 +0,0 @@
1
- import eslint from '@eslint/js'
2
- import react from 'eslint-plugin-react'
3
- import reactHooks from 'eslint-plugin-react-hooks'
4
- import stylistic from '@stylistic/eslint-plugin'
5
- import typescript from 'typescript-eslint'
6
- import {importsAndReExportsAtTop} from './rules/importsAndReExportsAtTop'
7
- import {individualImports} from './rules/individualImports'
8
- import {individualReExports} from './rules/individualReExports'
9
- import {multilineUnionTypes} from './rules/multilineUnionTypes'
10
- import {singleLineImports} from './rules/singleLineImports'
11
- import {singleLineReExports} from './rules/singleLineReExports'
12
- import {sortedImports} from './rules/sortedImports'
13
- import {sortedReExports} from './rules/sortedReExports'
14
- import type {TSESLint} from '@typescript-eslint/utils'
15
-
16
- export const CONFIG: TSESLint.FlatConfig.ConfigArray = [
17
- {
18
- ignores: [
19
- 'src/graphql/sdk.ts',
20
- '**/node_modules/**',
21
- '**/dist/**',
22
- ],
23
- },
24
- {
25
- settings: {
26
- react: {
27
- version: '19',
28
- },
29
- },
30
- },
31
- eslint.configs.recommended,
32
- react.configs.flat.recommended,
33
- stylistic.configs.recommended,
34
- ...typescript.configs.recommended,
35
- ...typescript.configs.stylistic,
36
- {
37
- plugins: {
38
- 'react-hooks': reactHooks,
39
- },
40
- rules: reactHooks.configs.recommended.rules,
41
- },
42
- {
43
- plugins: {
44
- '@borela-tech': {
45
- rules: {
46
- 'imports-and-re-exports-at-top': importsAndReExportsAtTop,
47
- 'individual-imports': individualImports,
48
- 'individual-re-exports': individualReExports,
49
- 'multiline-union-types': multilineUnionTypes,
50
- 'single-line-imports': singleLineImports,
51
- 'single-line-re-exports': singleLineReExports,
52
- 'sorted-imports': sortedImports,
53
- 'sorted-re-exports': sortedReExports,
54
- },
55
- },
56
- },
57
- rules: {
58
- '@borela-tech/imports-and-re-exports-at-top': 'error',
59
- '@borela-tech/individual-imports': 'error',
60
- '@borela-tech/individual-re-exports': 'error',
61
- '@borela-tech/multiline-union-types': 'error',
62
- '@borela-tech/single-line-imports': 'error',
63
- '@borela-tech/single-line-re-exports': 'error',
64
- '@borela-tech/sorted-imports': 'error',
65
- '@borela-tech/sorted-re-exports': 'error',
66
- },
67
- },
68
- {
69
- rules: {
70
- 'capitalized-comments': [
71
- 'error',
72
- 'always',
73
- {ignoreConsecutiveComments: true},
74
- ],
75
- 'react/react-in-jsx-scope': 'off',
76
- '@stylistic/arrow-parens': [
77
- 'error',
78
- 'as-needed',
79
- ],
80
- '@stylistic/array-bracket-newline': [
81
- 'error',
82
- 'consistent',
83
- ],
84
- '@stylistic/array-bracket-spacing': [
85
- 'error',
86
- 'never',
87
- ],
88
- '@stylistic/array-element-newline': [
89
- 'error',
90
- 'consistent',
91
- ],
92
- '@stylistic/block-spacing': 'off',
93
- '@stylistic/brace-style': [
94
- 'error',
95
- '1tbs',
96
- {allowSingleLine: true},
97
- ],
98
- '@stylistic/indent': [
99
- 'error',
100
- 2,
101
- {ignoredNodes: ['TSMappedType > *']},
102
- ],
103
- '@stylistic/jsx-tag-spacing': [
104
- 'error',
105
- {
106
- afterOpening: 'never',
107
- beforeClosing: 'never',
108
- beforeSelfClosing: 'never',
109
- closingSlash: 'never',
110
- },
111
- ],
112
- '@stylistic/jsx-wrap-multilines': 'off',
113
- '@stylistic/lines-between-class-members': 'off',
114
- '@stylistic/object-curly-newline': [
115
- 'error',
116
- {consistent: true},
117
- ],
118
- '@stylistic/object-curly-spacing': [
119
- 'error',
120
- 'never',
121
- ],
122
- '@stylistic/operator-linebreak': [
123
- 'error',
124
- 'before',
125
- {overrides: {'=': 'after'}},
126
- ],
127
- '@stylistic/quotes': [
128
- 'error',
129
- 'single',
130
- {avoidEscape: true},
131
- ],
132
- '@stylistic/quote-props': [
133
- 'error',
134
- 'as-needed',
135
- ],
136
- '@stylistic/semi': [
137
- 'error',
138
- 'never',
139
- {beforeStatementContinuationChars: 'always'},
140
- ],
141
- '@typescript-eslint/no-empty-function': 'off',
142
- '@typescript-eslint/consistent-indexed-object-style': 'off',
143
- '@typescript-eslint/consistent-type-imports': [
144
- 'error',
145
- {fixStyle: 'separate-type-imports'},
146
- ],
147
- },
148
- },
149
- ]
@@ -1,5 +0,0 @@
1
- import type {TSESTree} from '@typescript-eslint/types'
2
-
3
- export type ReExportDeclaration =
4
- | TSESTree.ExportAllDeclaration
5
- | TSESTree.ExportNamedDeclaration
@@ -1,4 +0,0 @@
1
- export interface ReplacementRange {
2
- start: number
3
- end: number
4
- }
@@ -1,3 +0,0 @@
1
- export function compare(a: string, b: string): number {
2
- return a.localeCompare(b, 'en', {sensitivity: 'case'})
3
- }
@@ -1,4 +0,0 @@
1
- export function countLeadingSpaces(line: string): number {
2
- const match = line.match(/^(\s*)/)
3
- return match ? match[1].length : 0
4
- }
@@ -1,7 +0,0 @@
1
- import {countLeadingSpaces} from './countLeadingSpaces'
2
-
3
- export function findMinIndent(lines: string[]): number {
4
- const nonEmptyLines = lines.filter(line => line.trim().length > 0)
5
- const indents = nonEmptyLines.map(line => countLeadingSpaces(line))
6
- return Math.min(...indents)
7
- }
@@ -1,17 +0,0 @@
1
- import {findMinIndent} from './findMinIndent'
2
- import {interpolate} from './interpolate'
3
- import {removeEmptyPrefix} from './removeEmptyPrefix'
4
- import {removeEmptySuffix} from './removeEmptySuffix'
5
- import {removeIndent} from './removeIndent'
6
-
7
- export function dedent(
8
- strings: TemplateStringsArray,
9
- ...values: unknown[]
10
- ): string {
11
- const raw = interpolate(strings, values)
12
- const lines = raw.split('\n')
13
- const withoutPrefix = removeEmptyPrefix(lines)
14
- const trimmed = removeEmptySuffix(withoutPrefix)
15
- const indentSize = findMinIndent(trimmed)
16
- return removeIndent(trimmed, indentSize)
17
- }
@@ -1,11 +0,0 @@
1
- export function interpolate(
2
- strings: TemplateStringsArray,
3
- values: unknown[],
4
- ): string {
5
- let result = ''
6
- for (let i = 0; i < strings.length; i++) {
7
- result += strings[i]
8
- if (i < values.length) result += String(values[i])
9
- }
10
- return result
11
- }
@@ -1,6 +0,0 @@
1
- export function removeEmptyPrefix(lines: string[]): string[] {
2
- const copy = [...lines]
3
- while (copy.length > 0 && copy[0].trim() === '')
4
- copy.shift()
5
- return copy
6
- }
@@ -1,6 +0,0 @@
1
- export function removeEmptySuffix(lines: string[]): string[] {
2
- const copy = [...lines]
3
- while (copy.length > 0 && copy[copy.length - 1].trim() === '')
4
- copy.pop()
5
- return copy
6
- }
@@ -1,3 +0,0 @@
1
- export function removeIndent(lines: string[], indentSize: number): string {
2
- return lines.map(line => line.slice(indentSize)).join('\n')
3
- }
@@ -1,88 +0,0 @@
1
- import typescript from 'typescript-eslint'
2
- import {dedent} from './dedent'
3
- import {importsAndReExportsAtTop} from '../importsAndReExportsAtTop'
4
- import {RuleTester} from 'eslint'
5
- import type {Rule} from 'eslint'
6
-
7
- const rule = importsAndReExportsAtTop as unknown as Rule.RuleModule
8
- const ruleTester = new RuleTester({
9
- languageOptions: {
10
- parser: typescript.parser,
11
- parserOptions: {
12
- ecmaVersion: 2020,
13
- sourceType: 'module',
14
- },
15
- },
16
- })
17
-
18
- ruleTester.run('imports-and-re-exports-at-top', rule, {
19
- valid: [{
20
- code: dedent`
21
- import {a} from 'aaa'
22
- export {a} from 'aaa'
23
- const c = 1
24
- `,
25
- }, {
26
- code: dedent`
27
- import {a} from 'aaa'
28
- import {b} from 'bbb'
29
- export {c} from 'ccc'
30
- `,
31
- }, {
32
- code: dedent`
33
- import {a} from 'aaa'
34
- const c = 1
35
- function foo() {}
36
- `,
37
- }, {
38
- code: dedent`
39
- export {a} from 'aaa'
40
- export * from 'bbb'
41
- const c = 1
42
- `,
43
- }, {
44
- code: dedent`
45
- const c = 1
46
- function foo() {}
47
- `,
48
- }, {
49
- code: dedent`
50
- import {a} from 'aaa'
51
- `,
52
- }, {
53
- code: dedent`
54
- export {a} from 'aaa'
55
- `,
56
- }, {
57
- code: '',
58
- }],
59
- invalid: [{
60
- code: dedent`
61
- export {z} from 'zzz'
62
- const c = 1
63
- import {a} from 'aaa'
64
- function foo() {}
65
- export {b} from 'bbb'
66
- `,
67
- errors: [{messageId: 'importsAndReExportsAtTop'}],
68
- output: dedent`
69
- import {a} from 'aaa'
70
- export {z} from 'zzz'
71
- export {b} from 'bbb'
72
- const c = 1
73
- function foo() {}
74
- `,
75
- }, {
76
- code: dedent`
77
- const a = 1
78
- import {b} from 'bbb'
79
- export {c} from 'ccc'
80
- `,
81
- errors: [{messageId: 'importsAndReExportsAtTop'}],
82
- output: dedent`
83
- import {b} from 'bbb'
84
- export {c} from 'ccc'
85
- const a = 1
86
- `,
87
- }],
88
- })
@@ -1,44 +0,0 @@
1
- import typescript from 'typescript-eslint'
2
- import {dedent} from './dedent'
3
- import {individualImports} from '../individualImports'
4
- import {RuleTester} from 'eslint'
5
- import type {Rule} from 'eslint'
6
-
7
- const rule = individualImports as unknown as Rule.RuleModule
8
- const ruleTester = new RuleTester({
9
- languageOptions: {
10
- parser: typescript.parser,
11
- parserOptions: {
12
- ecmaVersion: 2020,
13
- sourceType: 'module',
14
- },
15
- },
16
- })
17
-
18
- ruleTester.run('individual-imports', rule, {
19
- valid: [{
20
- code: "import {foo} from 'bar'",
21
- }, {
22
- code: "import foo from 'bar'",
23
- }, {
24
- code: "import * as foo from 'bar'",
25
- }, {
26
- code: "import 'bar'",
27
- }],
28
- invalid: [{
29
- code: "import {foo, bar} from 'baz'",
30
- errors: [{messageId: 'individualImports'}],
31
- output: dedent`
32
- import {foo} from 'baz'
33
- import {bar} from 'baz'
34
- `,
35
- }, {
36
- code: "import {foo, bar, baz} from 'qux'",
37
- errors: [{messageId: 'individualImports'}],
38
- output: dedent`
39
- import {foo} from 'qux'
40
- import {bar} from 'qux'
41
- import {baz} from 'qux'
42
- `,
43
- }],
44
- })
@@ -1,64 +0,0 @@
1
- import typescript from 'typescript-eslint'
2
- import {dedent} from './dedent'
3
- import {individualReExports} from '../individualReExports'
4
- import {RuleTester} from 'eslint'
5
- import type {Rule} from 'eslint'
6
-
7
- const rule = individualReExports as unknown as Rule.RuleModule
8
- const ruleTester = new RuleTester({
9
- languageOptions: {
10
- parser: typescript.parser,
11
- parserOptions: {
12
- ecmaVersion: 2020,
13
- sourceType: 'module',
14
- },
15
- },
16
- })
17
-
18
- ruleTester.run('individual-re-exports', rule, {
19
- valid: [{
20
- code: "export {foo} from 'bar'",
21
- }, {
22
- code: "export {foo as bar} from 'baz'",
23
- }, {
24
- code: "export * from 'bar'",
25
- }, {
26
- code: "export default 'bar'",
27
- }, {
28
- code: 'export const foo = 1',
29
- }, {
30
- code: 'export function foo() {}',
31
- }, {
32
- code: 'export class Foo {}',
33
- }],
34
- invalid: [{
35
- code: "export type {foo, bar} from 'baz'",
36
- errors: [{messageId: 'individualReExports'}],
37
- output: dedent`
38
- export type {foo} from 'baz'
39
- export type {bar} from 'baz'
40
- `,
41
- }, {
42
- code: "export {foo, bar} from 'baz'",
43
- errors: [{messageId: 'individualReExports'}],
44
- output: dedent`
45
- export {foo} from 'baz'
46
- export {bar} from 'baz'
47
- `,
48
- }, {
49
- code: "export {foo, bar, baz} from 'qux'",
50
- errors: [{messageId: 'individualReExports'}],
51
- output: dedent`
52
- export {foo} from 'qux'
53
- export {bar} from 'qux'
54
- export {baz} from 'qux'
55
- `,
56
- }, {
57
- code: "export {foo as bar, baz as qux} from 'qux'",
58
- errors: [{messageId: 'individualReExports'}],
59
- output: dedent`
60
- export {foo as bar} from 'qux'
61
- export {baz as qux} from 'qux'
62
- `,
63
- }],
64
- })