react-doctor 0.0.46 → 0.0.47

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/dist/cli.js CHANGED
@@ -1760,16 +1760,45 @@ const REACT_COMPILER_RULES = {
1760
1760
  "react-hooks-js/incompatible-library": "warn",
1761
1761
  "react-hooks-js/todo": "warn"
1762
1762
  };
1763
+ const readPluginRuleNames = (pluginSpecifier) => {
1764
+ try {
1765
+ const pluginModule = esmRequire$1(pluginSpecifier);
1766
+ const rules = pluginModule.rules ?? pluginModule.default?.rules;
1767
+ if (rules === void 0) return /* @__PURE__ */ new Set();
1768
+ return new Set(Object.keys(rules));
1769
+ } catch {
1770
+ return /* @__PURE__ */ new Set();
1771
+ }
1772
+ };
1763
1773
  const resolveReactHooksJsPlugin = (hasReactCompiler, customRulesOnly) => {
1764
1774
  if (!hasReactCompiler || customRulesOnly) return null;
1775
+ let pluginSpecifier;
1765
1776
  try {
1766
- return {
1767
- name: "react-hooks-js",
1768
- specifier: esmRequire$1.resolve("eslint-plugin-react-hooks")
1769
- };
1777
+ pluginSpecifier = esmRequire$1.resolve("eslint-plugin-react-hooks");
1770
1778
  } catch {
1771
1779
  return null;
1772
1780
  }
1781
+ return {
1782
+ entry: {
1783
+ name: "react-hooks-js",
1784
+ specifier: pluginSpecifier
1785
+ },
1786
+ availableRuleNames: readPluginRuleNames(pluginSpecifier)
1787
+ };
1788
+ };
1789
+ const filterRulesToAvailable = (rules, pluginNamespace, availableRuleNames) => {
1790
+ if (availableRuleNames.size === 0) return rules;
1791
+ const ruleKeyPrefix = `${pluginNamespace}/`;
1792
+ const filtered = {};
1793
+ for (const [ruleKey, severity] of Object.entries(rules)) {
1794
+ if (!ruleKey.startsWith(ruleKeyPrefix)) {
1795
+ filtered[ruleKey] = severity;
1796
+ continue;
1797
+ }
1798
+ const ruleName = ruleKey.slice(ruleKeyPrefix.length);
1799
+ if (availableRuleNames.has(ruleName)) filtered[ruleKey] = severity;
1800
+ }
1801
+ return filtered;
1773
1802
  };
