@simplysm/lint 13.0.82 → 13.0.84
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 +164 -0
- package/package.json +2 -3
package/README.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# @simplysm/lint
|
|
2
|
+
|
|
3
|
+
Shared ESLint configuration and custom ESLint plugin for the Simplysm monorepo. Provides a recommended flat config with rules for TypeScript, SolidJS, Tailwind CSS, and import hygiene, plus three custom rules.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @simplysm/lint
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @simplysm/lint
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Peer Dependencies
|
|
14
|
+
|
|
15
|
+
This package depends on the following (installed as direct dependencies):
|
|
16
|
+
|
|
17
|
+
- `eslint` >= 9
|
|
18
|
+
- `typescript` >= 5
|
|
19
|
+
- `typescript-eslint` >= 8
|
|
20
|
+
|
|
21
|
+
## Exports
|
|
22
|
+
|
|
23
|
+
| Export path | Description |
|
|
24
|
+
|---|---|
|
|
25
|
+
| `@simplysm/lint/eslint-plugin` | Custom ESLint plugin object (`rules` map) |
|
|
26
|
+
| `@simplysm/lint/eslint-recommended` | Ready-to-use ESLint flat config array |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Recommended Config
|
|
31
|
+
|
|
32
|
+
**`@simplysm/lint/eslint-recommended`**
|
|
33
|
+
|
|
34
|
+
A complete ESLint flat config (compatible with ESLint v9 flat config format) that you can spread directly into your `eslint.config.ts`.
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
// eslint.config.ts
|
|
38
|
+
import recommended from "@simplysm/lint/eslint-recommended";
|
|
39
|
+
|
|
40
|
+
export default [
|
|
41
|
+
...recommended,
|
|
42
|
+
// your project-specific overrides
|
|
43
|
+
];
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### What it includes
|
|
47
|
+
|
|
48
|
+
#### Global ignores
|
|
49
|
+
|
|
50
|
+
Ignores `node_modules/`, `dist/`, dotfile directories (`.*`), and underscore-prefixed directories (`_*`).
|
|
51
|
+
|
|
52
|
+
#### JS / JSX files (`**/*.js`, `**/*.jsx`)
|
|
53
|
+
|
|
54
|
+
- **Common rules**: `no-console`, `eqeqeq` (strict equality, `== null` allowed), `no-self-compare`, `array-callback-return`, `no-warning-comments` (warn on TODO/FIXME).
|
|
55
|
+
- **Unused imports**: Auto-removes unused imports; allows `_`-prefixed unused variables.
|
|
56
|
+
- **Import hygiene**: `import/no-extraneous-dependencies` with dev-dependency exceptions for config files.
|
|
57
|
+
- **Custom rules**: `@simplysm/no-hard-private` (error), `@simplysm/no-subpath-imports-from-simplysm` (error).
|
|
58
|
+
- **Node built-in restrictions**: Prohibits `Buffer` (use `Uint8Array`), `events`/`eventemitter3` (use `@simplysm/core-common` EventEmitter).
|
|
59
|
+
|
|
60
|
+
#### TS / TSX files (`**/*.ts`, `**/*.tsx`)
|
|
61
|
+
|
|
62
|
+
Includes all JS rules above, plus:
|
|
63
|
+
|
|
64
|
+
- **TypeScript-specific rules** (via `typescript-eslint`):
|
|
65
|
+
- `require-await`, `await-thenable`, `return-await` (in try-catch), `no-floating-promises`
|
|
66
|
+
- `no-shadow`, `no-unnecessary-condition`, `no-unnecessary-type-assertion`
|
|
67
|
+
- `prefer-reduce-type-parameter`, `prefer-return-this-type`, `prefer-readonly`
|
|
68
|
+
- `strict-boolean-expressions` (nullable boolean/object allowed)
|
|
69
|
+
- `no-misused-promises` (void return arguments and attributes allowed)
|
|
70
|
+
- `only-throw-error`, `no-array-delete`, `no-unused-expressions`
|
|
71
|
+
- `ban-ts-comment` (`ts-expect-error` allowed with description >= 3 chars)
|
|
72
|
+
- **Custom rules**: All JS custom rules plus `@simplysm/ts-no-throw-not-implemented-error` (warn).
|
|
73
|
+
|
|
74
|
+
#### Test files (`**/tests/**`, `**/tests-e2e/**`)
|
|
75
|
+
|
|
76
|
+
Relaxes some rules for test code:
|
|
77
|
+
|
|
78
|
+
- `no-console`: off
|
|
79
|
+
- `import/no-extraneous-dependencies`: off
|
|
80
|
+
- `@simplysm/ts-no-throw-not-implemented-error`: off
|
|
81
|
+
|
|
82
|
+
#### SolidJS (`**/*.ts`, `**/*.tsx`)
|
|
83
|
+
|
|
84
|
+
- **eslint-plugin-solid** rules: `no-destructure`, `components-return-once`, `jsx-no-duplicate-props`, `jsx-no-undef`, `no-react-deps`, `no-react-specific-props`, `no-innerhtml`, `jsx-no-script-url`, `jsx-uses-vars`, `prefer-for`, `event-handlers`, `imports`, `style-prop`, `self-closing-comp`.
|
|
85
|
+
- **eslint-plugin-tailwindcss** rules: `classnames-order` (warn), `enforces-negative-arbitrary-values`, `enforces-shorthand`, `no-contradicting-classname`, `no-custom-classname`, `no-unnecessary-arbitrary-value`.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Custom Plugin
|
|
90
|
+
|
|
91
|
+
**`@simplysm/lint/eslint-plugin`**
|
|
92
|
+
|
|
93
|
+
An ESLint plugin object that exposes three custom rules under the `@simplysm` namespace.
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import plugin from "@simplysm/lint/eslint-plugin";
|
|
97
|
+
|
|
98
|
+
// plugin.rules contains:
|
|
99
|
+
// - "no-hard-private"
|
|
100
|
+
// - "no-subpath-imports-from-simplysm"
|
|
101
|
+
// - "ts-no-throw-not-implemented-error"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Rules
|
|
105
|
+
|
|
106
|
+
#### `@simplysm/no-hard-private`
|
|
107
|
+
|
|
108
|
+
Enforces TypeScript `private _` style instead of ECMAScript hard private fields (`#`).
|
|
109
|
+
|
|
110
|
+
- **Type**: problem
|
|
111
|
+
- **Fixable**: yes (auto-fix replaces `#field` with `private _field`)
|
|
112
|
+
- **Recommended severity**: error
|
|
113
|
+
|
|
114
|
+
Hard private fields (`#field`) are disallowed. The auto-fixer renames the field and adds the `private` keyword. Reports a conflict error if `_field` already exists on the class.
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
// Bad
|
|
118
|
+
class Foo {
|
|
119
|
+
#value = 1;
|
|
120
|
+
#compute() { return this.#value; }
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Good
|
|
124
|
+
class Foo {
|
|
125
|
+
private _value = 1;
|
|
126
|
+
private _compute() { return this._value; }
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
#### `@simplysm/no-subpath-imports-from-simplysm`
|
|
131
|
+
|
|
132
|
+
Prohibits `src` subpath imports from `@simplysm/*` packages.
|
|
133
|
+
|
|
134
|
+
- **Type**: problem
|
|
135
|
+
- **Fixable**: yes (auto-fix strips the `/src/...` segment)
|
|
136
|
+
- **Recommended severity**: error
|
|
137
|
+
|
|
138
|
+
Prevents importing internal source paths such as `@simplysm/pkg/src/foo`. Only the package root import (`@simplysm/pkg`) is allowed.
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
// Bad
|
|
142
|
+
import { Foo } from "@simplysm/core-common/src/utils/foo";
|
|
143
|
+
|
|
144
|
+
// Good
|
|
145
|
+
import { Foo } from "@simplysm/core-common";
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
#### `@simplysm/ts-no-throw-not-implemented-error`
|
|
149
|
+
|
|
150
|
+
Warns about usage of `NotImplementedError` from `@simplysm/core-common` to catch unfinished code before production.
|
|
151
|
+
|
|
152
|
+
- **Type**: suggestion
|
|
153
|
+
- **Fixable**: no
|
|
154
|
+
- **Recommended severity**: warn (off in test files)
|
|
155
|
+
|
|
156
|
+
Detects `new NotImplementedError()` calls regardless of import form (named, aliased, or namespace import). The warning message displays the error's string argument if provided.
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
// Triggers warning: "Not implemented"
|
|
160
|
+
throw new NotImplementedError();
|
|
161
|
+
|
|
162
|
+
// Triggers warning: "parseXml is not ready"
|
|
163
|
+
throw new NotImplementedError("parseXml is not ready");
|
|
164
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/lint",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.84",
|
|
4
4
|
"description": "Simplysm package - Lint configuration (ESLint)",
|
|
5
5
|
"author": "simplysm",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"dist",
|
|
15
15
|
"src",
|
|
16
|
-
"tests"
|
|
17
|
-
"docs"
|
|
16
|
+
"tests"
|
|
18
17
|
],
|
|
19
18
|
"sideEffects": false,
|
|
20
19
|
"exports": {
|