eslint-plugin-barrel-rules 1.1.0 → 1.1.1

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 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.1.0-blue.svg" alt="Version"/>
6
+ <img src="https://img.shields.io/badge/version-1.1.1-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>
@@ -53,6 +53,22 @@ JavaScript/TypeScript 프로젝트에서 Barrel Pattern(배럴 패턴)을 강제
53
53
 
54
54
  ---
55
55
 
56
+ ## 규칙(Rules)
57
+
58
+ 1. **enforce-barrel-pattern**
59
+ 모듈 임포트 시 배럴 패턴(Barrel Pattern)을 강제합니다.
60
+ 지정한 배럴 파일을 통해서만 임포트가 가능하며, 내부 모듈에 직접 접근하는 것을 방지합니다.
61
+
62
+ - **옵션:**
63
+ - `paths`: 배럴 패턴으로 보호할 디렉토리 경로(`baseDir` 기준 상대경로)
64
+ - `baseDir` (선택): `paths` 해석 기준이 되는 디렉토리. 기본값은 ESLint 실행 위치입니다.
65
+
66
+ 2. **no-wildcard**
67
+ `import * as foo from "module"`, `export * from "./module"`과 같은 와일드카드(네임스페이스) import/export를 금지합니다.
68
+ 트리쉐이킹 및 코드 명확성을 위해 반드시 개별(named) import/export만 허용합니다.
69
+
70
+ ---
71
+
56
72
  ## 설치
57
73
 
58
74
  ```bash
@@ -86,6 +102,8 @@ module.exports = {
86
102
  baseDir: __dirname,
87
103
  },
88
104
  ],
105
+ // import * 또는 export * 금지
106
+ "barrel-rules/no-wildcard": ["error"],
89
107
  },
90
108
  };
91
109
  ```
@@ -133,6 +151,8 @@ export default tseslint.config([
133
151
  baseDir: __dirname,
134
152
  },
135
153
  ],
154
+ // import * 또는 export * 금지
155
+ "barrel-rules/no-wildcard": ["error"],
136
156
  },
137
157
  },
138
158
  ]);
@@ -154,12 +174,13 @@ import { Test } from "../domains/foo";
154
174
 
155
175
  ## 앞으로의 계획
156
176
 
157
- - 더 다양한 모듈 경계/추상화 관련 룰 추가 예정
158
- - Alias/tsconfig 지원: TypeScript의 paths, Vite의 resolve.alias, 기타 커스텀 경로 매핑을 완벽하게 지원
177
+ - 더 다양한 모듈 경계/추상화 관련 룰 추가 예정 (~Ing)
178
+ - Alias/tsconfig 지원: TypeScript의 paths, Vite의 resolve.alias, 기타 커스텀 경로 매핑을 완벽하게 지원 (~Ing)
159
179
  - **CJS 지원** (OK)
160
180
  - **ESLint 8 지원** (OK)
161
181
  - **번들 플러그인(플러그인 내 모든 기능 통합)** (OK)
162
182
  - **잘못된 경로 설정 검증 기능** (OK)
183
+ - **와일드카드 import/export 제한 규칙** (OK)
163
184
 
164
185
  ---
165
186
 
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.1.0-blue.svg" alt="Version"/>
6
+ <img src="https://img.shields.io/badge/version-1.1.1-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>
@@ -56,6 +56,22 @@ Direct imports from internal files are blocked, maximizing
56
56
 
57
57
  ---
58
58
 
59
+ ## Rules
60
+
61
+ 1. **enforce-barrel-pattern**
62
+ Enforces the barrel pattern for module imports.
63
+ Only allows imports from designated barrel files and prevents direct access to internal modules.
64
+
65
+ - **Options:**
66
+ - `paths`: The directories to be protected by the barrel pattern (relative to `baseDir`).
67
+ - `baseDir` (optional): The base directory for resolving `paths`. Defaults to the ESLint execution directory.
68
+
69
+ 2. **no-wildcard**
70
+ Disallows wildcard (namespace) imports such as `import * as foo from "module"`, `export * from "./module"`
71
+ Forces you to use named imports for better tree-shaking and code clarity.
72
+
73
+ ---
74
+
59
75
  ## Install
60
76
 
61
77
  ```bash
@@ -89,6 +105,8 @@ module.exports = {
89
105
  baseDir: __dirname,
90
106
  },
91
107
  ],
108
+ // Disallow wildcard (namespace) import/export.
109
+ "barrel-rules/no-wildcard": ["error"],
92
110
  },
93
111
  };
94
112
  ```
@@ -136,6 +154,8 @@ export default tseslint.config([
136
154
  baseDir: __dirname,
137
155
  },
138
156
  ],
157
+ // Disallow wildcard (namespace) import/export.
158
+ "barrel-rules/no-wildcard": ["error"],
139
159
  },
140
160
  },
141
161
  ]);
@@ -157,16 +177,17 @@ import { Test } from "../domains/foo";
157
177
 
158
178
  ## Future Work
159
179
 
160
- - More rules for module boundaries and abstraction
180
+ - More rules for module boundaries and abstraction (~Ing)
161
181
 
162
182
  - **Alias/tsconfig Support**
