@simplysm/eslint-plugin 12.16.30 → 12.16.31

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.
Files changed (2) hide show
  1. package/README.md +260 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,260 @@
1
+ # @simplysm/eslint-plugin
2
+
3
+ ESLint plugin providing custom rules and a shared flat config for Simplysm monorepo projects.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @simplysm/eslint-plugin
9
+ # or
10
+ yarn add @simplysm/eslint-plugin
11
+ ```
12
+
13
+ ### Peer Dependencies
14
+
15
+ - `eslint` >= 9
16
+ - `typescript` ~5.8
17
+ - `typescript-eslint` >= 8
18
+ - `angular-eslint` >= 20 (for Angular template rules)
19
+
20
+ ## Usage
21
+
22
+ ### Using the Shared Config
23
+
24
+ The plugin exports a `root` flat config that includes all recommended rules along with
25
+ third-party plugin configurations (typescript-eslint, angular-eslint, eslint-plugin-import,
26
+ eslint-plugin-unused-imports).
27
+
28
+ ```js
29
+ // eslint.config.js
30
+ import simplysm from "@simplysm/eslint-plugin";
31
+
32
+ export default [
33
+ ...simplysm.configs.root,
34
+ ];
35
+ ```
36
+
37
+ The `root` config applies rules to three file groups:
38
+
39
+ | Files | Plugins Enabled |
40
+ |---|---|
41
+ | `**/*.js`, `**/*.jsx` | `@simplysm`, `import`, `unused-imports` |
42
+ | `**/*.ts`, `**/*.tsx` | `@simplysm`, `@typescript-eslint`, `@angular-eslint`, `import`, `unused-imports` |
43
+ | `**/*.html` | `@simplysm` (Angular template rules) |
44
+
45
+ ### Using Individual Rules
46
+
47
+ You can also use the plugin directly and enable specific rules:
48
+
49
+ ```js
50
+ // eslint.config.js
51
+ import simplysm from "@simplysm/eslint-plugin";
52
+
53
+ export default [
54
+ {
55
+ plugins: {
56
+ "@simplysm": simplysm,
57
+ },
58
+ rules: {
59
+ "@simplysm/no-hard-private": "error",
60
+ "@simplysm/no-subpath-imports-from-simplysm": "error",
61
+ },
62
+ },
63
+ ];
64
+ ```
65
+
66
+ ## Rules
67
+
68
+ ### General Rules
69
+
70
+ #### `no-hard-private`
71
+
72
+ Enforce TypeScript `private` keyword over ECMAScript `#` private fields.
73
+
74
+ - **Type:** problem
75
+ - **Fixable:** code
76
+ - **Recommended severity:** `error`
77
+
78
+ Disallows `#field` syntax and auto-fixes to `private _field`.
79
+
80
+ ```ts
81
+ // Bad
82
+ class Foo {
83
+ #count = 0;
84
+ #getValue() { return this.#count; }
85
+ }
86
+
87
+ // Good
88
+ class Foo {
89
+ private _count = 0;
90
+ private _getValue() { return this._count; }
91
+ }
92
+ ```
93
+
94
+ #### `no-subpath-imports-from-simplysm`
95
+
96
+ Disallow `src` subpath imports from `@simplysm/*` packages.
97
+
98
+ - **Type:** problem
99
+ - **Recommended severity:** `error`
100
+
101
+ ```ts
102
+ // Bad
103
+ import { something } from "@simplysm/sd-core-common/src/utils";
104
+
105
+ // Good
106
+ import { something } from "@simplysm/sd-core-common";
107
+ ```
108
+
109
+ ---
110
+
111
+ ### TypeScript Rules
112
+
113
+ These rules require type information (`parserOptions.project: true`).
114
+
115
+ #### `ts-no-throw-not-implement-error`
116
+
117
+ Warn when `NotImplementError` is thrown, serving as a reminder for unfinished implementations.
118
+
119
+ - **Type:** suggestion
120
+ - **Recommended severity:** `warn`
121
+
122
+ ```ts
123
+ // Triggers warning
124
+ throw new NotImplementError("feature X");
125
+ ```
126
+
127
+ #### `ts-no-exported-types`
128
+
129
+ Disallow specified types from being exposed in exported APIs or public class members, suggesting safer alternatives.
130
+
131
+ - **Type:** problem
132
+ - **Recommended severity:** `error`
133
+ - **Schema:** accepts a `types` array with `ban`, `safe`, and `ignoreInGeneric` options
134
+
135
+ Checks exported functions, public methods, public properties, and exported variables.
136
+
137
+ ```js
138
+ // eslint.config.js rule example
139
+ "@simplysm/ts-no-exported-types": ["error", {
140
+ types: [
141
+ { ban: "ArrayBuffer", safe: "Buffer", ignoreInGeneric: true },
142
+ { ban: "Uint8Array", safe: "Buffer" },
143
+ ],
144
+ }]
145
+ ```
146
+
147
+ #### `ts-no-buffer-in-typedarray-context`
148
+
149
+ Disallow `Buffer` being used directly where a TypedArray is expected. Covers assignments, return statements, function call arguments, object properties, array elements, and conditional expressions.
150
+
151
+ - **Type:** problem
152
+ - **Recommended severity:** `error`
153
+
154
+ ```ts
155
+ // Bad
156
+ const arr: Uint8Array = Buffer.from([1, 2, 3]);
157
+
158
+ // Good
159
+ const arr: Uint8Array = new Uint8Array(Buffer.from([1, 2, 3]));
160
+ ```
161
+
162
+ #### `ts-no-unused-injects`
163
+
164
+ Disallow unused Angular `inject()` fields. Auto-removes the unused field declaration.
165
+
166
+ - **Type:** problem
167
+ - **Fixable:** code
168
+ - **Recommended severity:** `error`
169
+
170
+ ```ts
171
+ // Bad - myService is never referenced
172
+ class MyComponent {
173
+ private readonly myService = inject(MyService);
174
+ }
175
+
176
+ // Good
177
+ class MyComponent {
178
+ private readonly myService = inject(MyService);
179
+
180
+ doWork() {
181
+ this.myService.execute();
182
+ }
183
+ }
184
+ ```
185
+
186
+ #### `ts-no-unused-protected-readonly`
187
+
188
+ Disallow unused `protected readonly` fields in Angular `@Component` classes. Checks both class body usage and inline template references.
189
+
190
+ - **Type:** problem
191
+ - **Fixable:** code
192
+ - **Recommended severity:** `error`
193
+
194
+ ```ts
195
+ // Bad - cdr is not used in class or template
196
+ @Component({ template: `<div>hello</div>` })
197
+ class MyComponent {
198
+ protected readonly cdr = inject(ChangeDetectorRef);
199
+ }
200
+ ```
201
+
202
+ ---
203
+
204
+ ### Angular Template Rules
205
+
206
+ These rules apply to `.html` files parsed with `angular-eslint/template-parser`.
207
+
208
+ #### `ng-template-no-todo-comments`
209
+
210
+ Warn on `TODO:` comments inside HTML templates.
211
+
212
+ - **Type:** problem
213
+ - **Recommended severity:** `warn`
214
+
215
+ ```html
216
+ <!-- Bad -->
217
+ <!-- TODO: replace with real content -->
218
+
219
+ <!-- Good (no TODO comments) -->
220
+ <!-- This section displays user info -->
221
+ ```
222
+
223
+ #### `ng-template-sd-require-binding-attrs`
224
+
225
+ Disallow non-whitelisted plain attributes on components with specified selector prefixes (default: `sd-*`). Requires using Angular property bindings instead.
226
+
227
+ - **Type:** problem
228
+ - **Fixable:** code
229
+ - **Recommended severity:** `error`
230
+ - **Schema:** accepts `selectorPrefixes`, `allowAttributes`, and `allowAttributePrefixes` options
231
+
232
+ Default allowed plain attributes: `id`, `class`, `style`, `title`, `tabindex`, `role`.
233
+ Default allowed attribute prefixes: `aria-`, `data-`, `sd-`.
234
+
235
+ ```html
236
+ <!-- Bad -->
237
+ <sd-button color="primary">Click</sd-button>
238
+
239
+ <!-- Good -->
240
+ <sd-button [color]="'primary'">Click</sd-button>
241
+ ```
242
+
243
+ ```js
244
+ // Custom options
245
+ "@simplysm/ng-template-sd-require-binding-attrs": ["error", {
246
+ selectorPrefixes: ["sd-", "app-"],
247
+ allowAttributes: ["id", "class", "style"],
248
+ allowAttributePrefixes: ["aria-", "data-"],
249
+ }]
250
+ ```
251
+
252
+ ## Configs
253
+
254
+ | Config | Description |
255
+ |---|---|
256
+ | `root` | Full flat config with all recommended rules, typescript-eslint, angular-eslint, import, and unused-imports plugins configured |
257
+
258
+ ## License
259
+
260
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/eslint-plugin",
3
- "version": "12.16.30",
3
+ "version": "12.16.31",
4
4
  "description": "심플리즘 패키지 - ESLINT 플러그인",
5
5
  "author": "김석래",
6
6
  "repository": {