@simplysm/lint 13.0.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.md +522 -0
- package/dist/eslint-plugin.d.ts +15 -0
- package/dist/eslint-plugin.d.ts.map +1 -0
- package/dist/eslint-plugin.js +14 -0
- package/dist/eslint-plugin.js.map +6 -0
- package/dist/eslint-recommended.d.ts +3 -0
- package/dist/eslint-recommended.d.ts.map +1 -0
- package/dist/eslint-recommended.js +259 -0
- package/dist/eslint-recommended.js.map +6 -0
- package/dist/rules/no-hard-private.d.ts +15 -0
- package/dist/rules/no-hard-private.d.ts.map +1 -0
- package/dist/rules/no-hard-private.js +95 -0
- package/dist/rules/no-hard-private.js.map +6 -0
- package/dist/rules/no-subpath-imports-from-simplysm.d.ts +14 -0
- package/dist/rules/no-subpath-imports-from-simplysm.d.ts.map +1 -0
- package/dist/rules/no-subpath-imports-from-simplysm.js +64 -0
- package/dist/rules/no-subpath-imports-from-simplysm.js.map +6 -0
- package/dist/rules/ts-no-throw-not-implemented-error.d.ts +19 -0
- package/dist/rules/ts-no-throw-not-implemented-error.d.ts.map +1 -0
- package/dist/rules/ts-no-throw-not-implemented-error.js +63 -0
- package/dist/rules/ts-no-throw-not-implemented-error.js.map +6 -0
- package/dist/stylelint-recommended.d.ts +13 -0
- package/dist/stylelint-recommended.d.ts.map +1 -0
- package/dist/stylelint-recommended.js +20 -0
- package/dist/stylelint-recommended.js.map +6 -0
- package/dist/utils/create-rule.d.ts +22 -0
- package/dist/utils/create-rule.d.ts.map +1 -0
- package/dist/utils/create-rule.js +8 -0
- package/dist/utils/create-rule.js.map +6 -0
- package/package.json +52 -0
- package/src/eslint-plugin.ts +11 -0
- package/src/eslint-recommended.ts +274 -0
- package/src/rules/no-hard-private.ts +136 -0
- package/src/rules/no-subpath-imports-from-simplysm.ts +78 -0
- package/src/rules/ts-no-throw-not-implemented-error.ts +103 -0
- package/src/stylelint-recommended.ts +16 -0
- package/src/utils/create-rule.ts +22 -0
package/README.md
ADDED
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
# @simplysm/lint
|
|
2
|
+
|
|
3
|
+
Lint configurations for the Simplysm framework. Provides ESLint plugin with custom rules and Stylelint configuration for comprehensive code quality enforcement.
|
|
4
|
+
|
|
5
|
+
- **ESLint**: Custom rules, TypeScript, SolidJS, and Tailwind CSS support (Flat Config format)
|
|
6
|
+
- **Stylelint**: CSS linting with Chrome 84+ compatibility checks, Tailwind CSS support, and file resolution validation
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @simplysm/lint
|
|
12
|
+
# or
|
|
13
|
+
pnpm add @simplysm/lint
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Required Peer Dependencies
|
|
17
|
+
|
|
18
|
+
This plugin depends on the following packages:
|
|
19
|
+
|
|
20
|
+
| Package | Description |
|
|
21
|
+
|---------|-------------|
|
|
22
|
+
| `eslint` | ESLint core |
|
|
23
|
+
| `typescript` | TypeScript compiler |
|
|
24
|
+
| `typescript-eslint` | TypeScript ESLint parser and plugin |
|
|
25
|
+
| `eslint-plugin-import` | Rules for import/export |
|
|
26
|
+
| `eslint-plugin-unused-imports` | Auto-remove unused imports |
|
|
27
|
+
| `eslint-plugin-solid` | SolidJS-specific rules |
|
|
28
|
+
| `eslint-plugin-tailwindcss` | Tailwind CSS-specific rules |
|
|
29
|
+
| `globals` | Global variable definitions |
|
|
30
|
+
| `stylelint` | Stylelint core |
|
|
31
|
+
| `stylelint-config-standard` | Standard Stylelint rules |
|
|
32
|
+
| `stylelint-config-tailwindcss` | Tailwind CSS-specific Stylelint rules |
|
|
33
|
+
| `stylelint-no-unsupported-browser-features` | Browser compatibility checker |
|
|
34
|
+
| `stylelint-no-unresolved-module` | Import/url() file existence checker |
|
|
35
|
+
|
|
36
|
+
## Configuration
|
|
37
|
+
|
|
38
|
+
### ESLint Flat Config (eslint.config.js or eslint.config.ts)
|
|
39
|
+
|
|
40
|
+
#### Using recommended config (recommended)
|
|
41
|
+
|
|
42
|
+
The `recommended` config is a comprehensive setup that includes custom rules, TypeScript rules, SolidJS rules, and Tailwind CSS rules. This is sufficient for most cases.
|
|
43
|
+
|
|
44
|
+
```javascript
|
|
45
|
+
import simplysm from "@simplysm/lint/eslint-plugin";
|
|
46
|
+
|
|
47
|
+
export default [
|
|
48
|
+
// Use recommended config
|
|
49
|
+
simplysm.configs.recommended,
|
|
50
|
+
];
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### Using only specific rules
|
|
54
|
+
|
|
55
|
+
To selectively apply only certain custom rules:
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
import simplysm from "@simplysm/lint/eslint-plugin";
|
|
59
|
+
|
|
60
|
+
export default [
|
|
61
|
+
{
|
|
62
|
+
plugins: {
|
|
63
|
+
"@simplysm": simplysm,
|
|
64
|
+
},
|
|
65
|
+
rules: {
|
|
66
|
+
"@simplysm/no-hard-private": "error",
|
|
67
|
+
"@simplysm/no-subpath-imports-from-simplysm": "error",
|
|
68
|
+
"@simplysm/ts-no-throw-not-implemented-error": "warn",
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
### Stylelint Config (.stylelintrc.json)
|
|
77
|
+
|
|
78
|
+
#### Using recommended config (recommended)
|
|
79
|
+
|
|
80
|
+
Create a `.stylelintrc.json` file at the project root:
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"extends": ["@simplysm/lint/stylelint-recommended"]
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Or use the full configuration directly:
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"extends": ["stylelint-config-standard", "stylelint-config-tailwindcss"],
|
|
93
|
+
"plugins": ["stylelint-no-unsupported-browser-features", "stylelint-no-unresolved-module"],
|
|
94
|
+
"rules": {
|
|
95
|
+
"plugin/no-unsupported-browser-features": [
|
|
96
|
+
true,
|
|
97
|
+
{
|
|
98
|
+
"severity": "error",
|
|
99
|
+
"browsers": ["chrome >= 84"]
|
|
100
|
+
}
|
|
101
|
+
],
|
|
102
|
+
"plugin/no-unresolved-module": true
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### Overrides for specific files
|
|
108
|
+
|
|
109
|
+
Add overrides to disable rules for specific files:
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"extends": ["@simplysm/lint/stylelint-recommended"],
|
|
114
|
+
"overrides": [
|
|
115
|
+
{
|
|
116
|
+
"files": ["**/tailwind.css"],
|
|
117
|
+
"rules": {
|
|
118
|
+
"plugin/no-unsupported-browser-features": null
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Stylelint Rules
|
|
128
|
+
|
|
129
|
+
The `stylelint-recommended` config includes:
|
|
130
|
+
|
|
131
|
+
| Rule | Severity | Description |
|
|
132
|
+
|------|----------|-------------|
|
|
133
|
+
| `plugin/no-unsupported-browser-features` | error | Checks CSS features compatibility with Chrome 84+ |
|
|
134
|
+
| `plugin/no-unresolved-module` | error | Validates that `@import` and `url()` references exist |
|
|
135
|
+
| All rules from `stylelint-config-standard` | varies | Standard CSS linting rules |
|
|
136
|
+
| All rules from `stylelint-config-tailwindcss` | varies | Tailwind CSS-specific rules (`@apply`, `@layer`, etc.) |
|
|
137
|
+
|
|
138
|
+
### Browser Compatibility
|
|
139
|
+
|
|
140
|
+
The config enforces Chrome 84+ compatibility by default. This aligns with Simplysm's target browser support.
|
|
141
|
+
|
|
142
|
+
Unsupported features will trigger errors:
|
|
143
|
+
- CSS nesting (Chrome 112+)
|
|
144
|
+
- `@layer` directive (Chrome 99+)
|
|
145
|
+
- `aspect-ratio` property (Chrome 88+)
|
|
146
|
+
- `:is()`, `:where()` selectors (Chrome 88+)
|
|
147
|
+
|
|
148
|
+
Use overrides to disable checks for files using modern features intentionally (e.g., Tailwind's built-in nesting).
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Custom Rules
|
|
153
|
+
|
|
154
|
+
This plugin provides 3 custom rules.
|
|
155
|
+
|
|
156
|
+
| Rule | Type | Auto-fix | Default Severity | Description |
|
|
157
|
+
|------|------|----------|------------------|-------------|
|
|
158
|
+
| [`no-hard-private`](#no-hard-private) | problem | Supported | error | Enforces TypeScript `private` instead of ECMAScript `#field` |
|
|
159
|
+
| [`no-subpath-imports-from-simplysm`](#no-subpath-imports-from-simplysm) | problem | Supported | error | Prohibits importing from `@simplysm/*/src/` paths |
|
|
160
|
+
| [`ts-no-throw-not-implemented-error`](#ts-no-throw-not-implemented-error) | suggestion | Not supported | warn | Warns about usage of `NotImplementedError` |
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
### no-hard-private
|
|
165
|
+
|
|
166
|
+
Restricts the use of ECMAScript private fields (`#field`). Use TypeScript's `private` keyword and `_` prefix naming instead.
|
|
167
|
+
|
|
168
|
+
Supports auto-fix with the `--fix` option.
|
|
169
|
+
|
|
170
|
+
**Detection targets:**
|
|
171
|
+
|
|
172
|
+
- Class field declarations: `#field`
|
|
173
|
+
- Class method declarations: `#method()`
|
|
174
|
+
- Class accessor declarations: `accessor #field`
|
|
175
|
+
- Member access expressions: `this.#field`
|
|
176
|
+
|
|
177
|
+
**Valid code:**
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
class Foo {
|
|
181
|
+
private _value = 1;
|
|
182
|
+
private _count: number;
|
|
183
|
+
|
|
184
|
+
private _doSomething() {
|
|
185
|
+
return this._value;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**Invalid code:**
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
class Foo {
|
|
194
|
+
#value = 1;
|
|
195
|
+
#count: number;
|
|
196
|
+
|
|
197
|
+
#doSomething() {
|
|
198
|
+
return this.#value;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**Auto-fix with decorators:**
|
|
204
|
+
|
|
205
|
+
Members with decorators are also correctly converted. The `private` keyword is inserted after decorators and before other keywords like `static`.
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
// Before fix
|
|
209
|
+
class Foo {
|
|
210
|
+
@Deco
|
|
211
|
+
static #value = 1;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// After fix
|
|
215
|
+
class Foo {
|
|
216
|
+
@Deco
|
|
217
|
+
private static _value = 1;
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**Limitations:**
|
|
222
|
+
|
|
223
|
+
- If a member with the same name prefixed with `_` already exists, a name conflict occurs. In this case, auto-fix is not applied, and a `nameConflict` message requests manual adjustment.
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
class Foo {
|
|
227
|
+
private _value = 1;
|
|
228
|
+
#value = 2; // Error: Cannot convert "#value" to "_value" (name conflict)
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
### no-subpath-imports-from-simplysm
|
|
235
|
+
|
|
236
|
+
Prohibits importing from `@simplysm/*` packages through `/src/` paths. Only import through the official entry point (package root).
|
|
237
|
+
|
|
238
|
+
Supports auto-fix with the `--fix` option to convert to package root paths.
|
|
239
|
+
|
|
240
|
+
**Detection targets:**
|
|
241
|
+
|
|
242
|
+
- Static import statements: `import ... from '...'`
|
|
243
|
+
- Dynamic imports: `import('...')`
|
|
244
|
+
- Re-export statements: `export { ... } from '...'`
|
|
245
|
+
- Re-export all statements: `export * from '...'`
|
|
246
|
+
|
|
247
|
+
**Valid code:**
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
import { Foo } from "@simplysm/core-common";
|
|
251
|
+
import { Bar } from "@simplysm/core-node";
|
|
252
|
+
|
|
253
|
+
const mod = await import("@simplysm/core-common");
|
|
254
|
+
|
|
255
|
+
export { Baz } from "@simplysm/orm-common";
|
|
256
|
+
export * from "@simplysm/service-common";
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**Invalid code:**
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
import { Foo } from "@simplysm/core-common/src/types/DateOnly";
|
|
263
|
+
import { Bar } from "@simplysm/core-node/src/utils";
|
|
264
|
+
|
|
265
|
+
const mod = await import("@simplysm/core-common/src/index");
|
|
266
|
+
|
|
267
|
+
export { Baz } from "@simplysm/orm-common/src/query-builder";
|
|
268
|
+
export * from "@simplysm/service-common/src/protocols";
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
**Allowed subpaths:**
|
|
272
|
+
|
|
273
|
+
Subpaths other than `/src/` are allowed.
|
|
274
|
+
|
|
275
|
+
```typescript
|
|
276
|
+
// Allowed: not a /src/ path
|
|
277
|
+
import { Foo } from "@simplysm/core-common/utils";
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
### ts-no-throw-not-implemented-error
|
|
283
|
+
|
|
284
|
+
Warns about code that creates `NotImplementedError` from `@simplysm/core-common` with the `new` keyword. This rule prevents unimplemented code from being included in production.
|
|
285
|
+
|
|
286
|
+
It warns even if only creating without throwing. Auto-fix is not supported.
|
|
287
|
+
|
|
288
|
+
**Supported import forms:**
|
|
289
|
+
|
|
290
|
+
| Import Form | Detected |
|
|
291
|
+
|-------------|----------|
|
|
292
|
+
| named import: `import { NotImplementedError } from "@simplysm/core-common"` | Yes |
|
|
293
|
+
| aliased import: `import { NotImplementedError as NIE } from "@simplysm/core-common"` | Yes |
|
|
294
|
+
| namespace import: `import * as CC from "@simplysm/core-common"` | Yes |
|
|
295
|
+
| dynamic import: `await import("@simplysm/core-common")` | No |
|
|
296
|
+
| Re-exported from another module | No |
|
|
297
|
+
|
|
298
|
+
**Invalid code (warnings):**
|
|
299
|
+
|
|
300
|
+
```typescript
|
|
301
|
+
import { NotImplementedError } from "@simplysm/core-common";
|
|
302
|
+
|
|
303
|
+
throw new NotImplementedError(); // Warning: "미구현" (default message)
|
|
304
|
+
throw new NotImplementedError("Feature X"); // Warning: "Feature X"
|
|
305
|
+
const err = new NotImplementedError(); // Warning: "미구현" (default message)
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
**Aliased imports are also detected:**
|
|
309
|
+
|
|
310
|
+
```typescript
|
|
311
|
+
import { NotImplementedError as NIE } from "@simplysm/core-common";
|
|
312
|
+
|
|
313
|
+
throw new NIE(); // Warning
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
**Namespace imports are also detected:**
|
|
317
|
+
|
|
318
|
+
```typescript
|
|
319
|
+
import * as CC from "@simplysm/core-common";
|
|
320
|
+
|
|
321
|
+
throw new CC.NotImplementedError(); // Warning
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**Message display rules:**
|
|
325
|
+
|
|
326
|
+
- Calling `new NotImplementedError()` without arguments outputs a warning with the Korean default message "미구현".
|
|
327
|
+
- If a string argument is passed, that string is used as the warning message.
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## recommended Config Details
|
|
332
|
+
|
|
333
|
+
Full list of rules included in the `recommended` config.
|
|
334
|
+
|
|
335
|
+
### Global Ignore Patterns
|
|
336
|
+
|
|
337
|
+
The following directories are excluded from linting:
|
|
338
|
+
|
|
339
|
+
- `**/node_modules/**`
|
|
340
|
+
- `**/dist/**`
|
|
341
|
+
- `**/.*/**`
|
|
342
|
+
- `**/_*/**`
|
|
343
|
+
|
|
344
|
+
### Common Rules (JS/TS)
|
|
345
|
+
|
|
346
|
+
Rules applied to all JS and TS files.
|
|
347
|
+
|
|
348
|
+
| Rule | Severity | Description |
|
|
349
|
+
|------|----------|-------------|
|
|
350
|
+
| `no-console` | error | Prohibit console usage (prevent production performance degradation) |
|
|
351
|
+
| `no-warning-comments` | warn | Warn about TODO/FIXME comments (to identify incomplete code) |
|
|
352
|
+
| `eqeqeq` | error | Enforce `===`, allow `== null` check |
|
|
353
|
+
| `no-self-compare` | error | Prohibit self-comparison like `x === x` (prevent typos) |
|
|
354
|
+
| `array-callback-return` | error | Prevent missing `return` in array callbacks like `map`/`filter` |
|
|
355
|
+
|
|
356
|
+
### Node.js Built-in Module Restrictions
|
|
357
|
+
|
|
358
|
+
Restrict Node.js-specific API usage for code consistency across all packages.
|
|
359
|
+
|
|
360
|
+
| Restricted Target | Rule | Alternative |
|
|
361
|
+
|-------------------|------|-------------|
|
|
362
|
+
| `Buffer` (global) | `no-restricted-globals` | `Uint8Array`, `BytesUtils` from `@simplysm/core-common` |
|
|
363
|
+
| `buffer` (import) | `no-restricted-imports` | `Uint8Array`, `BytesUtils` from `@simplysm/core-common` |
|
|
364
|
+
| `events` (import) | `no-restricted-imports` | `SdEventEmitter` from `@simplysm/core-common` |
|
|
365
|
+
| `eventemitter3` (import) | `no-restricted-imports` | `SdEventEmitter` from `@simplysm/core-common` |
|
|
366
|
+
|
|
367
|
+
### Unused Imports Rules
|
|
368
|
+
|
|
369
|
+
| Rule | Severity | Description |
|
|
370
|
+
|------|----------|-------------|
|
|
371
|
+
| `unused-imports/no-unused-imports` | error | Auto-remove unused imports |
|
|
372
|
+
| `unused-imports/no-unused-vars` | error | Detect unused variables (allow `_` prefix variables/arguments) |
|
|
373
|
+
|
|
374
|
+
### Import Dependency Check
|
|
375
|
+
|
|
376
|
+
| Rule | Severity | Description |
|
|
377
|
+
|------|----------|-------------|
|
|
378
|
+
| `import/no-extraneous-dependencies` | error | Prohibit importing external dependencies not declared in `package.json` |
|
|
379
|
+
|
|
380
|
+
`devDependencies` are only allowed in the following paths:
|
|
381
|
+
|
|
382
|
+
- JS files: `**/lib/**`, `**/eslint.config.js`, `**/simplysm.js`, `**/vitest.config.js`
|
|
383
|
+
- TS files: `**/lib/**`, `**/eslint.config.ts`, `**/simplysm.ts`, `**/vitest.config.ts`, `**/vitest.setup.ts`
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
### JS-only Rules (.js, .jsx)
|
|
388
|
+
|
|
389
|
+
Rules applied only to JS files. Not applied to TS files as the TypeScript compiler performs the same checks.
|
|
390
|
+
|
|
391
|
+
| Rule | Severity | Description |
|
|
392
|
+
|------|----------|-------------|
|
|
393
|
+
| `require-await` | error | Require `await` in `async` functions |
|
|
394
|
+
| `no-shadow` | error | Prohibit variable shadowing |
|
|
395
|
+
| `no-duplicate-imports` | error | Prohibit duplicate imports |
|
|
396
|
+
| `no-unused-expressions` | error | Prohibit unused expressions |
|
|
397
|
+
| `no-undef` | error | Prohibit using undefined variables |
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
### TypeScript Rules (.ts, .tsx)
|
|
402
|
+
|
|
403
|
+
Rules applied based on `@typescript-eslint`. Performs precise checks using type information.
|
|
404
|
+
|
|
405
|
+
#### Async-related
|
|
406
|
+
|
|
407
|
+
| Rule | Severity | Description |
|
|
408
|
+
|------|----------|-------------|
|
|
409
|
+
| `@typescript-eslint/require-await` | error | Require `await` in `async` functions |
|
|
410
|
+
| `@typescript-eslint/await-thenable` | error | Only allow `await` on thenable objects |
|
|
411
|
+
| `@typescript-eslint/return-await` | error | Allow `return await` only inside `try-catch` |
|
|
412
|
+
| `@typescript-eslint/no-floating-promises` | error | Prohibit unhandled Promises |
|
|
413
|
+
| `@typescript-eslint/no-misused-promises` | error | Prevent error loss when passing async functions to void callbacks (excludes `arguments`, `attributes`) |
|
|
414
|
+
|
|
415
|
+
#### Type Safety
|
|
416
|
+
|
|
417
|
+
| Rule | Severity | Description |
|
|
418
|
+
|------|----------|-------------|
|
|
419
|
+
| `@typescript-eslint/strict-boolean-expressions` | error | Enforce strict boolean expressions (allow nullable boolean/object) |
|
|
420
|
+
| `@typescript-eslint/no-unnecessary-condition` | error | Prohibit unnecessary condition checks (allow constant loop conditions) |
|
|
421
|
+
| `@typescript-eslint/no-unnecessary-type-assertion` | error | Prohibit unnecessary type assertions |
|
|
422
|
+
| `@typescript-eslint/only-throw-error` | error | Prohibit throwing non-Error objects (preserve stack trace) |
|
|
423
|
+
|
|
424
|
+
#### Code Style
|
|
425
|
+
|
|
426
|
+
| Rule | Severity | Description |
|
|
427
|
+
|------|----------|-------------|
|
|
428
|
+
| `@typescript-eslint/no-shadow` | error | Prohibit variable shadowing |
|
|
429
|
+
| `@typescript-eslint/prefer-reduce-type-parameter` | error | Recommend using `reduce` type parameter |
|
|
430
|
+
| `@typescript-eslint/prefer-return-this-type` | error | Recommend using `this` return type |
|
|
431
|
+
| `@typescript-eslint/no-unused-expressions` | error | Prohibit unused expressions |
|
|
432
|
+
| `@typescript-eslint/prefer-readonly` | error | Recommend `readonly` for members that don't change |
|
|
433
|
+
| `@typescript-eslint/no-array-delete` | error | Prohibit using `delete` on arrays (prevent sparse array bugs) |
|
|
434
|
+
|
|
435
|
+
#### ts-comment Rules
|
|
436
|
+
|
|
437
|
+
| Rule | Severity | Description |
|
|
438
|
+
|------|----------|-------------|
|
|
439
|
+
| `@typescript-eslint/ban-ts-comment` | error | Require 3+ character description for `@ts-expect-error` |
|
|
440
|
+
|
|
441
|
+
---
|
|
442
|
+
|
|
443
|
+
### SolidJS Rules (.ts, .tsx)
|
|
444
|
+
|
|
445
|
+
Rules applied based on `eslint-plugin-solid`. Applied to both `.ts` and `.tsx` files.
|
|
446
|
+
|
|
447
|
+
#### Mistake Prevention
|
|
448
|
+
|
|
449
|
+
| Rule | Severity | Description |
|
|
450
|
+
|------|----------|-------------|
|
|
451
|
+
| `solid/reactivity` | error | Detect reactivity loss (registers custom reactive functions like `makePersisted`) |
|
|
452
|
+
| `solid/no-destructure` | error | Prohibit destructuring props (prevent reactivity loss) |
|
|
453
|
+
| `solid/components-return-once` | error | Prohibit early returns in components |
|
|
454
|
+
| `solid/jsx-no-duplicate-props` | error | Prohibit duplicate props |
|
|
455
|
+
| `solid/jsx-no-undef` | error | Prohibit using undefined JSX variables (TypeScript support enabled) |
|
|
456
|
+
| `solid/no-react-deps` | error | Prohibit React-style dependency arrays |
|
|
457
|
+
| `solid/no-react-specific-props` | error | Prohibit React-specific props (`className`, etc.) |
|
|
458
|
+
|
|
459
|
+
#### Security
|
|
460
|
+
|
|
461
|
+
| Rule | Severity | Description |
|
|
462
|
+
|------|----------|-------------|
|
|
463
|
+
| `solid/no-innerhtml` | error | Prohibit `innerHTML` usage (prevent XSS) |
|
|
464
|
+
| `solid/jsx-no-script-url` | error | Prohibit `javascript:` URLs |
|
|
465
|
+
|
|
466
|
+
#### Tooling Support
|
|
467
|
+
|
|
468
|
+
| Rule | Severity | Description |
|
|
469
|
+
|------|----------|-------------|
|
|
470
|
+
| `solid/jsx-uses-vars` | error | Prevent variables used in JSX from being flagged as unused imports |
|
|
471
|
+
|
|
472
|
+
#### Conventions
|
|
473
|
+
|
|
474
|
+
| Rule | Severity | Description |
|
|
475
|
+
|------|----------|-------------|
|
|
476
|
+
| `solid/prefer-for` | error | Recommend using `For` component |
|
|
477
|
+
| `solid/event-handlers` | error | Enforce event handler naming rules |
|
|
478
|
+
| `solid/imports` | error | Enforce import consistency |
|
|
479
|
+
| `solid/style-prop` | error | Enforce `style` prop format |
|
|
480
|
+
| `solid/self-closing-comp` | error | Enforce self-closing tags |
|
|
481
|
+
|
|
482
|
+
---
|
|
483
|
+
|
|
484
|
+
### Tailwind CSS Rules (.ts, .tsx)
|
|
485
|
+
|
|
486
|
+
Rules applied based on `eslint-plugin-tailwindcss`. Recognizes `clsx` template literal tags.
|
|
487
|
+
|
|
488
|
+
| Rule | Severity | Description |
|
|
489
|
+
|------|----------|-------------|
|
|
490
|
+
| `tailwindcss/classnames-order` | warn | Auto-sort class order |
|
|
491
|
+
| `tailwindcss/enforces-negative-arbitrary-values` | error | Unify negative arbitrary value format |
|
|
492
|
+
| `tailwindcss/enforces-shorthand` | error | Recommend using shorthand |
|
|
493
|
+
| `tailwindcss/no-contradicting-classname` | error | Prohibit conflicting classes (`p-2 p-4`, etc.) |
|
|
494
|
+
| `tailwindcss/no-custom-classname` | error | Prohibit custom classes not defined in Tailwind |
|
|
495
|
+
| `tailwindcss/no-unnecessary-arbitrary-value` | error | Prohibit unnecessary arbitrary values |
|
|
496
|
+
|
|
497
|
+
---
|
|
498
|
+
|
|
499
|
+
### Test File Exception Rules
|
|
500
|
+
|
|
501
|
+
The following rules are relaxed for test files in `**/tests/**/*.ts`, `**/tests/**/*.tsx` paths:
|
|
502
|
+
|
|
503
|
+
| Rule | Change | Reason |
|
|
504
|
+
|------|--------|--------|
|
|
505
|
+
| `no-console` | off | Allow debug output in tests |
|
|
506
|
+
| `import/no-extraneous-dependencies` | off | Allow using root `devDependencies` (vitest, etc.) |
|
|
507
|
+
| `@simplysm/ts-no-throw-not-implemented-error` | off | Allow using not-implemented errors in test code |
|
|
508
|
+
| `solid/reactivity` | off | Accessing signals inside async callbacks like `waitFor` in tests is intentional |
|
|
509
|
+
|
|
510
|
+
---
|
|
511
|
+
|
|
512
|
+
## Configuration Summary by File Type
|
|
513
|
+
|
|
514
|
+
| File Pattern | Applied Rules |
|
|
515
|
+
|--------------|---------------|
|
|
516
|
+
| `.js`, `.jsx` | Common rules + JS-only rules + `@simplysm` custom rules + import/unused-imports rules |
|
|
517
|
+
| `.ts`, `.tsx` | Common rules + `@typescript-eslint` rules + `@simplysm` custom rules + SolidJS rules + Tailwind CSS rules + import/unused-imports rules |
|
|
518
|
+
| `**/tests/**` | Above rules with some relaxed |
|
|
519
|
+
|
|
520
|
+
## License
|
|
521
|
+
|
|
522
|
+
Apache-2.0
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
rules: {
|
|
3
|
+
"no-hard-private": import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferSoftPrivate" | "nameConflict", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
"no-subpath-imports-from-simplysm": import("@typescript-eslint/utils/ts-eslint").RuleModule<"noSubpathImport", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
9
|
+
"ts-no-throw-not-implemented-error": import("@typescript-eslint/utils/ts-eslint").RuleModule<"noThrowNotImplementedError", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
|
15
|
+
//# sourceMappingURL=eslint-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eslint-plugin.d.ts","sourceRoot":"","sources":["../src/eslint-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAIA,wBAME"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import noHardPrivate from "./rules/no-hard-private.js";
|
|
2
|
+
import noSubpathImportsFromSimplysm from "./rules/no-subpath-imports-from-simplysm.js";
|
|
3
|
+
import tsNoThrowNotImplementedError from "./rules/ts-no-throw-not-implemented-error.js";
|
|
4
|
+
var eslint_plugin_default = {
|
|
5
|
+
rules: {
|
|
6
|
+
"no-hard-private": noHardPrivate,
|
|
7
|
+
"no-subpath-imports-from-simplysm": noSubpathImportsFromSimplysm,
|
|
8
|
+
"ts-no-throw-not-implemented-error": tsNoThrowNotImplementedError
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
eslint_plugin_default as default
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=eslint-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eslint-recommended.d.ts","sourceRoot":"","sources":["../src/eslint-recommended.ts"],"names":[],"mappings":";AAkFA,wBA+LG"}
|