@commencis/eslint-config 1.8.0 → 2.1.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/CHANGELOG.md +12 -0
- package/dist/configs/base.js +74 -28
- package/dist/configs/next.js +81 -28
- package/dist/configs/react-native.js +81 -28
- package/dist/configs/react.js +81 -28
- package/dist/configs/typescript.js +93 -0
- package/dist/configs/vue.js +81 -28
- package/dist/index.js +81 -28
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @commencis/eslint-config
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- feat: update consistent type imports ([#370](https://github.com/Commencis/js-toolkit/pull/370))
|
|
8
|
+
|
|
9
|
+
## 2.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- feat: enable consistent type imports ([#368](https://github.com/Commencis/js-toolkit/pull/368))
|
|
14
|
+
|
|
3
15
|
## 1.8.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/configs/base.js
CHANGED
|
@@ -6,39 +6,85 @@ import globals from "globals";
|
|
|
6
6
|
import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
|
|
7
7
|
|
|
8
8
|
// src/rules/importSortRules.ts
|
|
9
|
+
function asTypeOnly(pattern) {
|
|
10
|
+
const base = pattern.endsWith("$") ? pattern.slice(0, -1) : pattern;
|
|
11
|
+
return `${base}\\u0000$`;
|
|
12
|
+
}
|
|
13
|
+
function withTypeFirst(group) {
|
|
14
|
+
return group.flatMap((pattern) => [asTypeOnly(pattern), pattern]);
|
|
15
|
+
}
|
|
16
|
+
function exact(p) {
|
|
17
|
+
return `^@/${p}$`;
|
|
18
|
+
}
|
|
19
|
+
function subpath(p) {
|
|
20
|
+
return `^@/${p}/.+$`;
|
|
21
|
+
}
|
|
22
|
+
function expandFolders(folders) {
|
|
23
|
+
return folders.flatMap((name) => [exact(name), subpath(name)]);
|
|
24
|
+
}
|
|
25
|
+
var GROUPS = {
|
|
26
|
+
// Side effects (simple-import-sort prefixes side-effects with \u0000 at the start)
|
|
27
|
+
SIDE_EFFECTS: ["^\\u0000"],
|
|
28
|
+
// Main frameworks & libraries
|
|
29
|
+
FRAMEWORKS: [
|
|
30
|
+
"^(react(-native|-dom)?(/.*)?)$",
|
|
31
|
+
"^next",
|
|
32
|
+
"^vue",
|
|
33
|
+
"^nuxt",
|
|
34
|
+
"^@angular(/.*|$)",
|
|
35
|
+
"^expo",
|
|
36
|
+
"^node"
|
|
37
|
+
],
|
|
38
|
+
// External packages
|
|
39
|
+
EXTERNAL: ["^@commencis", "^@?\\w"],
|
|
40
|
+
// Internal common directories
|
|
41
|
+
INTERNAL_COMMON: expandFolders([
|
|
42
|
+
"config",
|
|
43
|
+
"types",
|
|
44
|
+
"interfaces",
|
|
45
|
+
"constants",
|
|
46
|
+
"helpers",
|
|
47
|
+
"utils",
|
|
48
|
+
"lib"
|
|
49
|
+
]),
|
|
50
|
+
// Component directories
|
|
51
|
+
COMPONENTS: expandFolders([
|
|
52
|
+
"providers",
|
|
53
|
+
"layouts",
|
|
54
|
+
"pages",
|
|
55
|
+
"modules",
|
|
56
|
+
"features",
|
|
57
|
+
"components"
|
|
58
|
+
]),
|
|
59
|
+
// Internal root alias (catch-all leftover @/ imports)
|
|
60
|
+
INTERNAL_ROOT: ["^@/.+$"],
|
|
61
|
+
// Relative parent imports then same-dir relatives
|
|
62
|
+
RELATIVE_PARENT: ["^\\.\\.(?!/?$)", "^\\.\\./?$"],
|
|
63
|
+
RELATIVE_SAME: ["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
|
|
64
|
+
// Styles
|
|
65
|
+
STYLES: ["^.+\\.(s?css|(style(s)?)\\..+)$"],
|
|
66
|
+
// Assets
|
|
67
|
+
ASSETS: [
|
|
68
|
+
"(asset(s?)|public|static|images)(/.*|$)",
|
|
69
|
+
"^.+\\.svg$",
|
|
70
|
+
"^.+\\.png$"
|
|
71
|
+
]
|
|
72
|
+
};
|
|
9
73
|
var importSortRules = {
|
|
10
74
|
"simple-import-sort/imports": [
|
|
11
75
|
"error",
|
|
12
76
|
{
|
|
13
77
|
groups: [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"^node"
|
|
25
|
-
],
|
|
26
|
-
// External packages
|
|
27
|
-
["^@commencis", "^@?\\w"],
|
|
28
|
-
// Internal common directories
|
|
29
|
-
["^@?/?(config|types|interfaces|constants|helpers|utils|lib)(/.*|$)"],
|
|
30
|
-
// Internal directories
|
|
31
|
-
["^@/"],
|
|
32
|
-
// Components
|
|
33
|
-
["((.*)/)?(providers|layouts|pages|modules|features|components)/?"],
|
|
34
|
-
// Relative parent imports: '../' comes last
|
|
35
|
-
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
|
|
36
|
-
// Relative imports: './' comes last
|
|
37
|
-
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
|
|
38
|
-
// Styles
|
|
39
|
-
["^.+\\.(s?css|(style(s)?)\\..+)$"],
|
|
40
|
-
// Static assets
|
|
41
|
-
["(asset(s?)|public|static|images)(/.*|$)", "^.+\\.svg$", "^.+\\.png$"]
|
|
78
|
+
GROUPS.SIDE_EFFECTS,
|
|
79
|
+
withTypeFirst(GROUPS.FRAMEWORKS),
|
|
80
|
+
withTypeFirst(GROUPS.EXTERNAL),
|
|
81
|
+
withTypeFirst(GROUPS.INTERNAL_COMMON),
|
|
82
|
+
withTypeFirst(GROUPS.COMPONENTS),
|
|
83
|
+
withTypeFirst(GROUPS.INTERNAL_ROOT),
|
|
84
|
+
withTypeFirst(GROUPS.RELATIVE_PARENT),
|
|
85
|
+
withTypeFirst(GROUPS.RELATIVE_SAME),
|
|
86
|
+
GROUPS.STYLES,
|
|
87
|
+
GROUPS.ASSETS
|
|
42
88
|
]
|
|
43
89
|
}
|
|
44
90
|
],
|
package/dist/configs/next.js
CHANGED
|
@@ -6,39 +6,85 @@ import globals from "globals";
|
|
|
6
6
|
import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
|
|
7
7
|
|
|
8
8
|
// src/rules/importSortRules.ts
|
|
9
|
+
function asTypeOnly(pattern) {
|
|
10
|
+
const base = pattern.endsWith("$") ? pattern.slice(0, -1) : pattern;
|
|
11
|
+
return `${base}\\u0000$`;
|
|
12
|
+
}
|
|
13
|
+
function withTypeFirst(group) {
|
|
14
|
+
return group.flatMap((pattern) => [asTypeOnly(pattern), pattern]);
|
|
15
|
+
}
|
|
16
|
+
function exact(p) {
|
|
17
|
+
return `^@/${p}$`;
|
|
18
|
+
}
|
|
19
|
+
function subpath(p) {
|
|
20
|
+
return `^@/${p}/.+$`;
|
|
21
|
+
}
|
|
22
|
+
function expandFolders(folders) {
|
|
23
|
+
return folders.flatMap((name) => [exact(name), subpath(name)]);
|
|
24
|
+
}
|
|
25
|
+
var GROUPS = {
|
|
26
|
+
// Side effects (simple-import-sort prefixes side-effects with \u0000 at the start)
|
|
27
|
+
SIDE_EFFECTS: ["^\\u0000"],
|
|
28
|
+
// Main frameworks & libraries
|
|
29
|
+
FRAMEWORKS: [
|
|
30
|
+
"^(react(-native|-dom)?(/.*)?)$",
|
|
31
|
+
"^next",
|
|
32
|
+
"^vue",
|
|
33
|
+
"^nuxt",
|
|
34
|
+
"^@angular(/.*|$)",
|
|
35
|
+
"^expo",
|
|
36
|
+
"^node"
|
|
37
|
+
],
|
|
38
|
+
// External packages
|
|
39
|
+
EXTERNAL: ["^@commencis", "^@?\\w"],
|
|
40
|
+
// Internal common directories
|
|
41
|
+
INTERNAL_COMMON: expandFolders([
|
|
42
|
+
"config",
|
|
43
|
+
"types",
|
|
44
|
+
"interfaces",
|
|
45
|
+
"constants",
|
|
46
|
+
"helpers",
|
|
47
|
+
"utils",
|
|
48
|
+
"lib"
|
|
49
|
+
]),
|
|
50
|
+
// Component directories
|
|
51
|
+
COMPONENTS: expandFolders([
|
|
52
|
+
"providers",
|
|
53
|
+
"layouts",
|
|
54
|
+
"pages",
|
|
55
|
+
"modules",
|
|
56
|
+
"features",
|
|
57
|
+
"components"
|
|
58
|
+
]),
|
|
59
|
+
// Internal root alias (catch-all leftover @/ imports)
|
|
60
|
+
INTERNAL_ROOT: ["^@/.+$"],
|
|
61
|
+
// Relative parent imports then same-dir relatives
|
|
62
|
+
RELATIVE_PARENT: ["^\\.\\.(?!/?$)", "^\\.\\./?$"],
|
|
63
|
+
RELATIVE_SAME: ["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
|
|
64
|
+
// Styles
|
|
65
|
+
STYLES: ["^.+\\.(s?css|(style(s)?)\\..+)$"],
|
|
66
|
+
// Assets
|
|
67
|
+
ASSETS: [
|
|
68
|
+
"(asset(s?)|public|static|images)(/.*|$)",
|
|
69
|
+
"^.+\\.svg$",
|
|
70
|
+
"^.+\\.png$"
|
|
71
|
+
]
|
|
72
|
+
};
|
|
9
73
|
var importSortRules = {
|
|
10
74
|
"simple-import-sort/imports": [
|
|
11
75
|
"error",
|
|
12
76
|
{
|
|
13
77
|
groups: [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"^node"
|
|
25
|
-
],
|
|
26
|
-
// External packages
|
|
27
|
-
["^@commencis", "^@?\\w"],
|
|
28
|
-
// Internal common directories
|
|
29
|
-
["^@?/?(config|types|interfaces|constants|helpers|utils|lib)(/.*|$)"],
|
|
30
|
-
// Internal directories
|
|
31
|
-
["^@/"],
|
|
32
|
-
// Components
|
|
33
|
-
["((.*)/)?(providers|layouts|pages|modules|features|components)/?"],
|
|
34
|
-
// Relative parent imports: '../' comes last
|
|
35
|
-
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
|
|
36
|
-
// Relative imports: './' comes last
|
|
37
|
-
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
|
|
38
|
-
// Styles
|
|
39
|
-
["^.+\\.(s?css|(style(s)?)\\..+)$"],
|
|
40
|
-
// Static assets
|
|
41
|
-
["(asset(s?)|public|static|images)(/.*|$)", "^.+\\.svg$", "^.+\\.png$"]
|
|
78
|
+
GROUPS.SIDE_EFFECTS,
|
|
79
|
+
withTypeFirst(GROUPS.FRAMEWORKS),
|
|
80
|
+
withTypeFirst(GROUPS.EXTERNAL),
|
|
81
|
+
withTypeFirst(GROUPS.INTERNAL_COMMON),
|
|
82
|
+
withTypeFirst(GROUPS.COMPONENTS),
|
|
83
|
+
withTypeFirst(GROUPS.INTERNAL_ROOT),
|
|
84
|
+
withTypeFirst(GROUPS.RELATIVE_PARENT),
|
|
85
|
+
withTypeFirst(GROUPS.RELATIVE_SAME),
|
|
86
|
+
GROUPS.STYLES,
|
|
87
|
+
GROUPS.ASSETS
|
|
42
88
|
]
|
|
43
89
|
}
|
|
44
90
|
],
|
|
@@ -82,6 +128,13 @@ var typescriptRules = {
|
|
|
82
128
|
"@typescript-eslint/no-empty-function": "off",
|
|
83
129
|
"@typescript-eslint/array-type": "off",
|
|
84
130
|
"@typescript-eslint/explicit-function-return-type": "error",
|
|
131
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
132
|
+
"error",
|
|
133
|
+
{
|
|
134
|
+
prefer: "type-imports",
|
|
135
|
+
fixStyle: "separate-type-imports"
|
|
136
|
+
}
|
|
137
|
+
],
|
|
85
138
|
"@typescript-eslint/no-unused-vars": [
|
|
86
139
|
"error",
|
|
87
140
|
{
|
|
@@ -6,39 +6,85 @@ import globals from "globals";
|
|
|
6
6
|
import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
|
|
7
7
|
|
|
8
8
|
// src/rules/importSortRules.ts
|
|
9
|
+
function asTypeOnly(pattern) {
|
|
10
|
+
const base = pattern.endsWith("$") ? pattern.slice(0, -1) : pattern;
|
|
11
|
+
return `${base}\\u0000$`;
|
|
12
|
+
}
|
|
13
|
+
function withTypeFirst(group) {
|
|
14
|
+
return group.flatMap((pattern) => [asTypeOnly(pattern), pattern]);
|
|
15
|
+
}
|
|
16
|
+
function exact(p) {
|
|
17
|
+
return `^@/${p}$`;
|
|
18
|
+
}
|
|
19
|
+
function subpath(p) {
|
|
20
|
+
return `^@/${p}/.+$`;
|
|
21
|
+
}
|
|
22
|
+
function expandFolders(folders) {
|
|
23
|
+
return folders.flatMap((name) => [exact(name), subpath(name)]);
|
|
24
|
+
}
|
|
25
|
+
var GROUPS = {
|
|
26
|
+
// Side effects (simple-import-sort prefixes side-effects with \u0000 at the start)
|
|
27
|
+
SIDE_EFFECTS: ["^\\u0000"],
|
|
28
|
+
// Main frameworks & libraries
|
|
29
|
+
FRAMEWORKS: [
|
|
30
|
+
"^(react(-native|-dom)?(/.*)?)$",
|
|
31
|
+
"^next",
|
|
32
|
+
"^vue",
|
|
33
|
+
"^nuxt",
|
|
34
|
+
"^@angular(/.*|$)",
|
|
35
|
+
"^expo",
|
|
36
|
+
"^node"
|
|
37
|
+
],
|
|
38
|
+
// External packages
|
|
39
|
+
EXTERNAL: ["^@commencis", "^@?\\w"],
|
|
40
|
+
// Internal common directories
|
|
41
|
+
INTERNAL_COMMON: expandFolders([
|
|
42
|
+
"config",
|
|
43
|
+
"types",
|
|
44
|
+
"interfaces",
|
|
45
|
+
"constants",
|
|
46
|
+
"helpers",
|
|
47
|
+
"utils",
|
|
48
|
+
"lib"
|
|
49
|
+
]),
|
|
50
|
+
// Component directories
|
|
51
|
+
COMPONENTS: expandFolders([
|
|
52
|
+
"providers",
|
|
53
|
+
"layouts",
|
|
54
|
+
"pages",
|
|
55
|
+
"modules",
|
|
56
|
+
"features",
|
|
57
|
+
"components"
|
|
58
|
+
]),
|
|
59
|
+
// Internal root alias (catch-all leftover @/ imports)
|
|
60
|
+
INTERNAL_ROOT: ["^@/.+$"],
|
|
61
|
+
// Relative parent imports then same-dir relatives
|
|
62
|
+
RELATIVE_PARENT: ["^\\.\\.(?!/?$)", "^\\.\\./?$"],
|
|
63
|
+
RELATIVE_SAME: ["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
|
|
64
|
+
// Styles
|
|
65
|
+
STYLES: ["^.+\\.(s?css|(style(s)?)\\..+)$"],
|
|
66
|
+
// Assets
|
|
67
|
+
ASSETS: [
|
|
68
|
+
"(asset(s?)|public|static|images)(/.*|$)",
|
|
69
|
+
"^.+\\.svg$",
|
|
70
|
+
"^.+\\.png$"
|
|
71
|
+
]
|
|
72
|
+
};
|
|
9
73
|
var importSortRules = {
|
|
10
74
|
"simple-import-sort/imports": [
|
|
11
75
|
"error",
|
|
12
76
|
{
|
|
13
77
|
groups: [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"^node"
|
|
25
|
-
],
|
|
26
|
-
// External packages
|
|
27
|
-
["^@commencis", "^@?\\w"],
|
|
28
|
-
// Internal common directories
|
|
29
|
-
["^@?/?(config|types|interfaces|constants|helpers|utils|lib)(/.*|$)"],
|
|
30
|
-
// Internal directories
|
|
31
|
-
["^@/"],
|
|
32
|
-
// Components
|
|
33
|
-
["((.*)/)?(providers|layouts|pages|modules|features|components)/?"],
|
|
34
|
-
// Relative parent imports: '../' comes last
|
|
35
|
-
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
|
|
36
|
-
// Relative imports: './' comes last
|
|
37
|
-
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
|
|
38
|
-
// Styles
|
|
39
|
-
["^.+\\.(s?css|(style(s)?)\\..+)$"],
|
|
40
|
-
// Static assets
|
|
41
|
-
["(asset(s?)|public|static|images)(/.*|$)", "^.+\\.svg$", "^.+\\.png$"]
|
|
78
|
+
GROUPS.SIDE_EFFECTS,
|
|
79
|
+
withTypeFirst(GROUPS.FRAMEWORKS),
|
|
80
|
+
withTypeFirst(GROUPS.EXTERNAL),
|
|
81
|
+
withTypeFirst(GROUPS.INTERNAL_COMMON),
|
|
82
|
+
withTypeFirst(GROUPS.COMPONENTS),
|
|
83
|
+
withTypeFirst(GROUPS.INTERNAL_ROOT),
|
|
84
|
+
withTypeFirst(GROUPS.RELATIVE_PARENT),
|
|
85
|
+
withTypeFirst(GROUPS.RELATIVE_SAME),
|
|
86
|
+
GROUPS.STYLES,
|
|
87
|
+
GROUPS.ASSETS
|
|
42
88
|
]
|
|
43
89
|
}
|
|
44
90
|
],
|
|
@@ -82,6 +128,13 @@ var typescriptRules = {
|
|
|
82
128
|
"@typescript-eslint/no-empty-function": "off",
|
|
83
129
|
"@typescript-eslint/array-type": "off",
|
|
84
130
|
"@typescript-eslint/explicit-function-return-type": "error",
|
|
131
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
132
|
+
"error",
|
|
133
|
+
{
|
|
134
|
+
prefer: "type-imports",
|
|
135
|
+
fixStyle: "separate-type-imports"
|
|
136
|
+
}
|
|
137
|
+
],
|
|
85
138
|
"@typescript-eslint/no-unused-vars": [
|
|
86
139
|
"error",
|
|
87
140
|
{
|
package/dist/configs/react.js
CHANGED
|
@@ -6,39 +6,85 @@ import globals from "globals";
|
|
|
6
6
|
import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
|
|
7
7
|
|
|
8
8
|
// src/rules/importSortRules.ts
|
|
9
|
+
function asTypeOnly(pattern) {
|
|
10
|
+
const base = pattern.endsWith("$") ? pattern.slice(0, -1) : pattern;
|
|
11
|
+
return `${base}\\u0000$`;
|
|
12
|
+
}
|
|
13
|
+
function withTypeFirst(group) {
|
|
14
|
+
return group.flatMap((pattern) => [asTypeOnly(pattern), pattern]);
|
|
15
|
+
}
|
|
16
|
+
function exact(p) {
|
|
17
|
+
return `^@/${p}$`;
|
|
18
|
+
}
|
|
19
|
+
function subpath(p) {
|
|
20
|
+
return `^@/${p}/.+$`;
|
|
21
|
+
}
|
|
22
|
+
function expandFolders(folders) {
|
|
23
|
+
return folders.flatMap((name) => [exact(name), subpath(name)]);
|
|
24
|
+
}
|
|
25
|
+
var GROUPS = {
|
|
26
|
+
// Side effects (simple-import-sort prefixes side-effects with \u0000 at the start)
|
|
27
|
+
SIDE_EFFECTS: ["^\\u0000"],
|
|
28
|
+
// Main frameworks & libraries
|
|
29
|
+
FRAMEWORKS: [
|
|
30
|
+
"^(react(-native|-dom)?(/.*)?)$",
|
|
31
|
+
"^next",
|
|
32
|
+
"^vue",
|
|
33
|
+
"^nuxt",
|
|
34
|
+
"^@angular(/.*|$)",
|
|
35
|
+
"^expo",
|
|
36
|
+
"^node"
|
|
37
|
+
],
|
|
38
|
+
// External packages
|
|
39
|
+
EXTERNAL: ["^@commencis", "^@?\\w"],
|
|
40
|
+
// Internal common directories
|
|
41
|
+
INTERNAL_COMMON: expandFolders([
|
|
42
|
+
"config",
|
|
43
|
+
"types",
|
|
44
|
+
"interfaces",
|
|
45
|
+
"constants",
|
|
46
|
+
"helpers",
|
|
47
|
+
"utils",
|
|
48
|
+
"lib"
|
|
49
|
+
]),
|
|
50
|
+
// Component directories
|
|
51
|
+
COMPONENTS: expandFolders([
|
|
52
|
+
"providers",
|
|
53
|
+
"layouts",
|
|
54
|
+
"pages",
|
|
55
|
+
"modules",
|
|
56
|
+
"features",
|
|
57
|
+
"components"
|
|
58
|
+
]),
|
|
59
|
+
// Internal root alias (catch-all leftover @/ imports)
|
|
60
|
+
INTERNAL_ROOT: ["^@/.+$"],
|
|
61
|
+
// Relative parent imports then same-dir relatives
|
|
62
|
+
RELATIVE_PARENT: ["^\\.\\.(?!/?$)", "^\\.\\./?$"],
|
|
63
|
+
RELATIVE_SAME: ["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
|
|
64
|
+
// Styles
|
|
65
|
+
STYLES: ["^.+\\.(s?css|(style(s)?)\\..+)$"],
|
|
66
|
+
// Assets
|
|
67
|
+
ASSETS: [
|
|
68
|
+
"(asset(s?)|public|static|images)(/.*|$)",
|
|
69
|
+
"^.+\\.svg$",
|
|
70
|
+
"^.+\\.png$"
|
|
71
|
+
]
|
|
72
|
+
};
|
|
9
73
|
var importSortRules = {
|
|
10
74
|
"simple-import-sort/imports": [
|
|
11
75
|
"error",
|
|
12
76
|
{
|
|
13
77
|
groups: [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"^node"
|
|
25
|
-
],
|
|
26
|
-
// External packages
|
|
27
|
-
["^@commencis", "^@?\\w"],
|
|
28
|
-
// Internal common directories
|
|
29
|
-
["^@?/?(config|types|interfaces|constants|helpers|utils|lib)(/.*|$)"],
|
|
30
|
-
// Internal directories
|
|
31
|
-
["^@/"],
|
|
32
|
-
// Components
|
|
33
|
-
["((.*)/)?(providers|layouts|pages|modules|features|components)/?"],
|
|
34
|
-
// Relative parent imports: '../' comes last
|
|
35
|
-
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
|
|
36
|
-
// Relative imports: './' comes last
|
|
37
|
-
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
|
|
38
|
-
// Styles
|
|
39
|
-
["^.+\\.(s?css|(style(s)?)\\..+)$"],
|
|
40
|
-
// Static assets
|
|
41
|
-
["(asset(s?)|public|static|images)(/.*|$)", "^.+\\.svg$", "^.+\\.png$"]
|
|
78
|
+
GROUPS.SIDE_EFFECTS,
|
|
79
|
+
withTypeFirst(GROUPS.FRAMEWORKS),
|
|
80
|
+
withTypeFirst(GROUPS.EXTERNAL),
|
|
81
|
+
withTypeFirst(GROUPS.INTERNAL_COMMON),
|
|
82
|
+
withTypeFirst(GROUPS.COMPONENTS),
|
|
83
|
+
withTypeFirst(GROUPS.INTERNAL_ROOT),
|
|
84
|
+
withTypeFirst(GROUPS.RELATIVE_PARENT),
|
|
85
|
+
withTypeFirst(GROUPS.RELATIVE_SAME),
|
|
86
|
+
GROUPS.STYLES,
|
|
87
|
+
GROUPS.ASSETS
|
|
42
88
|
]
|
|
43
89
|
}
|
|
44
90
|
],
|
|
@@ -82,6 +128,13 @@ var typescriptRules = {
|
|
|
82
128
|
"@typescript-eslint/no-empty-function": "off",
|
|
83
129
|
"@typescript-eslint/array-type": "off",
|
|
84
130
|
"@typescript-eslint/explicit-function-return-type": "error",
|
|
131
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
132
|
+
"error",
|
|
133
|
+
{
|
|
134
|
+
prefer: "type-imports",
|
|
135
|
+
fixStyle: "separate-type-imports"
|
|
136
|
+
}
|
|
137
|
+
],
|
|
85
138
|
"@typescript-eslint/no-unused-vars": [
|
|
86
139
|
"error",
|
|
87
140
|
{
|
|
@@ -1,12 +1,105 @@
|
|
|
1
1
|
// src/configs/typescript.ts
|
|
2
2
|
import tseslint from "typescript-eslint";
|
|
3
3
|
|
|
4
|
+
// src/rules/importSortRules.ts
|
|
5
|
+
function asTypeOnly(pattern) {
|
|
6
|
+
const base = pattern.endsWith("$") ? pattern.slice(0, -1) : pattern;
|
|
7
|
+
return `${base}\\u0000$`;
|
|
8
|
+
}
|
|
9
|
+
function withTypeFirst(group) {
|
|
10
|
+
return group.flatMap((pattern) => [asTypeOnly(pattern), pattern]);
|
|
11
|
+
}
|
|
12
|
+
function exact(p) {
|
|
13
|
+
return `^@/${p}$`;
|
|
14
|
+
}
|
|
15
|
+
function subpath(p) {
|
|
16
|
+
return `^@/${p}/.+$`;
|
|
17
|
+
}
|
|
18
|
+
function expandFolders(folders) {
|
|
19
|
+
return folders.flatMap((name) => [exact(name), subpath(name)]);
|
|
20
|
+
}
|
|
21
|
+
var GROUPS = {
|
|
22
|
+
// Side effects (simple-import-sort prefixes side-effects with \u0000 at the start)
|
|
23
|
+
SIDE_EFFECTS: ["^\\u0000"],
|
|
24
|
+
// Main frameworks & libraries
|
|
25
|
+
FRAMEWORKS: [
|
|
26
|
+
"^(react(-native|-dom)?(/.*)?)$",
|
|
27
|
+
"^next",
|
|
28
|
+
"^vue",
|
|
29
|
+
"^nuxt",
|
|
30
|
+
"^@angular(/.*|$)",
|
|
31
|
+
"^expo",
|
|
32
|
+
"^node"
|
|
33
|
+
],
|
|
34
|
+
// External packages
|
|
35
|
+
EXTERNAL: ["^@commencis", "^@?\\w"],
|
|
36
|
+
// Internal common directories
|
|
37
|
+
INTERNAL_COMMON: expandFolders([
|
|
38
|
+
"config",
|
|
39
|
+
"types",
|
|
40
|
+
"interfaces",
|
|
41
|
+
"constants",
|
|
42
|
+
"helpers",
|
|
43
|
+
"utils",
|
|
44
|
+
"lib"
|
|
45
|
+
]),
|
|
46
|
+
// Component directories
|
|
47
|
+
COMPONENTS: expandFolders([
|
|
48
|
+
"providers",
|
|
49
|
+
"layouts",
|
|
50
|
+
"pages",
|
|
51
|
+
"modules",
|
|
52
|
+
"features",
|
|
53
|
+
"components"
|
|
54
|
+
]),
|
|
55
|
+
// Internal root alias (catch-all leftover @/ imports)
|
|
56
|
+
INTERNAL_ROOT: ["^@/.+$"],
|
|
57
|
+
// Relative parent imports then same-dir relatives
|
|
58
|
+
RELATIVE_PARENT: ["^\\.\\.(?!/?$)", "^\\.\\./?$"],
|
|
59
|
+
RELATIVE_SAME: ["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
|
|
60
|
+
// Styles
|
|
61
|
+
STYLES: ["^.+\\.(s?css|(style(s)?)\\..+)$"],
|
|
62
|
+
// Assets
|
|
63
|
+
ASSETS: [
|
|
64
|
+
"(asset(s?)|public|static|images)(/.*|$)",
|
|
65
|
+
"^.+\\.svg$",
|
|
66
|
+
"^.+\\.png$"
|
|
67
|
+
]
|
|
68
|
+
};
|
|
69
|
+
var importSortRules = {
|
|
70
|
+
"simple-import-sort/imports": [
|
|
71
|
+
"error",
|
|
72
|
+
{
|
|
73
|
+
groups: [
|
|
74
|
+
GROUPS.SIDE_EFFECTS,
|
|
75
|
+
withTypeFirst(GROUPS.FRAMEWORKS),
|
|
76
|
+
withTypeFirst(GROUPS.EXTERNAL),
|
|
77
|
+
withTypeFirst(GROUPS.INTERNAL_COMMON),
|
|
78
|
+
withTypeFirst(GROUPS.COMPONENTS),
|
|
79
|
+
withTypeFirst(GROUPS.INTERNAL_ROOT),
|
|
80
|
+
withTypeFirst(GROUPS.RELATIVE_PARENT),
|
|
81
|
+
withTypeFirst(GROUPS.RELATIVE_SAME),
|
|
82
|
+
GROUPS.STYLES,
|
|
83
|
+
GROUPS.ASSETS
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
"simple-import-sort/exports": "error"
|
|
88
|
+
};
|
|
89
|
+
|
|
4
90
|
// src/rules/typescriptRules.ts
|
|
5
91
|
var typescriptRules = {
|
|
6
92
|
"@typescript-eslint/consistent-type-definitions": "off",
|
|
7
93
|
"@typescript-eslint/no-empty-function": "off",
|
|
8
94
|
"@typescript-eslint/array-type": "off",
|
|
9
95
|
"@typescript-eslint/explicit-function-return-type": "error",
|
|
96
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
97
|
+
"error",
|
|
98
|
+
{
|
|
99
|
+
prefer: "type-imports",
|
|
100
|
+
fixStyle: "separate-type-imports"
|
|
101
|
+
}
|
|
102
|
+
],
|
|
10
103
|
"@typescript-eslint/no-unused-vars": [
|
|
11
104
|
"error",
|
|
12
105
|
{
|
package/dist/configs/vue.js
CHANGED
|
@@ -9,39 +9,85 @@ import globals from "globals";
|
|
|
9
9
|
import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
|
|
10
10
|
|
|
11
11
|
// src/rules/importSortRules.ts
|
|
12
|
+
function asTypeOnly(pattern) {
|
|
13
|
+
const base = pattern.endsWith("$") ? pattern.slice(0, -1) : pattern;
|
|
14
|
+
return `${base}\\u0000$`;
|
|
15
|
+
}
|
|
16
|
+
function withTypeFirst(group) {
|
|
17
|
+
return group.flatMap((pattern) => [asTypeOnly(pattern), pattern]);
|
|
18
|
+
}
|
|
19
|
+
function exact(p) {
|
|
20
|
+
return `^@/${p}$`;
|
|
21
|
+
}
|
|
22
|
+
function subpath(p) {
|
|
23
|
+
return `^@/${p}/.+$`;
|
|
24
|
+
}
|
|
25
|
+
function expandFolders(folders) {
|
|
26
|
+
return folders.flatMap((name) => [exact(name), subpath(name)]);
|
|
27
|
+
}
|
|
28
|
+
var GROUPS = {
|
|
29
|
+
// Side effects (simple-import-sort prefixes side-effects with \u0000 at the start)
|
|
30
|
+
SIDE_EFFECTS: ["^\\u0000"],
|
|
31
|
+
// Main frameworks & libraries
|
|
32
|
+
FRAMEWORKS: [
|
|
33
|
+
"^(react(-native|-dom)?(/.*)?)$",
|
|
34
|
+
"^next",
|
|
35
|
+
"^vue",
|
|
36
|
+
"^nuxt",
|
|
37
|
+
"^@angular(/.*|$)",
|
|
38
|
+
"^expo",
|
|
39
|
+
"^node"
|
|
40
|
+
],
|
|
41
|
+
// External packages
|
|
42
|
+
EXTERNAL: ["^@commencis", "^@?\\w"],
|
|
43
|
+
// Internal common directories
|
|
44
|
+
INTERNAL_COMMON: expandFolders([
|
|
45
|
+
"config",
|
|
46
|
+
"types",
|
|
47
|
+
"interfaces",
|
|
48
|
+
"constants",
|
|
49
|
+
"helpers",
|
|
50
|
+
"utils",
|
|
51
|
+
"lib"
|
|
52
|
+
]),
|
|
53
|
+
// Component directories
|
|
54
|
+
COMPONENTS: expandFolders([
|
|
55
|
+
"providers",
|
|
56
|
+
"layouts",
|
|
57
|
+
"pages",
|
|
58
|
+
"modules",
|
|
59
|
+
"features",
|
|
60
|
+
"components"
|
|
61
|
+
]),
|
|
62
|
+
// Internal root alias (catch-all leftover @/ imports)
|
|
63
|
+
INTERNAL_ROOT: ["^@/.+$"],
|
|
64
|
+
// Relative parent imports then same-dir relatives
|
|
65
|
+
RELATIVE_PARENT: ["^\\.\\.(?!/?$)", "^\\.\\./?$"],
|
|
66
|
+
RELATIVE_SAME: ["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
|
|
67
|
+
// Styles
|
|
68
|
+
STYLES: ["^.+\\.(s?css|(style(s)?)\\..+)$"],
|
|
69
|
+
// Assets
|
|
70
|
+
ASSETS: [
|
|
71
|
+
"(asset(s?)|public|static|images)(/.*|$)",
|
|
72
|
+
"^.+\\.svg$",
|
|
73
|
+
"^.+\\.png$"
|
|
74
|
+
]
|
|
75
|
+
};
|
|
12
76
|
var importSortRules = {
|
|
13
77
|
"simple-import-sort/imports": [
|
|
14
78
|
"error",
|
|
15
79
|
{
|
|
16
80
|
groups: [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"^node"
|
|
28
|
-
],
|
|
29
|
-
// External packages
|
|
30
|
-
["^@commencis", "^@?\\w"],
|
|
31
|
-
// Internal common directories
|
|
32
|
-
["^@?/?(config|types|interfaces|constants|helpers|utils|lib)(/.*|$)"],
|
|
33
|
-
// Internal directories
|
|
34
|
-
["^@/"],
|
|
35
|
-
// Components
|
|
36
|
-
["((.*)/)?(providers|layouts|pages|modules|features|components)/?"],
|
|
37
|
-
// Relative parent imports: '../' comes last
|
|
38
|
-
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
|
|
39
|
-
// Relative imports: './' comes last
|
|
40
|
-
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
|
|
41
|
-
// Styles
|
|
42
|
-
["^.+\\.(s?css|(style(s)?)\\..+)$"],
|
|
43
|
-
// Static assets
|
|
44
|
-
["(asset(s?)|public|static|images)(/.*|$)", "^.+\\.svg$", "^.+\\.png$"]
|
|
81
|
+
GROUPS.SIDE_EFFECTS,
|
|
82
|
+
withTypeFirst(GROUPS.FRAMEWORKS),
|
|
83
|
+
withTypeFirst(GROUPS.EXTERNAL),
|
|
84
|
+
withTypeFirst(GROUPS.INTERNAL_COMMON),
|
|
85
|
+
withTypeFirst(GROUPS.COMPONENTS),
|
|
86
|
+
withTypeFirst(GROUPS.INTERNAL_ROOT),
|
|
87
|
+
withTypeFirst(GROUPS.RELATIVE_PARENT),
|
|
88
|
+
withTypeFirst(GROUPS.RELATIVE_SAME),
|
|
89
|
+
GROUPS.STYLES,
|
|
90
|
+
GROUPS.ASSETS
|
|
45
91
|
]
|
|
46
92
|
}
|
|
47
93
|
],
|
|
@@ -85,6 +131,13 @@ var typescriptRules = {
|
|
|
85
131
|
"@typescript-eslint/no-empty-function": "off",
|
|
86
132
|
"@typescript-eslint/array-type": "off",
|
|
87
133
|
"@typescript-eslint/explicit-function-return-type": "error",
|
|
134
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
135
|
+
"error",
|
|
136
|
+
{
|
|
137
|
+
prefer: "type-imports",
|
|
138
|
+
fixStyle: "separate-type-imports"
|
|
139
|
+
}
|
|
140
|
+
],
|
|
88
141
|
"@typescript-eslint/no-unused-vars": [
|
|
89
142
|
"error",
|
|
90
143
|
{
|
package/dist/index.js
CHANGED
|
@@ -9,39 +9,85 @@ import globals from "globals";
|
|
|
9
9
|
import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
|
|
10
10
|
|
|
11
11
|
// src/rules/importSortRules.ts
|
|
12
|
+
function asTypeOnly(pattern) {
|
|
13
|
+
const base = pattern.endsWith("$") ? pattern.slice(0, -1) : pattern;
|
|
14
|
+
return `${base}\\u0000$`;
|
|
15
|
+
}
|
|
16
|
+
function withTypeFirst(group) {
|
|
17
|
+
return group.flatMap((pattern) => [asTypeOnly(pattern), pattern]);
|
|
18
|
+
}
|
|
19
|
+
function exact(p) {
|
|
20
|
+
return `^@/${p}$`;
|
|
21
|
+
}
|
|
22
|
+
function subpath(p) {
|
|
23
|
+
return `^@/${p}/.+$`;
|
|
24
|
+
}
|
|
25
|
+
function expandFolders(folders) {
|
|
26
|
+
return folders.flatMap((name) => [exact(name), subpath(name)]);
|
|
27
|
+
}
|
|
28
|
+
var GROUPS = {
|
|
29
|
+
// Side effects (simple-import-sort prefixes side-effects with \u0000 at the start)
|
|
30
|
+
SIDE_EFFECTS: ["^\\u0000"],
|
|
31
|
+
// Main frameworks & libraries
|
|
32
|
+
FRAMEWORKS: [
|
|
33
|
+
"^(react(-native|-dom)?(/.*)?)$",
|
|
34
|
+
"^next",
|
|
35
|
+
"^vue",
|
|
36
|
+
"^nuxt",
|
|
37
|
+
"^@angular(/.*|$)",
|
|
38
|
+
"^expo",
|
|
39
|
+
"^node"
|
|
40
|
+
],
|
|
41
|
+
// External packages
|
|
42
|
+
EXTERNAL: ["^@commencis", "^@?\\w"],
|
|
43
|
+
// Internal common directories
|
|
44
|
+
INTERNAL_COMMON: expandFolders([
|
|
45
|
+
"config",
|
|
46
|
+
"types",
|
|
47
|
+
"interfaces",
|
|
48
|
+
"constants",
|
|
49
|
+
"helpers",
|
|
50
|
+
"utils",
|
|
51
|
+
"lib"
|
|
52
|
+
]),
|
|
53
|
+
// Component directories
|
|
54
|
+
COMPONENTS: expandFolders([
|
|
55
|
+
"providers",
|
|
56
|
+
"layouts",
|
|
57
|
+
"pages",
|
|
58
|
+
"modules",
|
|
59
|
+
"features",
|
|
60
|
+
"components"
|
|
61
|
+
]),
|
|
62
|
+
// Internal root alias (catch-all leftover @/ imports)
|
|
63
|
+
INTERNAL_ROOT: ["^@/.+$"],
|
|
64
|
+
// Relative parent imports then same-dir relatives
|
|
65
|
+
RELATIVE_PARENT: ["^\\.\\.(?!/?$)", "^\\.\\./?$"],
|
|
66
|
+
RELATIVE_SAME: ["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
|
|
67
|
+
// Styles
|
|
68
|
+
STYLES: ["^.+\\.(s?css|(style(s)?)\\..+)$"],
|
|
69
|
+
// Assets
|
|
70
|
+
ASSETS: [
|
|
71
|
+
"(asset(s?)|public|static|images)(/.*|$)",
|
|
72
|
+
"^.+\\.svg$",
|
|
73
|
+
"^.+\\.png$"
|
|
74
|
+
]
|
|
75
|
+
};
|
|
12
76
|
var importSortRules = {
|
|
13
77
|
"simple-import-sort/imports": [
|
|
14
78
|
"error",
|
|
15
79
|
{
|
|
16
80
|
groups: [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"^node"
|
|
28
|
-
],
|
|
29
|
-
// External packages
|
|
30
|
-
["^@commencis", "^@?\\w"],
|
|
31
|
-
// Internal common directories
|
|
32
|
-
["^@?/?(config|types|interfaces|constants|helpers|utils|lib)(/.*|$)"],
|
|
33
|
-
// Internal directories
|
|
34
|
-
["^@/"],
|
|
35
|
-
// Components
|
|
36
|
-
["((.*)/)?(providers|layouts|pages|modules|features|components)/?"],
|
|
37
|
-
// Relative parent imports: '../' comes last
|
|
38
|
-
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
|
|
39
|
-
// Relative imports: './' comes last
|
|
40
|
-
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
|
|
41
|
-
// Styles
|
|
42
|
-
["^.+\\.(s?css|(style(s)?)\\..+)$"],
|
|
43
|
-
// Static assets
|
|
44
|
-
["(asset(s?)|public|static|images)(/.*|$)", "^.+\\.svg$", "^.+\\.png$"]
|
|
81
|
+
GROUPS.SIDE_EFFECTS,
|
|
82
|
+
withTypeFirst(GROUPS.FRAMEWORKS),
|
|
83
|
+
withTypeFirst(GROUPS.EXTERNAL),
|
|
84
|
+
withTypeFirst(GROUPS.INTERNAL_COMMON),
|
|
85
|
+
withTypeFirst(GROUPS.COMPONENTS),
|
|
86
|
+
withTypeFirst(GROUPS.INTERNAL_ROOT),
|
|
87
|
+
withTypeFirst(GROUPS.RELATIVE_PARENT),
|
|
88
|
+
withTypeFirst(GROUPS.RELATIVE_SAME),
|
|
89
|
+
GROUPS.STYLES,
|
|
90
|
+
GROUPS.ASSETS
|
|
45
91
|
]
|
|
46
92
|
}
|
|
47
93
|
],
|
|
@@ -85,6 +131,13 @@ var typescriptRules = {
|
|
|
85
131
|
"@typescript-eslint/no-empty-function": "off",
|
|
86
132
|
"@typescript-eslint/array-type": "off",
|
|
87
133
|
"@typescript-eslint/explicit-function-return-type": "error",
|
|
134
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
135
|
+
"error",
|
|
136
|
+
{
|
|
137
|
+
prefer: "type-imports",
|
|
138
|
+
fixStyle: "separate-type-imports"
|
|
139
|
+
}
|
|
140
|
+
],
|
|
88
141
|
"@typescript-eslint/no-unused-vars": [
|
|
89
142
|
"error",
|
|
90
143
|
{
|