@felixarntz/biome 0.1.0 → 0.1.1

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
@@ -8,7 +8,7 @@ Reusable [Biome](https://biomejs.dev) lint rules that make your agent produce be
8
8
  | --- | --- |
9
9
  | `no-as-unknown-as` | `value as unknown as T` double assertions, which bypass TypeScript's type checking entirely. |
10
10
  | `no-in-operator` | The `in` operator, recommending `Object.hasOwn(obj, prop)` (which does not walk the prototype chain). |
11
- | `prefer-object-parameter` | Functions, methods, and constructors with more than one positional parameter, recommending a single object argument with named parameters instead. A leading TypeScript `this` parameter is not counted. |
11
+ | `prefer-object-parameter` | Functions, methods, and constructors with more than one positional parameter, recommending a single object argument with named parameters instead. A leading TypeScript `this` parameter is not counted. Inline callbacks, whose signature is dictated by the calling API, are left alone. |
12
12
 
13
13
  ## Installation
14
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@felixarntz/biome",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Reusable Biome (GritQL) lint rules that make your agent produce better code in fewer review cycles.",
5
5
  "license": "MIT",
6
6
  "keywords": [
package/rules/all.grit CHANGED
@@ -10,20 +10,51 @@ or {
10
10
  `$prop in $obj` as $expr where {
11
11
  register_diagnostic(span=$expr, message="Use `Object.hasOwn($obj, $prop)` instead of the `in` operator. `in` also walks the prototype chain, which is rarely the intended runtime check.")
12
12
  },
13
+ // Every arm below binds $params to a parameter items list, then the shared
14
+ // trailing where applies one multi-positional check and emits the diagnostic.
15
+ // The list is deliberately structural: it covers signatures whose author owns
16
+ // the parameter list -- named/declared functions, every method form (class,
17
+ // object, interface, abstract), constructors and construct signatures, function
18
+ // values assigned to a variable, and named function/constructor type aliases.
19
+ // It intentionally omits callback-shaped signatures whose parameter list is
20
+ // dictated by the API that calls them: arrow/function expressions passed inline
21
+ // (such as the reducer in arr.reduce(...)), object-property function values,
22
+ // class arrow fields, bare call signatures, and inline function types. Those
23
+ // cannot be rewritten to a single object parameter by the author, so flagging
24
+ // them only produces unfixable diagnostics.
25
+ //
26
+ // Grit parameterized pattern definitions do not compile in Biome, so the
27
+ // multi-positional check cannot be factored into a helper; the shared trailing
28
+ // where is how it stays written once.
13
29
  or {
14
- JsParameters(items = $params) where {
15
- or {
16
- $params <: [TsThisParameter(), $second, $third, ...],
17
- and {
18
- $params <: [$first, $second, ...],
19
- $first <: not TsThisParameter()
20
- }
21
- },
22
- register_diagnostic(span=$params, message="Use a single object argument with named parameters instead of multiple positional parameters. Object parameters keep call sites self-documenting and make argument order irrelevant.")
30
+ JsFunctionDeclaration(parameters = JsParameters(items = $params)),
31
+ TsDeclareFunctionDeclaration(parameters = JsParameters(items = $params)),
32
+ JsMethodClassMember(parameters = JsParameters(items = $params)),
33
+ TsMethodSignatureClassMember(parameters = JsParameters(items = $params)),
34
+ JsMethodObjectMember(parameters = JsParameters(items = $params)),
35
+ TsMethodSignatureTypeMember(parameters = JsParameters(items = $params)),
36
+ TsConstructSignatureTypeMember(parameters = JsParameters(items = $params)),
37
+ JsConstructorParameters(parameters = $params),
38
+ JsVariableDeclarator(initializer = JsInitializerClause(expression = $fn)) where {
39
+ $fn <: or {
40
+ JsArrowFunctionExpression(parameters = JsParameters(items = $params)),
41
+ JsFunctionExpression(parameters = JsParameters(items = $params))
42
+ }
23
43
  },
24
- JsConstructorParameters(parameters = $params) where {
25
- $params <: [$first, $second, ...],
26
- register_diagnostic(span=$params, message="Use a single object argument with named parameters instead of multiple positional parameters. Object parameters keep call sites self-documenting and make argument order irrelevant.")
44
+ TsTypeAliasDeclaration(ty = $aliased) where {
45
+ $aliased <: or {
46
+ TsFunctionType(parameters = JsParameters(items = $params)),
47
+ TsConstructorType(parameters = JsParameters(items = $params))
48
+ }
27
49
  }
50
+ } where {
51
+ or {
52
+ $params <: [TsThisParameter(), $second, $third, ...],
53
+ and {
54
+ $params <: [$first, $second, ...],
55
+ $first <: not TsThisParameter()
56
+ }
57
+ },
58
+ register_diagnostic(span=$params, message="Use a single object argument with named parameters instead of multiple positional parameters. Object parameters keep call sites self-documenting and make argument order irrelevant.")
28
59
  }
29
60
  }
@@ -1,18 +1,49 @@
1
1
  language js
2
2
 
3
+ // Every arm below binds $params to a parameter items list, then the shared
4
+ // trailing where applies one multi-positional check and emits the diagnostic.
5
+ // The list is deliberately structural: it covers signatures whose author owns
6
+ // the parameter list -- named/declared functions, every method form (class,
7
+ // object, interface, abstract), constructors and construct signatures, function
8
+ // values assigned to a variable, and named function/constructor type aliases.
9
+ // It intentionally omits callback-shaped signatures whose parameter list is
10
+ // dictated by the API that calls them: arrow/function expressions passed inline
11
+ // (such as the reducer in arr.reduce(...)), object-property function values,
12
+ // class arrow fields, bare call signatures, and inline function types. Those
13
+ // cannot be rewritten to a single object parameter by the author, so flagging
14
+ // them only produces unfixable diagnostics.
15
+ //
16
+ // Grit parameterized pattern definitions do not compile in Biome, so the
17
+ // multi-positional check cannot be factored into a helper; the shared trailing
18
+ // where is how it stays written once.
3
19
  or {
4
- JsParameters(items = $params) where {
5
- or {
6
- $params <: [TsThisParameter(), $second, $third, ...],
7
- and {
8
- $params <: [$first, $second, ...],
9
- $first <: not TsThisParameter()
10
- }
11
- },
12
- register_diagnostic(span=$params, message="Use a single object argument with named parameters instead of multiple positional parameters. Object parameters keep call sites self-documenting and make argument order irrelevant.")
20
+ JsFunctionDeclaration(parameters = JsParameters(items = $params)),
21
+ TsDeclareFunctionDeclaration(parameters = JsParameters(items = $params)),
22
+ JsMethodClassMember(parameters = JsParameters(items = $params)),
23
+ TsMethodSignatureClassMember(parameters = JsParameters(items = $params)),
24
+ JsMethodObjectMember(parameters = JsParameters(items = $params)),
25
+ TsMethodSignatureTypeMember(parameters = JsParameters(items = $params)),
26
+ TsConstructSignatureTypeMember(parameters = JsParameters(items = $params)),
27
+ JsConstructorParameters(parameters = $params),
28
+ JsVariableDeclarator(initializer = JsInitializerClause(expression = $fn)) where {
29
+ $fn <: or {
30
+ JsArrowFunctionExpression(parameters = JsParameters(items = $params)),
31
+ JsFunctionExpression(parameters = JsParameters(items = $params))
32
+ }
13
33
  },
14
- JsConstructorParameters(parameters = $params) where {
15
- $params <: [$first, $second, ...],
16
- register_diagnostic(span=$params, message="Use a single object argument with named parameters instead of multiple positional parameters. Object parameters keep call sites self-documenting and make argument order irrelevant.")
34
+ TsTypeAliasDeclaration(ty = $aliased) where {
35
+ $aliased <: or {
36
+ TsFunctionType(parameters = JsParameters(items = $params)),
37
+ TsConstructorType(parameters = JsParameters(items = $params))
38
+ }
17
39
  }
40
+ } where {
41
+ or {
42
+ $params <: [TsThisParameter(), $second, $third, ...],
43
+ and {
44
+ $params <: [$first, $second, ...],
45
+ $first <: not TsThisParameter()
46
+ }
47
+ },
48
+ register_diagnostic(span=$params, message="Use a single object argument with named parameters instead of multiple positional parameters. Object parameters keep call sites self-documenting and make argument order irrelevant.")
18
49
  }