oxlint-plugin-effect 0.14.0 → 0.16.0

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 (61) hide show
  1. package/README.md +16 -3
  2. package/dist/presets/recommended.d.ts +1 -0
  3. package/dist/presets/recommended.js +1 -0
  4. package/dist/rules/_anti-slop-array-method.js +41 -33
  5. package/dist/rules/_anti-slop-dictionary-types.js +172 -129
  6. package/dist/rules/_anti-slop-function-parameters.js +9 -6
  7. package/dist/rules/_anti-slop-lexical-type-parameters.js +6 -14
  8. package/dist/rules/_anti-slop-reflect-method.js +7 -3
  9. package/dist/rules/_anti-slop-scope.js +8 -6
  10. package/dist/rules/_anti-slop-type-alias-resolution.js +58 -65
  11. package/dist/rules/_ast-ancestors.js +14 -0
  12. package/dist/rules/_ast-children.js +18 -0
  13. package/dist/rules/_call-arguments.js +11 -0
  14. package/dist/rules/_effect-context.js +25 -20
  15. package/dist/rules/_function-metrics.js +63 -44
  16. package/dist/rules/_tagged-control-flow.js +38 -60
  17. package/dist/rules/_test-apis.js +47 -0
  18. package/dist/rules/index.d.ts +2 -1
  19. package/dist/rules/index.js +2 -0
  20. package/dist/rules/no-array-filter-map.js +24 -14
  21. package/dist/rules/no-chained-type-assertions.js +7 -4
  22. package/dist/rules/no-conditional-empty-object-spread.js +7 -4
  23. package/dist/rules/no-dynamic-imports.js +33 -25
  24. package/dist/rules/no-eager-acquire.js +40 -34
  25. package/dist/rules/no-effect-run-in-tests.js +11 -8
  26. package/dist/rules/no-globals.js +42 -31
  27. package/dist/rules/no-known-value-widening.js +64 -39
  28. package/dist/rules/no-module-level-mutable-state.js +4 -8
  29. package/dist/rules/no-module-mocks.js +37 -48
  30. package/dist/rules/no-new-promise.js +6 -2
  31. package/dist/rules/no-node-builtin-import.js +56 -33
  32. package/dist/rules/no-nullish.js +5 -1
  33. package/dist/rules/no-object-parameters.js +9 -7
  34. package/dist/rules/no-per-call-cache-construction.js +2 -2
  35. package/dist/rules/no-reduce-accumulator-copy.js +65 -53
  36. package/dist/rules/no-reflect-apply.js +7 -4
  37. package/dist/rules/no-reflect-get.js +7 -4
  38. package/dist/rules/no-run-collect-on-unbounded-stream.js +23 -25
  39. package/dist/rules/no-runtime-typeof.js +9 -5
  40. package/dist/rules/no-sequential-effect-all.js +18 -11
  41. package/dist/rules/no-shape-in-symbol-names.js +10 -6
  42. package/dist/rules/no-silent-catch-all.js +20 -14
  43. package/dist/rules/no-test-globals.d.ts +6 -0
  44. package/dist/rules/no-test-globals.js +147 -0
  45. package/dist/rules/no-test-lifecycle-hooks.js +4 -2
  46. package/dist/rules/no-unbounded-concurrency.js +22 -17
  47. package/dist/rules/no-unbounded-retry.js +47 -62
  48. package/dist/rules/no-unknown-parameters.js +5 -3
  49. package/dist/rules/no-unknown-returns.js +11 -10
  50. package/dist/rules/no-unknown-type-aliases.js +13 -9
  51. package/dist/rules/no-unsafe-dictionary-type.js +22 -27
  52. package/dist/rules/no-widen-then-assert.js +95 -72
  53. package/dist/rules/prefer-catch-tag.js +29 -37
  54. package/dist/rules/prefer-match-tags-exhaustive.js +35 -47
  55. package/dist/rules/prefer-predicate-is-tagged.js +4 -6
  56. package/dist/rules/prefer-service-of.js +39 -26
  57. package/dist/rules/require-named-effect-fn.js +4 -2
  58. package/dist/rules/require-suppression-reason.js +8 -3
  59. package/dist/vendor/effect-oxlint/Scope.js +1 -1
  60. package/package.json +3 -1
  61. package/presets/recommended.json +58 -0