163
- Fully supports TypeScript `paths`, Vite `resolve.alias`, and other custom path mappings
183
+ Fully supports TypeScript `paths`, Vite `resolve.alias`, and other custom path mappings (~Ing)
164
184
 
165
185
  - **CJS Support** (OK)
166
186
  - **Eslint8 Support** (OK)
167
187
  - **Bundle Plugin(capsure any features in plugin)**
168
188
  (OK)
169
189
  - **Wrong Path Setup Validator** (OK)
190
+ - **Wildcard Import/Export Protection Rule** (OK)
170
191
 
171
192
  ---
172
193
 
package/dist/index.cjs CHANGED
@@ -133,9 +133,48 @@ var enforceBarrelPattern = {
133
133
  }
134
134
  };
135
135
 
136
+ // src/rules/no-wildcard.ts
137
+ var import_utils2 = require("@typescript-eslint/utils");
138
+ var noWildcard = {
139
+ meta: {
140
+ type: "problem",
141
+ docs: {
142
+ description: "Wildcard (namespace) import is not allowed."
143
+ },
144
+ schema: [],
145
+ messages: {
146
+ NoWildcardImport: "Wildcard import (`import * as ... from ...`) is not allowed. Please use named imports instead.",
147
+ NoExportAll: "Export all (`export * from ...`) is not allowed. Please use named exports instead."
148
+ }
149
+ },
150
+ defaultOptions: [],
151
+ create(context) {
152
+ return {
153
+ ImportDeclaration(node) {
154
+ const hasNamespaceImport = node.specifiers.some(
155
+ (specifier) => specifier.type === "ImportNamespaceSpecifier"
156
+ );
157
+ if (hasNamespaceImport) {
158
+ context.report({
159
+ node,
160
+ messageId: "NoWildcardImport"
161
+ });
162
+ }
163
+ },
164
+ ExportAllDeclaration(node) {
165
+ context.report({
166
+ node,
167
+ messageId: "NoExportAll"
168
+ });
169
+ }
170
+ };
171
+ }
172
+ };
173
+
136
174
  // src/index.ts
137
175
  var rules = {
138
- "enforce-barrel-pattern": enforceBarrelPattern
176
+ "enforce-barrel-pattern": enforceBarrelPattern,
177
+ "no-wildcard": noWildcard
139
178
  };
140
179
  var index_default = { rules };
141
180
  module.exports = { rules };
package/dist/index.d.cts CHANGED
@@ -6,6 +6,7 @@ declare const _default: {
6
6
  paths: string[];
7
7
  baseDir: string;
8
8
  }[], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
9
+ "no-wildcard": _typescript_eslint_utils_ts_eslint.RuleModule<"NoWildcardImport" | "NoExportAll", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
9
10
  };
10
11
  };
11
12
 
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ declare const _default: {
6
6
  paths: string[];
7
7
  baseDir: string;
8
8
  }[], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
9
+ "no-wildcard": _typescript_eslint_utils_ts_eslint.RuleModule<"NoWildcardImport" | "NoExportAll", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
9
10
  };
10
11
  };
11
12
 
package/dist/index.js CHANGED
@@ -97,9 +97,48 @@ var enforceBarrelPattern = {
97
97
  }
98
98
  };
99
99
 
100
+ // src/rules/no-wildcard.ts
101
+ import "@typescript-eslint/utils";
102
+ var noWildcard = {
103
+ meta: {
104
+ type: "problem",
105
+ docs: {
106
+ description: "Wildcard (namespace) import is not allowed."
107
+ },
108
+ schema: [],
109
+ messages: {
110
+ NoWildcardImport: "Wildcard import (`import * as ... from ...`) is not allowed. Please use named imports instead.",
111
+ NoExportAll: "Export all (`export * from ...`) is not allowed. Please use named exports instead."
112
+ }
113
+ },
114
+ defaultOptions: [],
115
+ create(context) {
116
+ return {
117
+ ImportDeclaration(node) {
118
+ const hasNamespaceImport = node.specifiers.some(
119
+ (specifier) => specifier.type === "ImportNamespaceSpecifier"
120
+ );
121
+ if (hasNamespaceImport) {
122
+ context.report({
123
+ node,
124
+ messageId: "NoWildcardImport"
125
+ });
126
+ }
127
+ },
128
+ ExportAllDeclaration(node) {
129
+ context.report({
130
+ node,
131
+ messageId: "NoExportAll"
132
+ });
133
+ }
134
+ };
135
+ }
136
+ };
137
+
100
138
  // src/index.ts
101
139
  var rules = {
102
- "enforce-barrel-pattern": enforceBarrelPattern
140
+ "enforce-barrel-pattern": enforceBarrelPattern,
141
+ "no-wildcard": noWildcard
103
142
  };
104
143
  var index_default = { rules };
105
144
  module.exports = { rules };
package/package.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "encapsulation directory",
24
24
  "enforce barrel pattern"
25
25
  ],
26
- "version": "1.1.0",
26
+ "version": "1.1.1",
27
27
  "type": "module",
28
28
  "main": "dist/index.cjs",
29
29
  "module": "dist/index.js",