diff --git a/packages/eslint-plugin-react-hooks/src/index.ts b/packages/eslint-plugin-react-hooks/src/index.ts index 924299d89894..b2478a0af5c7 100644 --- a/packages/eslint-plugin-react-hooks/src/index.ts +++ b/packages/eslint-plugin-react-hooks/src/index.ts @@ -6,6 +6,8 @@ */ import type {Linter, Rule} from 'eslint'; +import {createRequire} from 'module'; + import ExhaustiveDeps from './rules/ExhaustiveDeps'; import { allRules, @@ -15,6 +17,11 @@ import { } from './shared/ReactCompiler'; import RulesOfHooks from './rules/RulesOfHooks'; +// Use createRequire to load package.json version at runtime +// This ensures the version is always in sync with package.json +const require = createRequire(import.meta.url); +const pkg = require('../package.json'); + const rules = { 'exhaustive-deps': ExhaustiveDeps, 'rules-of-hooks': RulesOfHooks, @@ -80,7 +87,7 @@ const configs = { const plugin = { meta: { name: 'eslint-plugin-react-hooks', - version: '7.0.0', + version: pkg.version, }, rules, configs, diff --git a/packages/eslint-plugin-react-hooks/tsconfig.json b/packages/eslint-plugin-react-hooks/tsconfig.json index c5d8847f1ec4..b6c33cc6c0b7 100644 --- a/packages/eslint-plugin-react-hooks/tsconfig.json +++ b/packages/eslint-plugin-react-hooks/tsconfig.json @@ -1,12 +1,13 @@ { "extends": "@tsconfig/strictest/tsconfig.json", "compilerOptions": { - "module": "ES2015", - "target": "ES2015", + "module": "ES2020", + "target": "ES2020", "moduleResolution": "Bundler", "lib": ["ES2020", "dom"], "sourceMap": false, "types": ["estree-jsx", "node"], + "resolveJsonModule": true, "downlevelIteration": true, "paths": { "babel-plugin-react-compiler": ["../../compiler/packages/babel-plugin-react-compiler/src"]