@tianjos/eslint-plugin-elegant 0.3.1 → 0.3.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 CHANGED
@@ -87,47 +87,71 @@ The `recommended` config enables every custom rule plus the native
87
87
 
88
88
  ### Rule details
89
89
 
90
- - **`no-boolean-param`** — a boolean argument almost always means the callee
91
- does two things. Prefer two intention-revealing functions or an options
92
- object. Flags both annotated (`flag: boolean`) and boolean-defaulted
93
- (`flag = false`) parameters.
94
- - **`max-class-methods`** a proxy for the Single Responsibility Principle.
95
- Constructors are not counted; getters and setters are.
96
- - **`no-type-assertion`** — assertions silence the type checker. Reach for a
97
- type guard, a generic, or a correctly typed value instead. `as const` is
98
- permitted because it narrows rather than widens.
99
- - **`no-null-return`** keeps absence out of return values; model it with an
100
- explicit domain type or throw.
101
- - **`no-public-mutable-props`** — public state should be `readonly` so callers
102
- cannot break an aggregate's invariants. `private`/`protected` members and
103
- `readonly` members are allowed.
104
- - **`no-logic-in-constructor`** a constructor should only wire arguments to
105
- fields. Validation, transformation, and I/O belong in a static factory or a
106
- method, keeping object construction predictable. Parameter properties
107
- (`constructor(private readonly x: T)`) and a leading `super(...)` are allowed;
108
- computed right-hand sides (`this.x = x * 2`, `this.items = items.slice()`) and
109
- any non-assignment statement are flagged.
110
- - **`no-getters-setters`** — getters and setters turn objects into data bags;
111
- prefer methods that expose behavior. Native `get`/`set` accessors (and
112
- `accessor` fields) are always flagged. The opt-in `{ methods: true }` option
113
- also flags conventional `getX`/`setX` methods — useful for strict Elegant
114
- Objects style, but noisy around repositories and framework hooks, so it stays
115
- off in `recommended`.
116
- - **`no-instanceof`** — `instanceof` is type discrimination that belongs inside a
117
- polymorphic method on the object. Pairs with `no-type-assertion` to keep
118
- type-based branching out of the codebase.
119
- - **`no-static-members`** static state and behavior cannot be injected,
120
- substituted, or mocked. Prefer instances (with dependency injection) and a
121
- module-level `const` for shared values. The `{ allowReadonly: true }` option
122
- permits `static readonly` constants. Note this also flags `static` factory
123
- methods (`static create()`), which are common; relax per-file if your design
124
- relies on them.
125
- - **`no-null`** — completes `no-null-return` by banning the `null` literal as a
126
- value everywhere (`const x = null`, `x === null`, `fn(null)`), pushing absence
127
- into explicit types or `undefined`. `null` in type positions (`string | null`)
128
- and a direct `return null` (owned by `no-null-return`) are left alone. This is
129
- strict and will flag idioms like `JSON.stringify(x, null, 2)` relax it in the
130
- files where you interoperate with null-based APIs.
90
+ #### `no-boolean-param`
91
+
92
+ A boolean argument almost always means the callee does two things. Prefer two
93
+ intention-revealing functions or an options object. Flags both annotated
94
+ (`flag: boolean`) and boolean-defaulted (`flag = false`) parameters.
95
+
96
+ #### `max-class-methods`
97
+
98
+ A proxy for the Single Responsibility Principle. Constructors are not counted;
99
+ getters and setters are. Configurable via `{ max: number }` (default `10`).
100
+
101
+ #### `no-type-assertion`
102
+
103
+ Assertions silence the type checker. Reach for a type guard, a generic, or a
104
+ correctly typed value instead. `as const` is permitted because it narrows rather
105
+ than widens.
106
+
107
+ #### `no-null-return`
108
+
109
+ Keeps absence out of return values; model it with an explicit domain type or
110
+ throw.
111
+
112
+ #### `no-public-mutable-props`
113
+
114
+ Public state should be `readonly` so callers cannot break an aggregate's
115
+ invariants. `private`/`protected` members and `readonly` members are allowed.
116
+
117
+ #### `no-logic-in-constructor`
118
+
119
+ A constructor should only wire arguments to fields. Validation, transformation,
120
+ and I/O belong in a static factory or a method, keeping object construction
121
+ predictable. Parameter properties (`constructor(private readonly x: T)`) and a
122
+ leading `super(...)` are allowed; computed right-hand sides (`this.x = x * 2`,
123
+ `this.items = items.slice()`) and any non-assignment statement are flagged.
124
+
125
+ #### `no-getters-setters`
126
+
127
+ Getters and setters turn objects into data bags; prefer methods that expose
128
+ behavior. Native `get`/`set` accessors (and `accessor` fields) are always
129
+ flagged. The opt-in `{ methods: true }` option also flags conventional
130
+ `getX`/`setX` methods useful for strict Elegant Objects style, but noisy
131
+ around repositories and framework hooks, so it stays off in `recommended`.
132
+
133
+ #### `no-instanceof`
134
+
135
+ `instanceof` is type discrimination that belongs inside a polymorphic method on
136
+ the object. Pairs with `no-type-assertion` to keep type-based branching out of
137
+ the codebase.
138
+
139
+ #### `no-static-members`
140
+
141
+ Static state and behavior cannot be injected, substituted, or mocked. Prefer
142
+ instances (with dependency injection) and a module-level `const` for shared
143
+ values. The `{ allowReadonly: true }` option permits `static readonly`
144
+ constants. Note this also flags `static` factory methods (`static create()`),
145
+ which are common; relax per-file if your design relies on them.
146
+
147
+ #### `no-null`
148
+
149
+ Completes `no-null-return` by banning the `null` literal as a value everywhere
150
+ (`const x = null`, `x === null`, `fn(null)`), pushing absence into explicit types
151
+ or `undefined`. `null` in type positions (`string | null`) and a direct
152
+ `return null` (owned by `no-null-return`) are left alone. This is strict and will
153
+ flag idioms like `JSON.stringify(x, null, 2)` — relax it in the files where you
154
+ interoperate with null-based APIs.
131
155
 
