@simplysm/lint 13.0.98 → 13.0.100
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 +32 -75
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @simplysm/lint
|
|
2
2
|
|
|
3
|
-
Lint configuration (ESLint)
|
|
3
|
+
Simplysm package - Lint configuration (ESLint). Provides an ESLint plugin with custom rules and a recommended flat config for TypeScript, SolidJS, and Tailwind CSS projects.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -8,75 +8,52 @@ Lint configuration (ESLint) -- ESLint plugin with custom rules and a recommended
|
|
|
8
8
|
npm install @simplysm/lint
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
## Entrypoints
|
|
12
|
+
|
|
11
13
|
This package has two entrypoints:
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
| Entrypoint | Import Path | Description |
|
|
16
|
+
|------------|-------------|-------------|
|
|
17
|
+
| ESLint Plugin | `@simplysm/lint/eslint-plugin` | Custom ESLint rules |
|
|
18
|
+
| Recommended Config | `@simplysm/lint/eslint-recommended` | Full recommended flat config |
|
|
15
19
|
|
|
16
20
|
## API Overview
|
|
17
21
|
|
|
18
22
|
### ESLint Plugin (`@simplysm/lint/eslint-plugin`)
|
|
19
23
|
|
|
20
|
-
|
|
21
|
-
|-----|------|-------------|
|
|
22
|
-
| `default` | ESLint plugin | Plugin object with `rules` property |
|
|
23
|
-
|
|
24
|
-
### Rules
|
|
25
|
-
|
|
26
|
-
| Rule | Type | Description |
|
|
27
|
-
|------|------|-------------|
|
|
28
|
-
| `no-hard-private` | problem (fixable) | Enforces TypeScript `private _` style instead of hard private fields (`#`) |
|
|
29
|
-
| `no-subpath-imports-from-simplysm` | problem (fixable) | Prohibits `src` subpath imports from `@simplysm/*` packages |
|
|
30
|
-
| `ts-no-throw-not-implemented-error` | suggestion | Warns about `NotImplementedError` usage from `@simplysm/core-common` |
|
|
31
|
-
|
|
32
|
-
### ESLint Recommended Config (`@simplysm/lint/eslint-recommended`)
|
|
33
|
-
|
|
34
|
-
| API | Type | Description |
|
|
35
|
-
|-----|------|-------------|
|
|
36
|
-
| `default` | flat config array | Complete ESLint flat config with JS/TS, SolidJS, and Tailwind CSS rules |
|
|
37
|
-
|
|
38
|
-
### Utils
|
|
39
|
-
|
|
40
|
-
| API | Type | Description |
|
|
41
|
-
|-----|------|-------------|
|
|
42
|
-
| `createRule` | function | Factory function to create ESLint rules (wraps `@typescript-eslint/utils` `RuleCreator`) |
|
|
43
|
-
|
|
44
|
-
## `createRule`
|
|
45
|
-
|
|
46
|
-
```typescript
|
|
47
|
-
const createRule: ReturnType<typeof ESLintUtils.RuleCreator>;
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Factory function wrapping `RuleCreator` from `@typescript-eslint/utils`. Automatically generates rule documentation URLs.
|
|
51
|
-
|
|
52
|
-
## Rule Details
|
|
53
|
-
|
|
54
|
-
### `no-hard-private`
|
|
24
|
+
Default export is an ESLint plugin object with `rules`:
|
|
55
25
|
|
|
56
|
-
|
|
26
|
+
| Rule | Type | Fixable | Description |
|
|
27
|
+
|------|------|---------|-------------|
|
|
28
|
+
| `no-hard-private` | problem | Yes | Enforces TypeScript `private _` style instead of hard private fields (`#`). Auto-fixes `#field` to `private _field` and `this.#field` to `this._field`. |
|
|
29
|
+
| `no-subpath-imports-from-simplysm` | problem | Yes | Prohibits `src` subpath imports from `@simplysm/*` packages (e.g., `@simplysm/pkg/src/x` is prohibited). Auto-fixes to package root import. |
|
|
30
|
+
| `ts-no-throw-not-implemented-error` | suggestion | No | Warns about `NotImplementedError` usage from `@simplysm/core-common`. Detects named, aliased, and namespace imports. |
|
|
57
31
|
|
|
58
|
-
###
|
|
32
|
+
### Recommended Config (`@simplysm/lint/eslint-recommended`)
|
|
59
33
|
|
|
60
|
-
|
|
34
|
+
Default export is a full ESLint flat config array that includes:
|
|
61
35
|
|
|
62
|
-
|
|
36
|
+
- **Global ignores**: `node_modules`, `dist`, dotfiles, underscore-prefixed directories
|
|
37
|
+
- **JS/JSX rules**: Common rules + unused imports + import dependency checks + custom `@simplysm` rules
|
|
38
|
+
- **TS/TSX rules**: TypeScript-specific rules (strict boolean expressions, no floating promises, prefer readonly, etc.) + all JS rules
|
|
39
|
+
- **Test overrides**: Relaxed rules for `tests/` and `tests-e2e/` directories (allows console, no extraneous deps check)
|
|
40
|
+
- **SolidJS rules**: No destructure, components-return-once, no-innerhtml, prefer-for, etc.
|
|
41
|
+
- **Tailwind CSS rules**: Classnames order, enforces shorthand, no contradicting classname, no custom classname
|
|
63
42
|
|
|
64
|
-
|
|
43
|
+
#### Included Plugins
|
|
65
44
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
- **SolidJS rules**: `no-destructure`, `components-return-once`, `prefer-for`, `no-react-specific-props`
|
|
75
|
-
- **Tailwind CSS rules**: `classnames-order`, `no-contradicting-classname`, `enforces-shorthand`
|
|
45
|
+
| Plugin | Prefix | Purpose |
|
|
46
|
+
|--------|--------|---------|
|
|
47
|
+
| `@typescript-eslint` | `@typescript-eslint/` | TypeScript type-aware linting |
|
|
48
|
+
| `@simplysm` (this package) | `@simplysm/` | Custom Simplysm rules |
|
|
49
|
+
| `eslint-plugin-import` | `import/` | Import/export validation |
|
|
50
|
+
| `eslint-plugin-unused-imports` | `unused-imports/` | Auto-remove unused imports |
|
|
51
|
+
| `eslint-plugin-solid` | `solid/` | SolidJS best practices |
|
|
52
|
+
| `eslint-plugin-tailwindcss` | `tailwindcss/` | Tailwind CSS class validation |
|
|
76
53
|
|
|
77
54
|
## Usage Examples
|
|
78
55
|
|
|
79
|
-
### Use recommended config
|
|
56
|
+
### Use the recommended config
|
|
80
57
|
|
|
81
58
|
```typescript
|
|
82
59
|
// eslint.config.ts
|
|
@@ -85,7 +62,7 @@ import recommended from "@simplysm/lint/eslint-recommended";
|
|
|
85
62
|
export default recommended;
|
|
86
63
|
```
|
|
87
64
|
|
|
88
|
-
### Use plugin rules
|
|
65
|
+
### Use the plugin with custom rules
|
|
89
66
|
|
|
90
67
|
```typescript
|
|
91
68
|
// eslint.config.ts
|
|
@@ -102,23 +79,3 @@ export default [
|
|
|
102
79
|
},
|
|
103
80
|
];
|
|
104
81
|
```
|
|
105
|
-
|
|
106
|
-
### Create a custom rule with `createRule`
|
|
107
|
-
|
|
108
|
-
```typescript
|
|
109
|
-
import { createRule } from "@simplysm/lint/eslint-plugin";
|
|
110
|
-
|
|
111
|
-
export default createRule({
|
|
112
|
-
name: "my-custom-rule",
|
|
113
|
-
meta: {
|
|
114
|
-
type: "problem",
|
|
115
|
-
docs: { description: "My custom rule" },
|
|
116
|
-
schema: [],
|
|
117
|
-
messages: { myMessage: "Something is wrong" },
|
|
118
|
-
},
|
|
119
|
-
defaultOptions: [],
|
|
120
|
-
create(context) {
|
|
121
|
-
return {};
|
|
122
|
-
},
|
|
123
|
-
});
|
|
124
|
-
```
|