@commencis/eslint-config 1.7.5 → 2.0.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @commencis/eslint-config
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - feat: enable consistent type imports ([#368](https://github.com/Commencis/js-toolkit/pull/368))
8
+
9
+ ## 1.8.0
10
+
11
+ ### Minor Changes
12
+
13
+ - chore(deps): update eslint monorepo to v9.34.0 ([#364](https://github.com/Commencis/js-toolkit/pull/364))
14
+
3
15
  ## 1.7.5
4
16
 
5
17
  ### Patch Changes
@@ -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: [exact(""), subpath("")],
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
- // Side effects
15
- ["^\\u0000"],
16
- // Main frameworks & libraries
17
- [
18
- "^(react(-native|-dom)?(/.*)?)$",
19
- "^next",
20
- "^vue",
21
- "^nuxt",
22
- "^@angular(/.*|$)",
23
- "^expo",
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
  ],
@@ -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: [exact(""), subpath("")],
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
- // Side effects
15
- ["^\\u0000"],
16
- // Main frameworks & libraries
17
- [
18
- "^(react(-native|-dom)?(/.*)?)$",
19
- "^next",
20
- "^vue",
21
- "^nuxt",
22
- "^@angular(/.*|$)",
23
- "^expo",
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
  ],
@@ -81,6 +127,7 @@ var typescriptRules = {
81
127
  "@typescript-eslint/consistent-type-definitions": "off",
82
128
  "@typescript-eslint/no-empty-function": "off",
83
129
  "@typescript-eslint/array-type": "off",
130
+ "@typescript-eslint/consistent-type-imports": "error",
84
131
  "@typescript-eslint/explicit-function-return-type": "error",
85
132
  "@typescript-eslint/no-unused-vars": [
86
133
  "error",
@@ -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: [exact(""), subpath("")],
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
- // Side effects
15
- ["^\\u0000"],
16
- // Main frameworks & libraries
17
- [
18
- "^(react(-native|-dom)?(/.*)?)$",
19
- "^next",
20
- "^vue",
21
- "^nuxt",
22
- "^@angular(/.*|$)",
23
- "^expo",
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
  ],
@@ -81,6 +127,7 @@ var typescriptRules = {
81
127
  "@typescript-eslint/consistent-type-definitions": "off",
82
128
  "@typescript-eslint/no-empty-function": "off",
83
129
  "@typescript-eslint/array-type": "off",
130
+ "@typescript-eslint/consistent-type-imports": "error",
84
131
  "@typescript-eslint/explicit-function-return-type": "error",
85
132
  "@typescript-eslint/no-unused-vars": [
86
133
  "error",
@@ -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: [exact(""), subpath("")],
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
- // Side effects
15
- ["^\\u0000"],
16
- // Main frameworks & libraries
17
- [
18
- "^(react(-native|-dom)?(/.*)?)$",
19
- "^next",
20
- "^vue",
21
- "^nuxt",
22
- "^@angular(/.*|$)",
23
- "^expo",
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
  ],
@@ -81,6 +127,7 @@ var typescriptRules = {
81
127
  "@typescript-eslint/consistent-type-definitions": "off",
82
128
  "@typescript-eslint/no-empty-function": "off",
83
129
  "@typescript-eslint/array-type": "off",
130
+ "@typescript-eslint/consistent-type-imports": "error",
84
131
  "@typescript-eslint/explicit-function-return-type": "error",
85
132
  "@typescript-eslint/no-unused-vars": [
86
133
  "error",
@@ -1,11 +1,98 @@
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: [exact(""), subpath("")],
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",
95
+ "@typescript-eslint/consistent-type-imports": "error",
9
96
  "@typescript-eslint/explicit-function-return-type": "error",
10
97
  "@typescript-eslint/no-unused-vars": [
11
98
  "error",
@@ -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: [exact(""), subpath("")],
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
- // Side effects
18
- ["^\\u0000"],
19
- // Main frameworks & libraries
20
- [
21
- "^(react(-native|-dom)?(/.*)?)$",
22
- "^next",
23
- "^vue",
24
- "^nuxt",
25
- "^@angular(/.*|$)",
26
- "^expo",
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
  ],
@@ -84,6 +130,7 @@ var typescriptRules = {
84
130
  "@typescript-eslint/consistent-type-definitions": "off",
85
131
  "@typescript-eslint/no-empty-function": "off",
86
132
  "@typescript-eslint/array-type": "off",
133
+ "@typescript-eslint/consistent-type-imports": "error",
87
134
  "@typescript-eslint/explicit-function-return-type": "error",
88
135
  "@typescript-eslint/no-unused-vars": [
89
136
  "error",
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: [exact(""), subpath("")],
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
- // Side effects
18
- ["^\\u0000"],
19
- // Main frameworks & libraries
20
- [
21
- "^(react(-native|-dom)?(/.*)?)$",
22
- "^next",
23
- "^vue",
24
- "^nuxt",
25
- "^@angular(/.*|$)",
26
- "^expo",
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
  ],
@@ -84,6 +130,7 @@ var typescriptRules = {
84
130
  "@typescript-eslint/consistent-type-definitions": "off",
85
131
  "@typescript-eslint/no-empty-function": "off",
86
132
  "@typescript-eslint/array-type": "off",
133
+ "@typescript-eslint/consistent-type-imports": "error",
87
134
  "@typescript-eslint/explicit-function-return-type": "error",
88
135
  "@typescript-eslint/no-unused-vars": [
89
136
  "error",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commencis/eslint-config",
3
- "version": "1.7.5",
3
+ "version": "2.0.0",
4
4
  "description": "Commencis ESLint config",
5
5
  "author": "Commencis WEB Team",
6
6
  "license": "Apache-2.0",
@@ -58,7 +58,7 @@
58
58
  }
59
59
  },
60
60
  "dependencies": {
61
- "@eslint/js": "9.33.0",
61
+ "@eslint/js": "9.34.0",
62
62
  "@next/eslint-plugin-next": "15.5.0",
63
63
  "@typescript-eslint/utils": "8.40.0",
64
64
  "eslint-config-prettier": "10.1.8",
@@ -73,9 +73,9 @@
73
73
  },
74
74
  "devDependencies": {
75
75
  "@commencis/ts-config": "0.0.2",
76
- "eslint": "9.33.0",
76
+ "eslint": "9.34.0",
77
77
  "tsup": "8.5.0",
78
- "typescript": "5.8.3"
78
+ "typescript": "5.9.2"
79
79
  },
80
80
  "peerDependencies": {
81
81
  "eslint": ">= 9.7"