@simplysm/eslint-plugin 12.16.31 → 12.16.35
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.md +98 -192
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,260 +1,166 @@
|
|
|
1
1
|
# @simplysm/eslint-plugin
|
|
2
2
|
|
|
3
|
-
ESLint plugin
|
|
3
|
+
ESLint plugin with custom rules and a shared flat config for Simplysm monorepo projects. Provides a ready-to-use `root` config and 9 custom rules covering TypeScript best practices, Angular template conventions, and Simplysm-specific import restrictions.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install @simplysm/eslint-plugin
|
|
9
|
-
# or
|
|
10
|
-
yarn add @simplysm/eslint-plugin
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
## API Overview
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
- `typescript` ~5.8
|
|
17
|
-
- `typescript-eslint` >= 8
|
|
18
|
-
- `angular-eslint` >= 20 (for Angular template rules)
|
|
13
|
+
### Plugin Export
|
|
19
14
|
|
|
20
|
-
|
|
15
|
+
| API | Type | Description |
|
|
16
|
+
|-----|------|-------------|
|
|
17
|
+
| `default` | Plugin object | Default export with `configs.root` and 9 custom rules |
|
|
21
18
|
|
|
22
|
-
###
|
|
19
|
+
### Custom Rules
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
| Rule | Type | Description |
|
|
22
|
+
|------|------|-------------|
|
|
23
|
+
| `ts-no-throw-not-implement-error` | suggestion | Warns on `NotImplementError` usage |
|
|
24
|
+
| `ts-no-exported-types` | problem | Forbids specified types from being exposed in export APIs or public class members |
|
|
25
|
+
| `ts-no-buffer-in-typedarray-context` | problem | Forbids using `Buffer` where a TypedArray is expected |
|
|
26
|
+
| `ng-template-no-todo-comments` | problem | Warns on TODO comments in Angular HTML templates |
|
|
27
|
+
| `no-subpath-imports-from-simplysm` | problem | Forbids subpath imports from `@simplysm` packages (e.g., `@simplysm/pkg/src/x`) |
|
|
28
|
+
| `ng-template-sd-require-binding-attrs` | problem | Requires binding syntax for attributes on `sd-` prefixed components |
|
|
29
|
+
| `no-hard-private` | problem | Enforces TypeScript `private _` style over ECMAScript `#` private fields (auto-fixable) |
|
|
30
|
+
| `ts-no-unused-injects` | problem | Disallows unused Angular `inject()` fields (auto-fixable) |
|
|
31
|
+
| `ts-no-unused-protected-readonly` | problem | Disallows unused `protected readonly` fields in Angular components (auto-fixable) |
|
|
27
32
|
|
|
28
|
-
|
|
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
|
|
33
|
+
## API Reference
|
|
46
34
|
|
|
47
|
-
|
|
35
|
+
### Default Export
|
|
48
36
|
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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; }
|
|
37
|
+
```typescript
|
|
38
|
+
export default {
|
|
39
|
+
configs: {
|
|
40
|
+
root: FlatConfig[]
|
|
41
|
+
}
|
|
91
42
|
}
|
|
92
43
|
```
|
|
93
44
|
|
|
94
|
-
|
|
45
|
+
The plugin object contains:
|
|
46
|
+
- `configs.root` -- A flat ESLint config array that sets up all recommended rules for Simplysm projects
|
|
95
47
|
|
|
96
|
-
|
|
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
|
-
```
|
|
48
|
+
### `configs.root`
|
|
108
49
|
|
|
109
|
-
|
|
50
|
+
A complete flat ESLint configuration array that includes:
|
|
110
51
|
|
|
111
|
-
|
|
52
|
+
- **Global ignores**: `node_modules/`, `dist/`, `tests/`, `.*`, `_*`
|
|
53
|
+
- **Language globals**: Node.js, ES2021, and browser globals
|
|
54
|
+
- **JS/JSX rules**: `eqeqeq`, `no-console` (warn), `no-shadow`, `require-await`, unused imports enforcement, import dependency checks, and Simplysm rules (`no-subpath-imports-from-simplysm`, `no-hard-private`)
|
|
55
|
+
- **TS/TSX rules**: All JS rules plus TypeScript-specific rules (`strict-boolean-expressions`, `no-floating-promises`, `return-await`, `prefer-readonly`, `typedef`, `no-unnecessary-condition`, etc.), Angular ESLint inline template processing, and additional Simplysm rules (`ts-no-throw-not-implement-error`, `ts-no-unused-injects`, `ts-no-unused-protected-readonly`)
|
|
56
|
+
- **HTML rules**: Angular template parser with `ng-template-no-todo-comments` and `ng-template-sd-require-binding-attrs`
|
|
112
57
|
|
|
113
|
-
|
|
58
|
+
### `ts-no-throw-not-implement-error`
|
|
114
59
|
|
|
115
|
-
|
|
60
|
+
Warns when `NotImplementError` is thrown, flagging unfinished implementations.
|
|
116
61
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
- **Type:** suggestion
|
|
120
|
-
- **Recommended severity:** `warn`
|
|
121
|
-
|
|
122
|
-
```ts
|
|
123
|
-
// Triggers warning
|
|
124
|
-
throw new NotImplementError("feature X");
|
|
62
|
+
```javascript
|
|
63
|
+
"@simplysm/ts-no-throw-not-implement-error": ["warn"]
|
|
125
64
|
```
|
|
126
65
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
Disallow specified types from being exposed in exported APIs or public class members, suggesting safer alternatives.
|
|
66
|
+
### `ts-no-exported-types`
|
|
130
67
|
|
|
131
|
-
|
|
132
|
-
- **Recommended severity:** `error`
|
|
133
|
-
- **Schema:** accepts a `types` array with `ban`, `safe`, and `ignoreInGeneric` options
|
|
68
|
+
Forbids specified types from appearing in exported APIs or public class members, suggesting safer alternatives.
|
|
134
69
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
```js
|
|
138
|
-
// eslint.config.js rule example
|
|
70
|
+
```javascript
|
|
139
71
|
"@simplysm/ts-no-exported-types": ["error", {
|
|
140
72
|
types: [
|
|
141
73
|
{ ban: "ArrayBuffer", safe: "Buffer", ignoreInGeneric: true },
|
|
142
74
|
{ ban: "Uint8Array", safe: "Buffer" },
|
|
143
|
-
]
|
|
75
|
+
]
|
|
144
76
|
}]
|
|
145
77
|
```
|
|
146
78
|
|
|
147
|
-
|
|
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.
|
|
79
|
+
### `ts-no-buffer-in-typedarray-context`
|
|
150
80
|
|
|
151
|
-
|
|
152
|
-
- **Recommended severity:** `error`
|
|
81
|
+
Prevents using `Buffer` in contexts where a standard TypedArray (e.g., `Uint8Array`) is expected.
|
|
153
82
|
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
const arr: Uint8Array = Buffer.from([1, 2, 3]);
|
|
157
|
-
|
|
158
|
-
// Good
|
|
159
|
-
const arr: Uint8Array = new Uint8Array(Buffer.from([1, 2, 3]));
|
|
83
|
+
```javascript
|
|
84
|
+
"@simplysm/ts-no-buffer-in-typedarray-context": ["error"]
|
|
160
85
|
```
|
|
161
86
|
|
|
162
|
-
|
|
87
|
+
### `ng-template-no-todo-comments`
|
|
163
88
|
|
|
164
|
-
|
|
89
|
+
Warns on TODO/FIXME comments found in Angular HTML templates.
|
|
165
90
|
|
|
166
|
-
|
|
167
|
-
-
|
|
168
|
-
|
|
91
|
+
```javascript
|
|
92
|
+
"@simplysm/ng-template-no-todo-comments": ["warn"]
|
|
93
|
+
```
|
|
169
94
|
|
|
170
|
-
|
|
171
|
-
// Bad - myService is never referenced
|
|
172
|
-
class MyComponent {
|
|
173
|
-
private readonly myService = inject(MyService);
|
|
174
|
-
}
|
|
95
|
+
### `no-subpath-imports-from-simplysm`
|
|
175
96
|
|
|
176
|
-
|
|
177
|
-
class MyComponent {
|
|
178
|
-
private readonly myService = inject(MyService);
|
|
97
|
+
Forbids deep subpath imports from `@simplysm` packages. Only the package entry point is allowed.
|
|
179
98
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
}
|
|
99
|
+
```javascript
|
|
100
|
+
"@simplysm/no-subpath-imports-from-simplysm": ["error"]
|
|
184
101
|
```
|
|
185
102
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
Disallow unused `protected readonly` fields in Angular `@Component` classes. Checks both class body usage and inline template references.
|
|
103
|
+
### `ng-template-sd-require-binding-attrs`
|
|
189
104
|
|
|
190
|
-
|
|
191
|
-
- **Fixable:** code
|
|
192
|
-
- **Recommended severity:** `error`
|
|
105
|
+
Requires binding syntax (`[attr]`, `(event)`, etc.) for attributes on components with `sd-` prefix selectors. Plain HTML attributes like `id`, `class`, `style`, `title`, `tabindex`, `role`, and attributes with `aria-`, `data-`, `sd-` prefixes are allowed.
|
|
193
106
|
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
@Component({ template: `<div>hello</div>` })
|
|
197
|
-
class MyComponent {
|
|
198
|
-
protected readonly cdr = inject(ChangeDetectorRef);
|
|
199
|
-
}
|
|
107
|
+
```javascript
|
|
108
|
+
"@simplysm/ng-template-sd-require-binding-attrs": ["error"]
|
|
200
109
|
```
|
|
201
110
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
### Angular Template Rules
|
|
205
|
-
|
|
206
|
-
These rules apply to `.html` files parsed with `angular-eslint/template-parser`.
|
|
111
|
+
### `no-hard-private`
|
|
207
112
|
|
|
208
|
-
|
|
113
|
+
Enforces TypeScript `private _` convention over ECMAScript `#` private fields. Auto-fixable.
|
|
209
114
|
|
|
210
|
-
|
|
115
|
+
```javascript
|
|
116
|
+
"@simplysm/no-hard-private": ["error"]
|
|
117
|
+
```
|
|
211
118
|
|
|
212
|
-
-
|
|
213
|
-
- **Recommended severity:** `warn`
|
|
119
|
+
### `ts-no-unused-injects`
|
|
214
120
|
|
|
215
|
-
|
|
216
|
-
<!-- Bad -->
|
|
217
|
-
<!-- TODO: replace with real content -->
|
|
121
|
+
Disallows unused Angular `inject()` fields. Auto-fixable -- removes the unused field.
|
|
218
122
|
|
|
219
|
-
|
|
220
|
-
|
|
123
|
+
```javascript
|
|
124
|
+
"@simplysm/ts-no-unused-injects": ["error"]
|
|
221
125
|
```
|
|
222
126
|
|
|
223
|
-
|
|
127
|
+
### `ts-no-unused-protected-readonly`
|
|
224
128
|
|
|
225
|
-
|
|
129
|
+
Disallows unused `protected readonly` fields in Angular components. A field is considered "used" if it appears in the class body or the component's template. Auto-fixable.
|
|
226
130
|
|
|
227
|
-
|
|
228
|
-
-
|
|
229
|
-
|
|
230
|
-
- **Schema:** accepts `selectorPrefixes`, `allowAttributes`, and `allowAttributePrefixes` options
|
|
131
|
+
```javascript
|
|
132
|
+
"@simplysm/ts-no-unused-protected-readonly": ["error"]
|
|
133
|
+
```
|
|
231
134
|
|
|
232
|
-
|
|
233
|
-
Default allowed attribute prefixes: `aria-`, `data-`, `sd-`.
|
|
135
|
+
## Usage Examples
|
|
234
136
|
|
|
235
|
-
|
|
236
|
-
<!-- Bad -->
|
|
237
|
-
<sd-button color="primary">Click</sd-button>
|
|
137
|
+
### Using the root config (recommended)
|
|
238
138
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
139
|
+
```javascript
|
|
140
|
+
// eslint.config.js
|
|
141
|
+
import simplysm from "@simplysm/eslint-plugin";
|
|
242
142
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
selectorPrefixes: ["sd-", "app-"],
|
|
247
|
-
allowAttributes: ["id", "class", "style"],
|
|
248
|
-
allowAttributePrefixes: ["aria-", "data-"],
|
|
249
|
-
}]
|
|
143
|
+
export default [
|
|
144
|
+
...simplysm.configs.root,
|
|
145
|
+
];
|
|
250
146
|
```
|
|
251
147
|
|
|
252
|
-
|
|
148
|
+
### Using individual rules
|
|
253
149
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
## License
|
|
150
|
+
```javascript
|
|
151
|
+
// eslint.config.js
|
|
152
|
+
import simplysm from "@simplysm/eslint-plugin";
|
|
259
153
|
|
|
260
|
-
|
|
154
|
+
export default [
|
|
155
|
+
{
|
|
156
|
+
plugins: {
|
|
157
|
+
"@simplysm": simplysm,
|
|
158
|
+
},
|
|
159
|
+
rules: {
|
|
160
|
+
"@simplysm/no-hard-private": ["error"],
|
|
161
|
+
"@simplysm/no-subpath-imports-from-simplysm": ["error"],
|
|
162
|
+
"@simplysm/ts-no-unused-injects": ["error"],
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
];
|
|
166
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/eslint-plugin",
|
|
3
|
-
"version": "12.16.
|
|
3
|
+
"version": "12.16.35",
|
|
4
4
|
"description": "심플리즘 패키지 - ESLINT 플러그인",
|
|
5
5
|
"author": "김석래",
|
|
6
6
|
"repository": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@angular-eslint/utils": "^20.7.0",
|
|
16
16
|
"@eslint/compat": "^2.0.3",
|
|
17
|
-
"@typescript-eslint/utils": "^8.57.
|
|
17
|
+
"@typescript-eslint/utils": "^8.57.1",
|
|
18
18
|
"angular-eslint": "^20.7.0",
|
|
19
19
|
"eslint": "^9.39.4",
|
|
20
20
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"eslint-plugin-unused-imports": "^4.4.1",
|
|
23
23
|
"globals": "^16.5.0",
|
|
24
24
|
"typescript": "~5.8.3",
|
|
25
|
-
"typescript-eslint": "^8.57.
|
|
25
|
+
"typescript-eslint": "^8.57.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@typescript-eslint/rule-tester": "^8.57.
|
|
28
|
+
"@typescript-eslint/rule-tester": "^8.57.1"
|
|
29
29
|
}
|
|
30
30
|
}
|