oxlint-plugin-react-doctor 0.6.1-dev.f07ee37 → 0.6.2-dev.072d37e

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/dist/index.js +44 -24
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3458,7 +3458,7 @@ const SECRET_UNAMBIGUOUS_PLACEHOLDER_VALUE_PATTERNS = [
3458
3458
  ];
3459
3459
  const SECRET_CONTEXTUAL_PLACEHOLDER_VALUE_PATTERNS = [/(?:^|[_\-\s])(?:example|sample|dummy)(?:$|[_\-\s])/i];
3460
3460
  const SECRET_PLACEHOLDER_CONTEXT_PATTERN = /(?:placeholder|example|sample|dummy|masked|redacted|mask)/i;
3461
- const SECRET_VARIABLE_PATTERN = /(?:api_?key|secret|token|password|credential|auth)/i;
3461
+ const SECRET_VARIABLE_PATTERN = /(?:api_?key|secret|token|password|credential|auth(?!or(?!i[sz])))/i;
3462
3462
  const SECRET_TOOLING_FILE_PATTERN = /(?:^|\/)[^/]+\.config\.[cm]?[jt]s$/;
3463
3463
  const SECRET_TOOLING_RC_FILE_PATTERN = /(?:^|\/)(?:\.[a-z-]+rc|[a-z-]+\.rc)\.[cm]?[jt]s$/;
3464
3464
  const SECRET_TEST_FILE_PATTERN = /(?:^|\/)[^/]+\.(?:test|spec|stories|story|fixture|fixtures)\.[cm]?[jt]sx?$/;
@@ -7183,27 +7183,8 @@ const isDescendantScope = (inner, outer) => {
7183
7183
  return false;
7184
7184
  };
7185
7185
  //#endregion
7186
- //#region src/plugin/utils/is-ast-descendant.ts
7187
- /**
7188
- * True when `inner` is `outer` itself or any descendant in the AST
7189
- * `parent` chain. Walks `inner.parent` upward and stops at either a
7190
- * match (`true`) or the chain's root (`false`).
7191
- *
7192
- * Was duplicated byte-identical in:
7193
- * - exhaustive-deps-symbol-stability.ts
7194
- * - semantic/closure-captures.ts
7195
- */
7196
- const isAstDescendant = (inner, outer) => {
7197
- let current = inner;
7198
- while (current) {
7199
- if (current === outer) return true;
7200
- current = current.parent ?? null;
7201
- }
7202
- return false;
7203
- };
7204
- //#endregion
7205
7186
  //#region src/plugin/semantic/closure-captures.ts
7206
- const closureCaptures = (functionNode, scopes) => {
7187
+ const computeClosureCaptures = (functionNode, scopes) => {
7207
7188
  const functionScope = scopes.ownScopeFor(functionNode) ?? scopes.scopeFor(functionNode);
7208
7189
  const out = [];
7209
7190
  const seen = /* @__PURE__ */ new Set();
@@ -7238,7 +7219,20 @@ const closureCaptures = (functionNode, scopes) => {
7238
7219
  }
7239
7220
  };
7240
7221
  visit(functionNode);
7241
- return out.filter((reference) => isAstDescendant(reference.identifier, functionNode));
7222
+ return out;
7223
+ };
7224
+ const capturesByAnalysis = /* @__PURE__ */ new WeakMap();
7225
+ const closureCaptures = (functionNode, scopes) => {
7226
+ let capturesByFunction = capturesByAnalysis.get(scopes);
7227
+ if (!capturesByFunction) {
7228
+ capturesByFunction = /* @__PURE__ */ new WeakMap();
7229
+ capturesByAnalysis.set(scopes, capturesByFunction);
7230
+ }
7231
+ const memoizedCaptures = capturesByFunction.get(functionNode);
7232
+ if (memoizedCaptures) return memoizedCaptures;
7233
+ const computedCaptures = computeClosureCaptures(functionNode, scopes);
7234
+ capturesByFunction.set(functionNode, computedCaptures);
7235
+ return computedCaptures;
7242
7236
  };
7243
7237
  //#endregion
