@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.
- package/README.md +308 -19
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +3589 -811
- package/dist/index.mjs.map +1 -1
- package/jest.config.ts +19 -0
- package/package.json +17 -8
- package/vite.config.ts +41 -0
- package/bin/build +0 -9
- package/bin/lint +0 -14
- package/bin/publish +0 -12
- package/bin/test +0 -12
- package/bin/typecheck +0 -8
- package/dist/index.d.mts +0 -7
- package/src/index.ts +0 -149
- package/src/lib/ReExportDeclaration.ts +0 -5
- package/src/lib/ReplacementRange.ts +0 -4
- package/src/lib/compare.ts +0 -3
- package/src/rules/__tests__/dedent/countLeadingSpaces.ts +0 -4
- package/src/rules/__tests__/dedent/findMinIndent.ts +0 -7
- package/src/rules/__tests__/dedent/index.ts +0 -17
- package/src/rules/__tests__/dedent/interpolate.ts +0 -11
- package/src/rules/__tests__/dedent/removeEmptyPrefix.ts +0 -6
- package/src/rules/__tests__/dedent/removeEmptySuffix.ts +0 -6
- package/src/rules/__tests__/dedent/removeIndent.ts +0 -3
- package/src/rules/__tests__/importsAndReExportsAtTop.test.ts +0 -88
- package/src/rules/__tests__/individualImports.test.ts +0 -44
- package/src/rules/__tests__/individualReExports.test.ts +0 -64
- package/src/rules/__tests__/multilineUnionTypes.test.ts +0 -75
- package/src/rules/__tests__/singleLineImports.test.ts +0 -129
- package/src/rules/__tests__/singleLineReExports.test.ts +0 -100
- package/src/rules/__tests__/sortedImports.test.ts +0 -227
- package/src/rules/__tests__/sortedReExports.test.ts +0 -220
- package/src/rules/importsAndReExportsAtTop/CategorizedStatements.ts +0 -8
- package/src/rules/importsAndReExportsAtTop/StatementIndices.ts +0 -5
- package/src/rules/importsAndReExportsAtTop/categorizeStatements.ts +0 -28
- package/src/rules/importsAndReExportsAtTop/findStatementIndices.ts +0 -25
- package/src/rules/importsAndReExportsAtTop/generateSortedText.ts +0 -16
- package/src/rules/importsAndReExportsAtTop/getStatementType.ts +0 -17
- package/src/rules/importsAndReExportsAtTop/hasViolation.ts +0 -25
- package/src/rules/importsAndReExportsAtTop/index.ts +0 -45
- package/src/rules/importsAndReExportsAtTop/isImportDeclaration.ts +0 -7
- package/src/rules/importsAndReExportsAtTop/isReExport.ts +0 -12
- package/src/rules/importsAndReExportsAtTop/statementType.ts +0 -4
- package/src/rules/individualImports.ts +0 -38
- package/src/rules/individualReExports.ts +0 -51
- package/src/rules/multilineUnionTypes/createFix.ts +0 -13
- package/src/rules/multilineUnionTypes/index.ts +0 -52
- package/src/rules/multilineUnionTypes/isMultiline.ts +0 -6
- package/src/rules/singleLineImports/createFix.ts +0 -23
- package/src/rules/singleLineImports/formatAttributes.ts +0 -20
- package/src/rules/singleLineImports/formatNamed.ts +0 -9
- package/src/rules/singleLineImports/formatSpecifiers.ts +0 -32
- package/src/rules/singleLineImports/index.ts +0 -34
- package/src/rules/singleLineImports/isMultiline.ts +0 -6
- package/src/rules/singleLineReExports/createFix.ts +0 -29
- package/src/rules/singleLineReExports/index.ts +0 -48
- package/src/rules/singleLineReExports/isMultiline.ts +0 -6
- package/src/rules/sortedImports/CategorizedImport.ts +0 -8
- package/src/rules/sortedImports/ImportError.ts +0 -9
- package/src/rules/sortedImports/ImportGroup.ts +0 -6
- package/src/rules/sortedImports/ImportGroupOrder.ts +0 -9
- package/src/rules/sortedImports/areSpecifiersSorted.ts +0 -9
- package/src/rules/sortedImports/categorizeImport.ts +0 -23
- package/src/rules/sortedImports/categorizeImports.ts +0 -12
- package/src/rules/sortedImports/checkAlphabeticalSorting.ts +0 -23
- package/src/rules/sortedImports/checkGroupOrdering.ts +0 -21
- package/src/rules/sortedImports/checkSpecifiersSorting.ts +0 -21
- package/src/rules/sortedImports/createFix/buildSortedCode.ts +0 -23
- package/src/rules/sortedImports/createFix/findLastImportIndex.ts +0 -12
- package/src/rules/sortedImports/createFix/formatNamedImport.ts +0 -21
- package/src/rules/sortedImports/createFix/getReplacementRange.ts +0 -14
- package/src/rules/sortedImports/createFix/groupImportsByType.ts +0 -19
- package/src/rules/sortedImports/createFix/index.ts +0 -47
- package/src/rules/sortedImports/createFix/sortImportGroups.ts +0 -13
- package/src/rules/sortedImports/getImportGroups.ts +0 -23
- package/src/rules/sortedImports/getNamedSpecifiers.ts +0 -7
- package/src/rules/sortedImports/getSortKey.ts +0 -26
- package/src/rules/sortedImports/getSpecifierName.ts +0 -7
- package/src/rules/sortedImports/index.ts +0 -63
- package/src/rules/sortedImports/sortSpecifiersText.ts +0 -16
- package/src/rules/sortedReExports/CategorizedNamedReExport.ts +0 -6
- package/src/rules/sortedReExports/CategorizedReExport.ts +0 -26
- package/src/rules/sortedReExports/ReExportError.ts +0 -9
- package/src/rules/sortedReExports/ReExportGroup.ts +0 -5
- package/src/rules/sortedReExports/ReExportGroupOrder.ts +0 -8
- package/src/rules/sortedReExports/areSpecifiersSorted.ts +0 -9
- package/src/rules/sortedReExports/categorizeReExport.ts +0 -21
- package/src/rules/sortedReExports/categorizeReExports.ts +0 -14
- package/src/rules/sortedReExports/checkAlphabeticalSorting.ts +0 -25
- package/src/rules/sortedReExports/checkGroupOrdering.ts +0 -21
- package/src/rules/sortedReExports/checkSpecifiersSorting.ts +0 -23
- package/src/rules/sortedReExports/createFix/buildSortedCode.ts +0 -29
- package/src/rules/sortedReExports/createFix/findFirstExportIndex.ts +0 -11
- package/src/rules/sortedReExports/createFix/findLastExportIndex.ts +0 -12
- package/src/rules/sortedReExports/createFix/formatNamedReExport.ts +0 -21
- package/src/rules/sortedReExports/createFix/getReplacementRange.ts +0 -22
- package/src/rules/sortedReExports/createFix/groupReExportsByType.ts +0 -18
- package/src/rules/sortedReExports/createFix/index.ts +0 -47
- package/src/rules/sortedReExports/createFix/sortExportGroups.ts +0 -12
- package/src/rules/sortedReExports/getNamedSpecifiers.ts +0 -9
- package/src/rules/sortedReExports/getReExportGroups.ts +0 -33
- package/src/rules/sortedReExports/getSortKey.ts +0 -22
- package/src/rules/sortedReExports/getSpecifierName.ts +0 -7
- package/src/rules/sortedReExports/index.ts +0 -63
- package/src/rules/sortedReExports/isNamedReExport.ts +0 -6
- package/src/rules/sortedReExports/sortSpecifiersText.ts +0 -16
- package/tsdown.config.ts +0 -22
package/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.
|
|
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": "
|
|
13
|
+
"main": "dist/index.mjs",
|
|
14
14
|
"exports": {
|
|
15
15
|
"import": {
|
|
16
|
-
"types": "./dist/index.d.
|
|
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/
|
|
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
|
-
"
|
|
49
|
-
"
|
|
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": "
|
|
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
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
package/dist/index.d.mts
DELETED
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
|
-
]
|
package/src/lib/compare.ts
DELETED
|
@@ -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,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
|
-
})
|