1774
1803
  const TANSTACK_QUERY_RULES = {
1775
1804
  "react-doctor/query-stable-query-client": "warn",
@@ -1917,6 +1946,7 @@ const ALL_REACT_DOCTOR_RULE_KEYS = new Set([
1917
1946
  ]);
1918
1947
  const createOxlintConfig = ({ pluginPath, framework, hasReactCompiler, hasTanStackQuery, customRulesOnly = false }) => {
1919
1948
  const reactHooksJsPlugin = resolveReactHooksJsPlugin(hasReactCompiler, customRulesOnly);
1949
+ const reactCompilerRules = reactHooksJsPlugin ? filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames) : {};
1920
1950
  return {
1921
1951
  categories: {
1922
1952
  correctness: "off",
@@ -1928,11 +1958,11 @@ const createOxlintConfig = ({ pluginPath, framework, hasReactCompiler, hasTanSta
1928
1958
  nursery: "off"
1929
1959
  },
1930
1960
  plugins: customRulesOnly ? [] : ["react", "jsx-a11y"],
1931
- jsPlugins: reactHooksJsPlugin ? [reactHooksJsPlugin, pluginPath] : [pluginPath],
1961
+ jsPlugins: reactHooksJsPlugin ? [reactHooksJsPlugin.entry, pluginPath] : [pluginPath],
1932
1962
  rules: {
1933
1963
  ...customRulesOnly ? {} : BUILTIN_REACT_RULES,
1934
1964
  ...customRulesOnly ? {} : BUILTIN_A11Y_RULES,
1935
- ...reactHooksJsPlugin ? REACT_COMPILER_RULES : {},
1965
+ ...reactCompilerRules,
1936
1966
  ...GLOBAL_REACT_DOCTOR_RULES,
1937
1967
  ...framework === "nextjs" ? NEXTJS_RULES : {},
1938
1968
  ...framework === "expo" || framework === "react-native" ? REACT_NATIVE_RULES : {},
@@ -3333,7 +3363,7 @@ const promptProjectSelection = async (workspacePackages, rootDirectory) => {
3333
3363
  };
3334
3364
  //#endregion
3335
3365
  //#region src/cli.ts
3336
- const VERSION = "0.0.46";
3366
+ const VERSION = "0.0.47";
3337
3367
  const VALID_FAIL_ON_LEVELS = new Set([
3338
3368
  "error",
3339
3369
  "warning",
package/dist/index.js CHANGED
@@ -1512,16 +1512,45 @@ const REACT_COMPILER_RULES = {
1512
1512
  "react-hooks-js/incompatible-library": "warn",
1513
1513
  "react-hooks-js/todo": "warn"
1514
1514
  };
1515
+ const readPluginRuleNames = (pluginSpecifier) => {
1516
+ try {
1517
+ const pluginModule = esmRequire$1(pluginSpecifier);
1518
+ const rules = pluginModule.rules ?? pluginModule.default?.rules;
1519
+ if (rules === void 0) return /* @__PURE__ */ new Set();
1520
+ return new Set(Object.keys(rules));
1521
+ } catch {
1522
+ return /* @__PURE__ */ new Set();
1523
+ }
1524
+ };
1515
1525
  const resolveReactHooksJsPlugin = (hasReactCompiler, customRulesOnly) => {
1516
1526
  if (!hasReactCompiler || customRulesOnly) return null;
1527
+ let pluginSpecifier;
1517
1528
  try {
1518
- return {
1519
- name: "react-hooks-js",
1520
- specifier: esmRequire$1.resolve("eslint-plugin-react-hooks")
1521
- };
1529
+ pluginSpecifier = esmRequire$1.resolve("eslint-plugin-react-hooks");
1522
1530
  } catch {
1523
1531
  return null;
1524
1532
  }
1533
+ return {
1534
+ entry: {
1535
+ name: "react-hooks-js",
1536
+ specifier: pluginSpecifier
1537
+ },
1538
+ availableRuleNames: readPluginRuleNames(pluginSpecifier)
1539
+ };
1540
+ };
1541
+ const filterRulesToAvailable = (rules, pluginNamespace, availableRuleNames) => {
1542
+ if (availableRuleNames.size === 0) return rules;
1543
+ const ruleKeyPrefix = `${pluginNamespace}/`;
1544
+ const filtered = {};
1545
+ for (const [ruleKey, severity] of Object.entries(rules)) {
1546
+ if (!ruleKey.startsWith(ruleKeyPrefix)) {
1547
+ filtered[ruleKey] = severity;
1548
+ continue;
1549
+ }
1550
+ const ruleName = ruleKey.slice(ruleKeyPrefix.length);
1551
+ if (availableRuleNames.has(ruleName)) filtered[ruleKey] = severity;
1552
+ }
1553
+ return filtered;
1525
1554
  };
1526
1555
  const TANSTACK_QUERY_RULES = {
1527
1556
  "react-doctor/query-stable-query-client": "warn",
@@ -1669,6 +1698,7 @@ const ALL_REACT_DOCTOR_RULE_KEYS = new Set([
1669
1698
  ]);
1670
1699
  const createOxlintConfig = ({ pluginPath, framework, hasReactCompiler, hasTanStackQuery, customRulesOnly = false }) => {
1671
1700
  const reactHooksJsPlugin = resolveReactHooksJsPlugin(hasReactCompiler, customRulesOnly);
1701
+ const reactCompilerRules = reactHooksJsPlugin ? filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames) : {};
1672
1702
  return {
1673
1703
  categories: {
1674
1704
  correctness: "off",
@@ -1680,11 +1710,11 @@ const createOxlintConfig = ({ pluginPath, framework, hasReactCompiler, hasTanSta
1680
1710
  nursery: "off"
1681
1711
  },
1682
1712
  plugins: customRulesOnly ? [] : ["react", "jsx-a11y"],
1683
- jsPlugins: reactHooksJsPlugin ? [reactHooksJsPlugin, pluginPath] : [pluginPath],
1713
+ jsPlugins: reactHooksJsPlugin ? [reactHooksJsPlugin.entry, pluginPath] : [pluginPath],
1684
1714
  rules: {
1685
1715
  ...customRulesOnly ? {} : BUILTIN_REACT_RULES,
1686
1716
  ...customRulesOnly ? {} : BUILTIN_A11Y_RULES,
1687
- ...reactHooksJsPlugin ? REACT_COMPILER_RULES : {},
1717
+ ...reactCompilerRules,
1688
1718
  ...GLOBAL_REACT_DOCTOR_RULES,
1689
1719
  ...framework === "nextjs" ? NEXTJS_RULES : {},
1690
1720
  ...framework === "expo" || framework === "react-native" ? REACT_NATIVE_RULES : {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-doctor",
3
- "version": "0.0.46",
3
+ "version": "0.0.47",
4
4
  "description": "Diagnose and fix React codebases for security, performance, correctness, accessibility, bundle-size, and architecture issues",
5
5
  "keywords": [
6
6
  "accessibility",
@@ -66,7 +66,7 @@
66
66
  "commander": "^14.0.3",
67
67
  "knip": "^6.3.1",
68
68
  "ora": "^9.3.0",
69
- "oxlint": "^1.60.0",
69
+ "oxlint": "^1.62.0",
70
70
  "picocolors": "^1.1.1",
71
71
  "prompts": "^2.4.2",
72
72
  "typescript": ">=5.0.4 <7"