@simplysm/lint 14.0.18 → 14.0.20
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 +61 -31
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,56 +8,79 @@ Shared ESLint plugin and recommended configuration for Simplysm projects.
|
|
|
8
8
|
npm install @simplysm/lint
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## API Overview
|
|
12
12
|
|
|
13
13
|
### `@simplysm/lint/eslint-plugin`
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
| API | Type | Description |
|
|
16
|
+
|-----|------|-------------|
|
|
17
|
+
| `default` | object | ESLint plugin object (`{ rules: { ... } }`) containing 7 custom rules for Angular/TypeScript projects |
|
|
16
18
|
|
|
17
19
|
```typescript
|
|
18
20
|
import plugin from "@simplysm/lint/eslint-plugin";
|
|
19
21
|
```
|
|
20
22
|
|
|
21
|
-
Default export: `{ rules: { ... } }`
|
|
22
|
-
|
|
23
23
|
#### Rules
|
|
24
24
|
|
|
25
25
|
| Rule | Type | Fixable | Description |
|
|
26
26
|
|---|---|---|---|
|
|
27
|
-
| `ng-template-no-todo-comments` | problem | no | Warn on TODO comments inside Angular HTML templates |
|
|
28
|
-
| `ng-template-sd-require-binding-attrs` | problem | yes | Disallow non-whitelisted plain attributes on `sd-*` prefixed components; require Angular property bindings instead |
|
|
29
|
-
| `no-hard-private` | problem | yes | Disallow ES hard private fields (`#field`);
|
|
30
|
-
| `no-subpath-imports-from-simplysm` | problem | yes | Disallow importing from `@simplysm/*/src/*` subpaths
|
|
31
|
-
| `ts-no-throw-not-implemented-error` | suggestion | no | Warn on `NotImplementedError`
|
|
32
|
-
| `ts-no-unused-injects` | problem | yes | Disallow unused Angular `inject()` fields |
|
|
33
|
-
| `ts-no-unused-protected-readonly` | problem | yes | Disallow unused `protected readonly` fields in
|
|
27
|
+
| `ng-template-no-todo-comments` | problem | no | Warn on `<!-- TODO: ... -->` comments inside Angular HTML templates |
|
|
28
|
+
| `ng-template-sd-require-binding-attrs` | problem | yes | Disallow non-whitelisted plain attributes on `sd-*` prefixed components; require Angular property bindings (`[attr]="..."`) instead |
|
|
29
|
+
| `no-hard-private` | problem | yes | Disallow ES hard private fields (`#field`); autofix to TypeScript `private _field` style. Reports name conflicts when `_field` already exists |
|
|
30
|
+
| `no-subpath-imports-from-simplysm` | problem | yes | Disallow importing from `@simplysm/*/src/*` subpaths; autofix to package entrypoint (`@simplysm/pkg`). Covers static imports, dynamic imports, and re-exports |
|
|
31
|
+
| `ts-no-throw-not-implemented-error` | suggestion | no | Warn on `new NotImplementedError()` from `@simplysm/core-common` (named, aliased, and namespace imports). Displays the error message argument or "unimplemented" |
|
|
32
|
+
| `ts-no-unused-injects` | problem | yes | Disallow unused Angular `inject()` fields; autofix removes the entire field declaration |
|
|
33
|
+
| `ts-no-unused-protected-readonly` | problem | yes | Disallow unused `protected readonly` fields in `@Component` classes; checks both class body and inline template references |
|
|
34
|
+
|
|
35
|
+
#### `ng-template-sd-require-binding-attrs` Options
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
interface RuleOptions {
|
|
39
|
+
selectorPrefixes?: string[]; // default: ["sd-"]
|
|
40
|
+
allowAttributes?: string[]; // default: ["id", "class", "style", "title", "tabindex", "role"]
|
|
41
|
+
allowAttributePrefixes?: string[]; // default: ["aria-", "data-", "sd-"]
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
| Field | Type | Description |
|
|
46
|
+
|-------|------|-------------|
|
|
47
|
+
| `selectorPrefixes` | `string[]` | Tag name prefixes that trigger the rule (case-insensitive matching) |
|
|
48
|
+
| `allowAttributes` | `string[]` | Exact attribute names allowed as plain attributes (case-insensitive) |
|
|
49
|
+
| `allowAttributePrefixes` | `string[]` | Attribute name prefixes allowed as plain attributes (case-insensitive) |
|
|
34
50
|
|
|
35
51
|
### `@simplysm/lint/eslint-recommended`
|
|
36
52
|
|
|
37
|
-
|
|
53
|
+
| API | Type | Description |
|
|
54
|
+
|-----|------|-------------|
|
|
55
|
+
| `default` | `FlatConfig.ConfigArray` | Complete ESLint flat config array from `tseslint.config()` |
|
|
38
56
|
|
|
39
57
|
```typescript
|
|
40
58
|
import recommended from "@simplysm/lint/eslint-recommended";
|
|
41
59
|
```
|
|
42
60
|
|
|
43
|
-
Default export: a complete ESLint flat config array (from `tseslint.config()`).
|
|
44
|
-
|
|
45
61
|
#### Included Configurations
|
|
46
62
|
|
|
47
63
|
- `angular-eslint` template recommended + accessibility
|
|
48
|
-
- `typescript-eslint` recommended rules
|
|
49
|
-
- `eslint-plugin-import` (extraneous dependency checking)
|
|
50
|
-
- `eslint-plugin-unused-imports` (auto-remove unused imports)
|
|
64
|
+
- `typescript-eslint` parser and recommended rules
|
|
65
|
+
- `eslint-plugin-import` (extraneous dependency checking with `eslint-import-resolver-typescript`)
|
|
66
|
+
- `eslint-plugin-unused-imports` (auto-remove unused imports, unused vars with `_` prefix ignored)
|
|
51
67
|
- All 7 `@simplysm/lint/eslint-plugin` rules
|
|
52
68
|
|
|
53
69
|
#### Key Rules Enabled
|
|
54
70
|
|
|
55
71
|
- `eqeqeq` (always, null-ignore)
|
|
56
|
-
- `no-console` (error in
|
|
72
|
+
- `no-console` (error in `.ts` files)
|
|
73
|
+
- `no-warning-comments` (warn)
|
|
57
74
|
- `@typescript-eslint/require-await`, `await-thenable`, `no-floating-promises`
|
|
58
75
|
- `@typescript-eslint/strict-boolean-expressions` (nullable boolean/object allowed)
|
|
59
76
|
- `@typescript-eslint/prefer-readonly`
|
|
60
|
-
- `@typescript-eslint/no-unnecessary-condition`
|
|
77
|
+
- `@typescript-eslint/no-unnecessary-condition` (constant loop conditions allowed)
|
|
78
|
+
- `@typescript-eslint/no-unnecessary-type-assertion`
|
|
79
|
+
- `@typescript-eslint/only-throw-error`
|
|
80
|
+
- `@typescript-eslint/no-array-delete`
|
|
81
|
+
- `@typescript-eslint/no-misused-promises` (void return arguments allowed)
|
|
82
|
+
- `@typescript-eslint/ban-ts-comment` (ts-expect-error with description >= 3 chars)
|
|
83
|
+
- `@typescript-eslint/return-await` (in-try-catch)
|
|
61
84
|
- Bans `Buffer`, `events`, `eventemitter3` imports
|
|
62
85
|
- Test files (`**/tests/**/*.ts`): relaxes `no-console`, `import/no-extraneous-dependencies`, `ts-no-throw-not-implemented-error`
|
|
63
86
|
|
|
@@ -65,10 +88,10 @@ Default export: a complete ESLint flat config array (from `tseslint.config()`).
|
|
|
65
88
|
|
|
66
89
|
| Pattern | Applied Rules |
|
|
67
90
|
|---|---|
|
|
68
|
-
| `**/*.js`, `**/*.mjs`, `**/*.cjs` | Common rules + import checks + unused imports + no-hard-private + no-subpath-imports |
|
|
69
|
-
| `**/*.ts` | Full TypeScript rules + Angular
|
|
70
|
-
| `**/*.html` | Angular template
|
|
71
|
-
| `**/tests/**/*.ts` | Relaxed rules (no-console off, extraneous deps off) |
|
|
91
|
+
| `**/*.js`, `**/*.mjs`, `**/*.cjs` | Common rules + `require-await` + import checks + unused imports + `no-hard-private` + `no-subpath-imports` + Node builtins ban |
|
|
92
|
+
| `**/*.ts` | Full TypeScript rules + Angular inline template processing + all custom rules |
|
|
93
|
+
| `**/*.html` | Angular template recommended + accessibility + `ng-template-no-todo-comments` + `ng-template-sd-require-binding-attrs` |
|
|
94
|
+
| `**/tests/**/*.ts` | Relaxed rules (`no-console` off, extraneous deps off, `ts-no-throw-not-implemented-error` off) |
|
|
72
95
|
|
|
73
96
|
#### Ignored Patterns
|
|
74
97
|
|
|
@@ -77,11 +100,23 @@ Default export: a complete ESLint flat config array (from `tseslint.config()`).
|
|
|
77
100
|
- `**/.*/**`
|
|
78
101
|
- `**/_*/**`
|
|
79
102
|
|
|
80
|
-
|
|
103
|
+
### Internal Utility: `createRule`
|
|
81
104
|
|
|
82
|
-
|
|
105
|
+
Factory function wrapping `@typescript-eslint/utils` `RuleCreator` with auto-generated documentation URLs. Used internally by all rule implementations; **not publicly exported** via package entrypoints.
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
export const createRule = ESLintUtils.RuleCreator(
|
|
109
|
+
(name) =>
|
|
110
|
+
`https://github.com/kslhunter/simplysm/blob/master/packages/eslint-plugin/README.md#${name}`,
|
|
111
|
+
);
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Usage Examples
|
|
115
|
+
|
|
116
|
+
### Use the recommended config
|
|
83
117
|
|
|
84
118
|
```javascript
|
|
119
|
+
// eslint.config.js
|
|
85
120
|
import recommended from "@simplysm/lint/eslint-recommended";
|
|
86
121
|
|
|
87
122
|
export default [
|
|
@@ -93,6 +128,7 @@ export default [
|
|
|
93
128
|
### Use plugin rules individually
|
|
94
129
|
|
|
95
130
|
```javascript
|
|
131
|
+
// eslint.config.js
|
|
96
132
|
import plugin from "@simplysm/lint/eslint-plugin";
|
|
97
133
|
|
|
98
134
|
export default [
|
|
@@ -119,9 +155,3 @@ export default [
|
|
|
119
155
|
},
|
|
120
156
|
}
|
|
121
157
|
```
|
|
122
|
-
|
|
123
|
-
## Internal Utility
|
|
124
|
-
|
|
125
|
-
### `createRule`
|
|
126
|
-
|
|
127
|
-
Factory function for creating ESLint rules. Wraps `@typescript-eslint/utils` `RuleCreator` with auto-generated documentation URLs. This utility is used internally by all rule implementations but is **not publicly exported** via package entrypoints.
|