7244
7238
  //#region src/plugin/utils/is-react-hook-name.ts
@@ -7367,6 +7361,25 @@ const resolveExhaustiveDepsSettings = (settings) => {
7367
7361
  };
7368
7362
  };
7369
7363
  //#endregion
7364
+ //#region src/plugin/utils/is-ast-descendant.ts
7365
+ /**
7366
+ * True when `inner` is `outer` itself or any descendant in the AST
7367
+ * `parent` chain. Walks `inner.parent` upward and stops at either a
7368
+ * match (`true`) or the chain's root (`false`).
7369
+ *
7370
+ * Was duplicated byte-identical in:
7371
+ * - exhaustive-deps-symbol-stability.ts
7372
+ * - semantic/closure-captures.ts
7373
+ */
7374
+ const isAstDescendant = (inner, outer) => {
7375
+ let current = inner;
7376
+ while (current) {
7377
+ if (current === outer) return true;
7378
+ current = current.parent ?? null;
7379
+ }
7380
+ return false;
7381
+ };
7382
+ //#endregion
7370
7383
  //#region src/plugin/rules/react-builtins/exhaustive-deps-symbol-stability.ts
7371
7384
  /**
7372
7385
  * Symbol-stability helpers consumed by the `exhaustive-deps` rule.
@@ -12529,6 +12542,7 @@ const KNOWN_SLOT_PROP_NAMES = new Set([
12529
12542
  "bottomContent",
12530
12543
  "leftContent",
12531
12544
  "rightContent",
12545
+ "config",
12532
12546
  "value",
12533
12547
  "currentValue",
12534
12548
  "form",
@@ -12667,6 +12681,10 @@ const SLOT_PROP_SUFFIXES = [
12667
12681
  "Panel",
12668
12682
  "Overlay",
12669
12683
  "Shape",
12684
+ "Avatar",
12685
+ "Text",
12686
+ "State",
12687
+ "Zone",
12670
12688
  "Override",
12671
12689
  "Overrides",
12672
12690
  "Items",
@@ -12683,6 +12701,8 @@ const SLOT_PROP_SUFFIXES = [
12683
12701
  ];
12684
12702
  const isSlotPropName = (propName) => {
12685
12703
  if (KNOWN_SLOT_PROP_NAMES.has(propName)) return true;
12704
+ const decapitalized = propName.charAt(0).toLowerCase() + propName.slice(1);
12705
+ if (decapitalized !== propName && KNOWN_SLOT_PROP_NAMES.has(decapitalized)) return true;
12686
12706
  for (const suffix of SLOT_PROP_SUFFIXES) if (propName.length > suffix.length && propName.endsWith(suffix)) return true;
12687
12707
  return false;
12688
12708
  };
@@ -29728,10 +29748,10 @@ const onlyExportComponents = defineRule({
29728
29748
  };
29729
29749
  for (const child of componentCandidates) {
29730
29750
  if (isNodeOfType(child, "FunctionDeclaration") && child.id) {
29731
- if (isReactComponentName(child.id.name) && !isInsideExport(child)) localComponents.push(child.id);
29751
+ if (isReactComponentName(child.id.name) && !isInsideExport(child) && !isInsideFunctionScope(child)) localComponents.push(child.id);
29732
29752
  }
29733
29753
  if (isNodeOfType(child, "VariableDeclarator") && isNodeOfType(child.id, "Identifier")) {
29734
- if (isReactComponentName(child.id.name) && canBeReactFunctionComponent(child.init, state) && !isInsideExport(child)) localComponents.push(child.id);
29754
+ if (isReactComponentName(child.id.name) && canBeReactFunctionComponent(child.init, state) && !isInsideExport(child) && !isInsideFunctionScope(child)) localComponents.push(child.id);
29735
29755
  }
29736
29756
  }
29737
29757
  if (hasAnyExports && hasReactExport) for (const entry of exports) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oxlint-plugin-react-doctor",
3
- "version": "0.6.1-dev.f07ee37",
3
+ "version": "0.6.2-dev.072d37e",
4
4
  "description": "React Doctor rules for oxlint.",
5
5
  "keywords": [
6
6
  "accessibility",