@@ -24,8 +24,12 @@ const parseDirectives = (value) => {
24
24
  const end = matches[index + 1]?.index ?? value.length;
25
25
  const padded = ` ${value.slice(start, end).replaceAll(/\n[\t *]*/gu, " ").trim()} `;
26
26
  const separator = padded.search(reasonSeparator);
27
- const targetText = separator === -1 ? padded : padded.slice(0, separator);
28
- const reason = separator === -1 ? "" : padded.slice(separator + 4);
27
+ let targetText = padded;
28
+ let reason = "";
29
+ if (separator !== -1) {
30
+ targetText = padded.slice(0, separator);
31
+ reason = padded.slice(separator + 4);
32
+ }
29
33
  return {
30
34
  kind: kindOf(name),
31
35
  name,
@@ -37,7 +41,8 @@ const parseDirectives = (value) => {
37
41
  const checkDirective = (directive) => {
38
42
  const findings = [];
39
43
  if (directive.kind !== "typescript" && directive.targets.length === 0) {
40
- const example = directive.kind === "lint" ? "rule-name" : "ruleName:off";
44
+ let example = "ruleName:off";
45
+ if (directive.kind === "lint") example = "rule-name";
41
46
  findings.push({
42
47
  messageId: "missingTarget",
43
48
  data: {
@@ -107,4 +107,4 @@ const throughReferences = (scope) => scope.through;
107
107
  */
108
108
  const isStrict = (scope) => scope.isStrict;
109
109
  //#endregion
110
- export { Scope_exports, findVariableUp };
110
+ export { Scope_exports, findVariableUp, getReferences, throughReferences, variables };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oxlint-plugin-effect",
3
- "version": "0.14.0",
3
+ "version": "0.16.0",
4
4
  "description": "oxlint plugin with Effect-specific lint rules",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -9,6 +9,7 @@
9
9
  },
10
10
  "files": [
11
11
  "dist",
12
+ "presets",
12
13
  "THIRD_PARTY_NOTICES.md"
13
14
  ],
14
15
  "type": "module",
@@ -31,6 +32,7 @@
31
32
  "default": "./dist/vendor/effect-oxlint/index.js"
32
33
  }
33
34
  },
35
+ "./presets/recommended.json": "./presets/recommended.json",
34
36
  "./presets/*": {
35
37
  "import": {
36
38
  "types": "./dist/presets/*.d.ts",
@@ -0,0 +1,58 @@
1
+ {
2
+ "jsPlugins": ["oxlint-plugin-effect/plugin"],
3
+ "rules": {
4
+ "complexity": ["error", { "max": 21 }],
5
+ "effect/maxCognitiveComplexity": ["error", { "max": 21 }],
6
+ "effect/maxHalsteadDifficulty": ["error", { "max": 79 }],
7
+ "effect/noArrayFilterMap": "error",
8
+ "effect/noAs": "error",
9
+ "effect/noAsyncFunction": "error",
10
+ "effect/noChainedTypeAssertions": "error",
11
+ "effect/noConditionalEmptyObjectSpread": "error",
12
+ "effect/noDynamicImports": "error",
13
+ "effect/noEagerAcquire": "error",
14
+ "effect/noEffectBind": "error",
15
+ "effect/noEffectDo": "error",
16
+ "effect/noEffectRunInTests": "error",
17
+ "effect/noGlobals": "error",
18
+ "effect/noInlineProvide": "error",
19
+ "effect/noKnownValueWidening": "error",
20
+ "effect/noManagedRuntimeInEffect": "error",
21
+ "effect/noModuleLevelMutableState": "error",
22
+ "effect/noModuleMocks": "error",
23
+ "effect/noNestedEffectGen": "error",
24
+ "effect/noNewError": "error",
25
+ "effect/noNewPromise": "error",
26
+ "effect/noNodeBuiltinImport": "error",
27
+ "effect/noNullish": "error",
28
+ "effect/noObjectParameters": "error",
29
+ "effect/noPerCallCacheConstruction": "error",
30
+ "effect/noReduceAccumulatorCopy": "error",
31
+ "effect/noReflectApply": "error",
32
+ "effect/noReflectGet": "error",
33
+ "effect/noRunCollectOnUnboundedStream": "error",
34
+ "effect/noRuntimeTypeof": "error",
35
+ "effect/noSequentialEffectAll": "error",
36
+ "effect/noShapeInSymbolNames": "error",
37
+ "effect/noSilentCatchAll": "error",
38
+ "effect/noTernary": "error",
39
+ "effect/noTestGlobals": "error",
40
+ "effect/noTestLifecycleHooks": "error",
41
+ "effect/noThrowStatement": "error",
42
+ "effect/noTryCatch": "error",
43
+ "effect/noUnboundedConcurrency": "error",
44
+ "effect/noUnboundedRetry": "error",
45
+ "effect/noUnknownParameters": "error",
46
+ "effect/noUnknownReturns": "error",
47
+ "effect/noUnknownTypeAliases": "error",
48
+ "effect/noUnsafeDictionaryType": "error",
49
+ "effect/noWidenThenAssert": "error",
50
+ "effect/preferCatchTag": "error",
51
+ "effect/preferEffectFn": "error",
52
+ "effect/preferMatchTagsExhaustive": "error",
53
+ "effect/preferPredicateIsTagged": "error",
54
+ "effect/preferServiceOf": "error",
55
+ "effect/requireNamedEffectFn": "error",
56
+ "effect/requireSuppressionReason": "error"
57
+ }
58
+ }