oxlint-plugin-effector 0.0.2 → 0.0.3

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 (3) hide show
  1. package/README.md +15 -3
  2. package/dist/index.js +21 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -25,9 +25,21 @@ Program discovery (`src/shared/services.ts`) is on plain `typescript` and handle
25
25
  - if no tsconfig is found, a node-resolution fallback is used so `effector`/`react` types still resolve;
26
26
  - set **`OXLINT_EFFECTOR_TSCONFIG`** to point at a specific tsconfig (custom names, monorepo roots).
27
27
 
28
- Trade-off: building a TypeScript program means these rules are not "native oxlint" fast — the first lint of a
29
- project pays for program creation. Functionally there are **no limitations** versus `eslint-plugin-effector`
30
- (the full upstream test suite 349 cases passes against the real type checker).
28
+ ### Performance
29
+
30
+ These rules are **type-aware**, so each oxlint worker thread builds a TypeScript program for the project and
31
+ resolves types — the same fixed cost any type-aware linter pays (comparable to `typescript-eslint` with
32
+ `parserOptions.project`). On a real ~350-file React project expect a few seconds of overhead over oxlint's native
33
+ rules; it is dominated by the one-time program build + type resolution, which parallelizes across threads and is
34
+ largely inherent (it cannot be shared with oxlint's own type checker). Functionally there are **no limitations**
35
+ versus `eslint-plugin-effector` (the full upstream test suite — 349 cases — passes against the real type checker).
36
+
37
+ Levers if it's too slow:
38
+
39
+ - **`OXLINT_EFFECTOR_TSCONFIG`** → point at a lean tsconfig that `include`s only your source (skip tests/build
40
+ output) so the program is smaller;
41
+ - **`oxlint --threads N`** → on a type-aware run, fewer threads can be as fast or faster (each thread builds its
42
+ own program), so try a lower number than your core count.
31
43
 
32
44
  ## Installation
33
45
 
package/dist/index.js CHANGED
@@ -19,6 +19,24 @@ var NodeType = {
19
19
  SpreadElement: "SpreadElement",
20
20
  VariableDeclarator: "VariableDeclarator"
21
21
  };
22
+ var NON_UNIT_INIT = /* @__PURE__ */ new Set([
23
+ "ArrayExpression",
24
+ "ArrowFunctionExpression",
25
+ "BinaryExpression",
26
+ "ClassExpression",
27
+ "FunctionExpression",
28
+ "JSXElement",
29
+ "JSXFragment",
30
+ "Literal",
31
+ "ObjectExpression",
32
+ "TaggedTemplateExpression",
33
+ "TemplateLiteral",
34
+ "UnaryExpression"
35
+ ]);
36
+ var bindingCannotBeUnit = (node) => {
37
+ const parent = node.parent;
38
+ return parent?.type === NodeType.VariableDeclarator && parent.id === node && parent.init != null && NON_UNIT_INIT.has(parent.init.type);
39
+ };
22
40
 
23
41
  // src/shared/services.ts
24
42
  import { dirname, resolve } from "node:path";
@@ -278,6 +296,7 @@ var enforce_effect_naming_convention_default = createRule({
278
296
  ].join(", ");
279
297
  return {
280
298
  [identifierSelectors]: (node) => {
299
+ if (bindingCannotBeUnit(node)) return;
281
300
  const type = services.getTypeAtLocation(node);
282
301
  const isEffect = isType.effect(type);
283
302
  if (!isEffect) return;
@@ -473,6 +492,7 @@ var enforce_gate_naming_convention_default = createRule({
473
492
  const services = getParserServices(context);
474
493
  return {
475
494
  [`VariableDeclarator[id.name=${GateRegex}]`]: (node) => {
495
+ if (bindingCannotBeUnit(node.id)) return;
476
496
  const type = services.getTypeAtLocation(node);
477
497
  const isGate = isType.gate(type);
478
498
  if (!isGate) return;
@@ -539,6 +559,7 @@ var enforce_store_naming_convention_default = createRule({
539
559
  ].join(", ");
540
560
  return {
541
561
  [identifierSelectors]: (node) => {
562
+ if (bindingCannotBeUnit(node)) return;
542
563
  const type = services.getTypeAtLocation(node);
543
564
  const isStore = isType.store(type);
544
565
  if (!isStore) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oxlint-plugin-effector",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Enforcing best practices for Effector — a full type-aware oxlint plugin (port of eslint-plugin-effector)",
5
5
  "license": "MIT",
6
6
  "author": "Marsel Abazbekov <marsel.ave@gmail.com>",