Home / File/ index.ts — react Source File

index.ts — react Source File

Architecture documentation for index.ts, a typescript file in the react codebase. 8 imports, 0 dependents.

File typescript BabelCompiler Validation 8 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  b4590b6e_50d1_c664_5047_3e6e187f6b97["index.ts"]
  ea02b01a_dd46_4b35_fe00_775aec496668["ExhaustiveDeps.ts"]
  b4590b6e_50d1_c664_5047_3e6e187f6b97 --> ea02b01a_dd46_4b35_fe00_775aec496668
  40190dd7_cea0_7135_9d7e_df5f2d3454b7["ReactCompiler.ts"]
  b4590b6e_50d1_c664_5047_3e6e187f6b97 --> 40190dd7_cea0_7135_9d7e_df5f2d3454b7
  dc45eeec_7cda_3dde_2446_228b95f1d232["allRules"]
  b4590b6e_50d1_c664_5047_3e6e187f6b97 --> dc45eeec_7cda_3dde_2446_228b95f1d232
  1434d447_81c6_eb94_51f8_7685d920df34["mapErrorSeverityToESlint"]
  b4590b6e_50d1_c664_5047_3e6e187f6b97 --> 1434d447_81c6_eb94_51f8_7685d920df34
  e1d806ee_56f0_fe64_b5db_0e28ea3b30a8["recommendedRules"]
  b4590b6e_50d1_c664_5047_3e6e187f6b97 --> e1d806ee_56f0_fe64_b5db_0e28ea3b30a8
  dfe2e27a_b0fb_7783_8470_b0807f5f52fa["recommendedLatestRules"]
  b4590b6e_50d1_c664_5047_3e6e187f6b97 --> dfe2e27a_b0fb_7783_8470_b0807f5f52fa
  47fb9f02_49dd_1d0d_5027_9353a6a77f1e["RulesOfHooks.ts"]
  b4590b6e_50d1_c664_5047_3e6e187f6b97 --> 47fb9f02_49dd_1d0d_5027_9353a6a77f1e
  e023ae51_0bf7_c8b1_0545_8e7304e4bb72["eslint"]
  b4590b6e_50d1_c664_5047_3e6e187f6b97 --> e023ae51_0bf7_c8b1_0545_8e7304e4bb72
  style b4590b6e_50d1_c664_5047_3e6e187f6b97 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
import type {Linter, Rule} from 'eslint';

import ExhaustiveDeps from './rules/ExhaustiveDeps';
import {
  allRules,
  mapErrorSeverityToESlint,
  recommendedRules,
  recommendedLatestRules,
} from './shared/ReactCompiler';
import RulesOfHooks from './rules/RulesOfHooks';

const rules = {
  'exhaustive-deps': ExhaustiveDeps,
  'rules-of-hooks': RulesOfHooks,
  ...Object.fromEntries(
    Object.entries(allRules).map(([name, config]) => [name, config.rule]),
  ),
} satisfies Record<string, Rule.RuleModule>;

const basicRuleConfigs = {
  'react-hooks/rules-of-hooks': 'error',
  'react-hooks/exhaustive-deps': 'warn',
} as const satisfies Linter.RulesRecord;

const recommendedCompilerRuleConfigs = Object.fromEntries(
  Object.entries(recommendedRules).map(([name, ruleConfig]) => {
    return [
      `react-hooks/${name}` as const,
      mapErrorSeverityToESlint(ruleConfig.severity),
    ] as const;
  }),
) as Record<`react-hooks/${string}`, Linter.RuleEntry>;

const recommendedLatestCompilerRuleConfigs = Object.fromEntries(
  Object.entries(recommendedLatestRules).map(([name, ruleConfig]) => {
    return [
      `react-hooks/${name}` as const,
      mapErrorSeverityToESlint(ruleConfig.severity),
    ] as const;
  }),
) as Record<`react-hooks/${string}`, Linter.RuleEntry>;

const recommendedRuleConfigs: Linter.RulesRecord = {
  ...basicRuleConfigs,
  ...recommendedCompilerRuleConfigs,
};
const recommendedLatestRuleConfigs: Linter.RulesRecord = {
  ...basicRuleConfigs,
  ...recommendedLatestCompilerRuleConfigs,
};

const plugins = ['react-hooks'];

type ReactHooksFlatConfig = {
  plugins: {react: any};
  rules: Linter.RulesRecord;
};

const configs = {
  recommended: {
    plugins,
    rules: recommendedRuleConfigs,
  },
  'recommended-latest': {
    plugins,
    rules: recommendedLatestRuleConfigs,
  },
  flat: {} as {
    recommended: ReactHooksFlatConfig;
    'recommended-latest': ReactHooksFlatConfig;
  },
};

const plugin = {
  meta: {
    name: 'eslint-plugin-react-hooks',
    version: '7.0.0',
  },
  rules,
  configs,
};

Object.assign(configs.flat, {
  'recommended-latest': {
    plugins: {'react-hooks': plugin},
    rules: configs['recommended-latest'].rules,
  },
  recommended: {
    plugins: {'react-hooks': plugin},
    rules: configs.recommended.rules,
  },
});

export default plugin;

Domain

Subdomains

Frequently Asked Questions

What does index.ts do?
index.ts is a source file in the react codebase, written in typescript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in index.ts?
index.ts defines 2 function(s): recommendedCompilerRuleConfigs, recommendedLatestCompilerRuleConfigs.
What does index.ts depend on?
index.ts imports 8 module(s): ExhaustiveDeps.ts, ReactCompiler.ts, RulesOfHooks.ts, allRules, eslint, mapErrorSeverityToESlint, recommendedLatestRules, recommendedRules.
Where is index.ts in the architecture?
index.ts is located at packages/eslint-plugin-react-hooks/src/index.ts (domain: BabelCompiler, subdomain: Validation, directory: packages/eslint-plugin-react-hooks/src).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free