132
156
  ## Configuration
133
157
 
@@ -1,7 +1,8 @@
1
1
  import { ESLintUtils } from '@typescript-eslint/utils';
2
2
  /**
3
3
  * Factory for all rules in this plugin. Centralises the docs URL convention so
4
- * every rule links back to its documentation by name.
4
+ * every rule links back to its section in the README. The anchor matches the
5
+ * `#### \`<name>\`` heading GitHub generates for each rule under "Rule details".
5
6
  */
6
7
  export declare const createRule: <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, unknown>>) => ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener> & {
7
8
  name: string;
@@ -4,6 +4,7 @@ exports.createRule = void 0;
4
4
  const utils_1 = require("@typescript-eslint/utils");
5
5
  /**
6
6
  * Factory for all rules in this plugin. Centralises the docs URL convention so
7
- * every rule links back to its documentation by name.
7
+ * every rule links back to its section in the README. The anchor matches the
8
+ * `#### \`<name>\`` heading GitHub generates for each rule under "Rule details".
8
9
  */
9
- exports.createRule = utils_1.ESLintUtils.RuleCreator((name) => `https://github.com/tianjos/eslint-plugin-elegant/blob/main/docs/rules/${name}.md`);
10
+ exports.createRule = utils_1.ESLintUtils.RuleCreator((name) => `https://github.com/tianjos/eslint-plugin-elegant/blob/main/README.md#${name}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tianjos/eslint-plugin-elegant",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Opinionated ESLint rules for elegant, behavior-rich TypeScript: no flag arguments, no type assertions, no null returns, no public mutable state, and small focused classes.",
5
5
  "keywords": [
6
6
  "eslint",