@simplysm/lint 13.0.97 → 13.0.98

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.
Files changed (2) hide show
  1. package/README.md +124 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,124 @@
1
+ # @simplysm/lint
2
+
3
+ Lint configuration (ESLint) -- ESLint plugin with custom rules and a recommended flat config for Simplysm projects.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @simplysm/lint
9
+ ```
10
+
11
+ This package has two entrypoints:
12
+
13
+ - `@simplysm/lint/eslint-plugin` -- ESLint plugin exporting custom rules.
14
+ - `@simplysm/lint/eslint-recommended` -- Ready-to-use flat config with all recommended rules.
15
+
16
+ ## API Overview
17
+
18
+ ### ESLint Plugin (`@simplysm/lint/eslint-plugin`)
19
+
20
+ | API | Type | Description |
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`
55
+
56
+ Restricts ECMAScript private fields (`#field`) and enforces TypeScript `private` keyword usage. Auto-fixable: renames `#field` to `private _field` and `this.#field` to `this._field`.
57
+
58
+ ### `no-subpath-imports-from-simplysm`
59
+
60
+ Prohibits `src` subpath imports from `@simplysm/*` packages (e.g., `@simplysm/pkg/src/x` is prohibited). Auto-fixable: rewrites to `@simplysm/pkg`.
61
+
62
+ ### `ts-no-throw-not-implemented-error`
63
+
64
+ Detects and warns about `new NotImplementedError()` usage from `@simplysm/core-common`. Supports named imports, aliased imports, and namespace imports. Helps prevent unimplemented code from reaching production.
65
+
66
+ ## Recommended Config Details
67
+
68
+ The recommended config (`@simplysm/lint/eslint-recommended`) includes:
69
+
70
+ - **JS/TS common rules**: `no-console`, `eqeqeq`, `no-self-compare`, `array-callback-return`
71
+ - **TypeScript rules**: `require-await`, `no-floating-promises`, `strict-boolean-expressions`, `no-unnecessary-condition`, `prefer-readonly`, and more
72
+ - **Import rules**: `no-extraneous-dependencies`, unused import auto-removal
73
+ - **Node built-in restrictions**: Prohibits `Buffer` (use `Uint8Array`) and `events` (use `@simplysm/core-common` `EventEmitter`)
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`
76
+
77
+ ## Usage Examples
78
+
79
+ ### Use recommended config
80
+
81
+ ```typescript
82
+ // eslint.config.ts
83
+ import recommended from "@simplysm/lint/eslint-recommended";
84
+
85
+ export default recommended;
86
+ ```
87
+
88
+ ### Use plugin rules individually
89
+
90
+ ```typescript
91
+ // eslint.config.ts
92
+ import plugin from "@simplysm/lint/eslint-plugin";
93
+
94
+ export default [
95
+ {
96
+ plugins: { "@simplysm": plugin },
97
+ rules: {
98
+ "@simplysm/no-hard-private": "error",
99
+ "@simplysm/no-subpath-imports-from-simplysm": "error",
100
+ "@simplysm/ts-no-throw-not-implemented-error": "warn",
101
+ },
102
+ },
103
+ ];
104
+ ```
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
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/lint",
3
- "version": "13.0.97",
3
+ "version": "13.0.98",
4
4
  "description": "Simplysm package - Lint configuration (ESLint)",
5
5
  "author": "simplysm",
6
6
  "license": "Apache-2.0",