eslint-plugin-barrel-rules 1.4.0 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ko.md +1 -1
- package/README.md +1 -1
- package/dist/index.cjs +43 -25
- package/dist/index.d.cts +15 -17
- package/dist/index.d.ts +15 -17
- package/dist/index.js +39 -25
- package/package.json +8 -8
package/README.ko.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# **Advanced Barrel Pattern Enforcement for JavaScript/TypeScript Projects**
|
|
4
4
|
|
|
5
5
|
<div align="center">
|
|
6
|
-
<img src="https://img.shields.io/badge/version-1.4.
|
|
6
|
+
<img src="https://img.shields.io/badge/version-1.4.2-blue.svg" alt="Version"/>
|
|
7
7
|
<img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License"/>
|
|
8
8
|
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs Welcome"/>
|
|
9
9
|
</div>
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# **Advanced Barrel Pattern Enforcement for JavaScript/TypeScript Projects**
|
|
4
4
|
|
|
5
5
|
<div align="center">
|
|
6
|
-
<img src="https://img.shields.io/badge/version-1.4.
|
|
6
|
+
<img src="https://img.shields.io/badge/version-1.4.2-blue.svg" alt="Version"/>
|
|
7
7
|
<img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License"/>
|
|
8
8
|
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs Welcome"/>
|
|
9
9
|
</div>
|
package/dist/index.cjs
CHANGED
|
@@ -30,7 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
-
|
|
33
|
+
rules: () => rules
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
|
|
@@ -106,33 +106,59 @@ var Alias = class {
|
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
// src/
|
|
109
|
+
// src/utils/constants.ts
|
|
110
110
|
var BARREL_ENTRY_POINT_FILE_NAMES = [
|
|
111
111
|
"index.ts",
|
|
112
|
+
// TypeScript entry
|
|
112
113
|
"index.tsx",
|
|
114
|
+
// React TypeScript entry
|
|
113
115
|
"index.js",
|
|
116
|
+
// JavaScript entry
|
|
114
117
|
"index.jsx",
|
|
118
|
+
// React JavaScript entry
|
|
115
119
|
"index.cjs",
|
|
116
|
-
|
|
117
|
-
"index.
|
|
120
|
+
// CommonJS entry
|
|
121
|
+
"index.mjs"
|
|
122
|
+
// ES Module entry
|
|
118
123
|
];
|
|
119
124
|
var RESOLVE_EXTENSIONS = [
|
|
120
125
|
".ts",
|
|
126
|
+
// TypeScript
|
|
121
127
|
".js",
|
|
128
|
+
// JavaScript
|
|
122
129
|
".tsx",
|
|
130
|
+
// React TypeScript
|
|
123
131
|
".jsx",
|
|
132
|
+
// React JavaScript
|
|
124
133
|
".json",
|
|
134
|
+
// JSON file
|
|
135
|
+
// Type declaration and transformed files
|
|
125
136
|
".d.js",
|
|
137
|
+
// JS file with type declarations (rare)
|
|
126
138
|
".d.ts",
|
|
139
|
+
// Type declaration file
|
|
140
|
+
// Various module systems
|
|
127
141
|
".mjs",
|
|
142
|
+
// ES Module
|
|
128
143
|
".cjs",
|
|
144
|
+
// CommonJS
|
|
145
|
+
// Module-related TypeScript extensions
|
|
129
146
|
".mts",
|
|
147
|
+
// ES Module TypeScript
|
|
130
148
|
".cts",
|
|
149
|
+
// CommonJS TypeScript
|
|
150
|
+
// Type declarations for module-related files
|
|
131
151
|
".d.mjs",
|
|
152
|
+
// Type declarations for ES Module
|
|
132
153
|
".d.cjs",
|
|
154
|
+
// Type declarations for CommonJS
|
|
133
155
|
".d.mts",
|
|
156
|
+
// Type declarations for ES Module TS
|
|
134
157
|
".d.cts"
|
|
158
|
+
// Type declarations for CommonJS TS
|
|
135
159
|
];
|
|
160
|
+
|
|
161
|
+
// src/rules/enforce-barrel-pattern.ts
|
|
136
162
|
var enforceBarrelPattern = {
|
|
137
163
|
meta: {
|
|
138
164
|
type: "problem",
|
|
@@ -265,23 +291,6 @@ var enforceBarrelPattern = {
|
|
|
265
291
|
var import_types2 = require("@typescript-eslint/types");
|
|
266
292
|
var import_path3 = __toESM(require("path"), 1);
|
|
267
293
|
var import_resolve2 = __toESM(require("resolve"), 1);
|
|
268
|
-
var RESOLVE_EXTENSIONS2 = [
|
|
269
|
-
".ts",
|
|
270
|
-
".js",
|
|
271
|
-
".tsx",
|
|
272
|
-
".jsx",
|
|
273
|
-
".json",
|
|
274
|
-
".d.js",
|
|
275
|
-
".d.ts",
|
|
276
|
-
".mjs",
|
|
277
|
-
".cjs",
|
|
278
|
-
".mts",
|
|
279
|
-
".cts",
|
|
280
|
-
".d.mjs",
|
|
281
|
-
".d.cjs",
|
|
282
|
-
".d.mts",
|
|
283
|
-
".d.cts"
|
|
284
|
-
];
|
|
285
294
|
var isolateBarrelFile = {
|
|
286
295
|
meta: {
|
|
287
296
|
type: "problem",
|
|
@@ -334,6 +343,9 @@ var isolateBarrelFile = {
|
|
|
334
343
|
//check only import declaration(ESM)
|
|
335
344
|
ImportDeclaration(node) {
|
|
336
345
|
const rawImportPath = node.source.value;
|
|
346
|
+
if (rawImportPath.includes("/node_modules/")) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
337
349
|
const absoluteCurrentFilePath = context.getFilename();
|
|
338
350
|
let absoluteImportPath = null;
|
|
339
351
|
try {
|
|
@@ -343,13 +355,16 @@ var isolateBarrelFile = {
|
|
|
343
355
|
);
|
|
344
356
|
if (aliasResult.type === "success") {
|
|
345
357
|
absoluteImportPath = aliasResult.absolutePath;
|
|
358
|
+
if (absoluteImportPath.includes("/node_modules/")) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
346
361
|
} else {
|
|
347
|
-
if (!rawImportPath.startsWith(".") && !rawImportPath.startsWith("/")
|
|
362
|
+
if (!rawImportPath.startsWith(".") && !rawImportPath.startsWith("/")) {
|
|
348
363
|
return;
|
|
349
364
|
}
|
|
350
365
|
absoluteImportPath = import_resolve2.default.sync(rawImportPath, {
|
|
351
366
|
basedir: import_path3.default.dirname(absoluteCurrentFilePath),
|
|
352
|
-
extensions:
|
|
367
|
+
extensions: RESOLVE_EXTENSIONS
|
|
353
368
|
});
|
|
354
369
|
}
|
|
355
370
|
} catch (e) {
|
|
@@ -437,6 +452,9 @@ var rules = {
|
|
|
437
452
|
"enforce-barrel-pattern": enforceBarrelPattern,
|
|
438
453
|
"isolate-barrel-file": isolateBarrelFile,
|
|
439
454
|
"no-wildcard": noWildcard
|
|
455
|
+
// "no-cycle": noCycle,
|
|
440
456
|
};
|
|
441
|
-
|
|
442
|
-
module.exports = {
|
|
457
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
458
|
+
0 && (module.exports = {
|
|
459
|
+
rules
|
|
460
|
+
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
2
2
|
|
|
3
|
-
declare const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"no-wildcard": _typescript_eslint_utils_ts_eslint.RuleModule<"NoWildcardImport" | "NoExportAll", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
18
|
-
};
|
|
3
|
+
declare const rules: {
|
|
4
|
+
"enforce-barrel-pattern": _typescript_eslint_utils_ts_eslint.RuleModule<"DirectImportDisallowed" | "TransformedAliasResolveFailed" | "EmptyEslintConfig", {
|
|
5
|
+
paths: string[];
|
|
6
|
+
baseDir: string;
|
|
7
|
+
}[], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
8
|
+
"isolate-barrel-file": _typescript_eslint_utils_ts_eslint.RuleModule<"TransformedAliasResolveFailed" | "IsolatedBarrelImportDisallowed", {
|
|
9
|
+
isolations: {
|
|
10
|
+
path: string;
|
|
11
|
+
allowedPaths: string[];
|
|
12
|
+
}[];
|
|
13
|
+
baseDir: string;
|
|
14
|
+
globalAllowPaths: string[];
|
|
15
|
+
}[], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
16
|
+
"no-wildcard": _typescript_eslint_utils_ts_eslint.RuleModule<"NoWildcardImport" | "NoExportAll", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
19
17
|
};
|
|
20
18
|
|
|
21
|
-
export {
|
|
19
|
+
export { rules };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
2
2
|
|
|
3
|
-
declare const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"no-wildcard": _typescript_eslint_utils_ts_eslint.RuleModule<"NoWildcardImport" | "NoExportAll", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
18
|
-
};
|
|
3
|
+
declare const rules: {
|
|
4
|
+
"enforce-barrel-pattern": _typescript_eslint_utils_ts_eslint.RuleModule<"DirectImportDisallowed" | "TransformedAliasResolveFailed" | "EmptyEslintConfig", {
|
|
5
|
+
paths: string[];
|
|
6
|
+
baseDir: string;
|
|
7
|
+
}[], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
8
|
+
"isolate-barrel-file": _typescript_eslint_utils_ts_eslint.RuleModule<"TransformedAliasResolveFailed" | "IsolatedBarrelImportDisallowed", {
|
|
9
|
+
isolations: {
|
|
10
|
+
path: string;
|
|
11
|
+
allowedPaths: string[];
|
|
12
|
+
}[];
|
|
13
|
+
baseDir: string;
|
|
14
|
+
globalAllowPaths: string[];
|
|
15
|
+
}[], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
16
|
+
"no-wildcard": _typescript_eslint_utils_ts_eslint.RuleModule<"NoWildcardImport" | "NoExportAll", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
19
17
|
};
|
|
20
18
|
|
|
21
|
-
export {
|
|
19
|
+
export { rules };
|
package/dist/index.js
CHANGED
|
@@ -70,33 +70,59 @@ var Alias = class {
|
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
// src/
|
|
73
|
+
// src/utils/constants.ts
|
|
74
74
|
var BARREL_ENTRY_POINT_FILE_NAMES = [
|
|
75
75
|
"index.ts",
|
|
76
|
+
// TypeScript entry
|
|
76
77
|
"index.tsx",
|
|
78
|
+
// React TypeScript entry
|
|
77
79
|
"index.js",
|
|
80
|
+
// JavaScript entry
|
|
78
81
|
"index.jsx",
|
|
82
|
+
// React JavaScript entry
|
|
79
83
|
"index.cjs",
|
|
80
|
-
|
|
81
|
-
"index.
|
|
84
|
+
// CommonJS entry
|
|
85
|
+
"index.mjs"
|
|
86
|
+
// ES Module entry
|
|
82
87
|
];
|
|
83
88
|
var RESOLVE_EXTENSIONS = [
|
|
84
89
|
".ts",
|
|
90
|
+
// TypeScript
|
|
85
91
|
".js",
|
|
92
|
+
// JavaScript
|
|
86
93
|
".tsx",
|
|
94
|
+
// React TypeScript
|
|
87
95
|
".jsx",
|
|
96
|
+
// React JavaScript
|
|
88
97
|
".json",
|
|
98
|
+
// JSON file
|
|
99
|
+
// Type declaration and transformed files
|
|
89
100
|
".d.js",
|
|
101
|
+
// JS file with type declarations (rare)
|
|
90
102
|
".d.ts",
|
|
103
|
+
// Type declaration file
|
|
104
|
+
// Various module systems
|
|
91
105
|
".mjs",
|
|
106
|
+
// ES Module
|
|
92
107
|
".cjs",
|
|
108
|
+
// CommonJS
|
|
109
|
+
// Module-related TypeScript extensions
|
|
93
110
|
".mts",
|
|
111
|
+
// ES Module TypeScript
|
|
94
112
|
".cts",
|
|
113
|
+
// CommonJS TypeScript
|
|
114
|
+
// Type declarations for module-related files
|
|
95
115
|
".d.mjs",
|
|
116
|
+
// Type declarations for ES Module
|
|
96
117
|
".d.cjs",
|
|
118
|
+
// Type declarations for CommonJS
|
|
97
119
|
".d.mts",
|
|
120
|
+
// Type declarations for ES Module TS
|
|
98
121
|
".d.cts"
|
|
122
|
+
// Type declarations for CommonJS TS
|
|
99
123
|
];
|
|
124
|
+
|
|
125
|
+
// src/rules/enforce-barrel-pattern.ts
|
|
100
126
|
var enforceBarrelPattern = {
|
|
101
127
|
meta: {
|
|
102
128
|
type: "problem",
|
|
@@ -229,23 +255,6 @@ var enforceBarrelPattern = {
|
|
|
229
255
|
import "@typescript-eslint/types";
|
|
230
256
|
import path3 from "path";
|
|
231
257
|
import resolve2 from "resolve";
|
|
232
|
-
var RESOLVE_EXTENSIONS2 = [
|
|
233
|
-
".ts",
|
|
234
|
-
".js",
|
|
235
|
-
".tsx",
|
|
236
|
-
".jsx",
|
|
237
|
-
".json",
|
|
238
|
-
".d.js",
|
|
239
|
-
".d.ts",
|
|
240
|
-
".mjs",
|
|
241
|
-
".cjs",
|
|
242
|
-
".mts",
|
|
243
|
-
".cts",
|
|
244
|
-
".d.mjs",
|
|
245
|
-
".d.cjs",
|
|
246
|
-
".d.mts",
|
|
247
|
-
".d.cts"
|
|
248
|
-
];
|
|
249
258
|
var isolateBarrelFile = {
|
|
250
259
|
meta: {
|
|
251
260
|
type: "problem",
|
|
@@ -298,6 +307,9 @@ var isolateBarrelFile = {
|
|
|
298
307
|
//check only import declaration(ESM)
|
|
299
308
|
ImportDeclaration(node) {
|
|
300
309
|
const rawImportPath = node.source.value;
|
|
310
|
+
if (rawImportPath.includes("/node_modules/")) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
301
313
|
const absoluteCurrentFilePath = context.getFilename();
|
|
302
314
|
let absoluteImportPath = null;
|
|
303
315
|
try {
|
|
@@ -307,13 +319,16 @@ var isolateBarrelFile = {
|
|
|
307
319
|
);
|
|
308
320
|
if (aliasResult.type === "success") {
|
|
309
321
|
absoluteImportPath = aliasResult.absolutePath;
|
|
322
|
+
if (absoluteImportPath.includes("/node_modules/")) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
310
325
|
} else {
|
|
311
|
-
if (!rawImportPath.startsWith(".") && !rawImportPath.startsWith("/")
|
|
326
|
+
if (!rawImportPath.startsWith(".") && !rawImportPath.startsWith("/")) {
|
|
312
327
|
return;
|
|
313
328
|
}
|
|
314
329
|
absoluteImportPath = resolve2.sync(rawImportPath, {
|
|
315
330
|
basedir: path3.dirname(absoluteCurrentFilePath),
|
|
316
|
-
extensions:
|
|
331
|
+
extensions: RESOLVE_EXTENSIONS
|
|
317
332
|
});
|
|
318
333
|
}
|
|
319
334
|
} catch (e) {
|
|
@@ -401,9 +416,8 @@ var rules = {
|
|
|
401
416
|
"enforce-barrel-pattern": enforceBarrelPattern,
|
|
402
417
|
"isolate-barrel-file": isolateBarrelFile,
|
|
403
418
|
"no-wildcard": noWildcard
|
|
419
|
+
// "no-cycle": noCycle,
|
|
404
420
|
};
|
|
405
|
-
var index_default = { rules };
|
|
406
|
-
module.exports = { rules };
|
|
407
421
|
export {
|
|
408
|
-
|
|
422
|
+
rules
|
|
409
423
|
};
|
package/package.json
CHANGED
|
@@ -25,32 +25,32 @@
|
|
|
25
25
|
"isolated barrel module",
|
|
26
26
|
"no-wildcard"
|
|
27
27
|
],
|
|
28
|
-
"version": "1.4.
|
|
28
|
+
"version": "1.4.2",
|
|
29
29
|
"type": "module",
|
|
30
30
|
"main": "dist/index.cjs",
|
|
31
31
|
"module": "dist/index.js",
|
|
32
32
|
"types": "dist/index.d.ts",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@types/jest": "^30.0.0",
|
|
35
|
-
"@typescript-eslint/parser": "^8.46.2",
|
|
36
|
-
"@typescript-eslint/rule-tester": "^8.46.2",
|
|
37
34
|
"@typescript-eslint/types": "^8.46.2",
|
|
38
35
|
"@typescript-eslint/utils": "^8.36.0",
|
|
39
36
|
"fast-glob": "^3.3.3",
|
|
40
|
-
"jest": "^30.2.0",
|
|
41
37
|
"resolve": "^1.22.10",
|
|
42
|
-
"ts-jest": "^29.4.5",
|
|
43
38
|
"tsconfig-paths": "^4.2.0"
|
|
44
39
|
},
|
|
45
40
|
"devDependencies": {
|
|
41
|
+
"jest": "^30.2.0",
|
|
46
42
|
"@types/node": "^24.0.13",
|
|
47
43
|
"@types/resolve": "^1.20.6",
|
|
48
44
|
"tsup": "^8.5.0",
|
|
49
|
-
"typescript": "~5.8.3"
|
|
45
|
+
"typescript": "~5.8.3",
|
|
46
|
+
"@types/jest": "^30.0.0",
|
|
47
|
+
"@typescript-eslint/parser": "^8.46.2",
|
|
48
|
+
"@typescript-eslint/rule-tester": "^8.46.2",
|
|
49
|
+
"ts-jest": "^29.4.5"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"lint": "eslint src/**/*.ts",
|
|
53
|
-
"build": "pnpm run test && tsup
|
|
53
|
+
"build": "pnpm run test && tsup",
|
|
54
54
|
"type-check": "tsc --noEmit",
|
|
55
55
|
"test": "jest",
|
|
56
56
|
"test:watch": "jest --watch",
|