Skip to content

Commit 5adf402

Browse files
michaelfaithpoteto
andauthored
feat(eslint-plugin-react-hooks): convert to typescript and package type declarations (#32240)
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please provide enough information so that others can review your pull request. The three fields below are mandatory. Before submitting a pull request, please make sure the following is done: 1. Fork [the repository](https://github.com/facebook/react) and create your branch from `main`. 2. Run `yarn` in the repository root. 3. If you've fixed a bug or added code that should be tested, add tests! 4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch TestName` is helpful in development. 5. Run `yarn test --prod` to test in the production environment. It supports the same options as `yarn test`. 6. If you need a debugger, run `yarn test --debug --watch TestName`, open `chrome://inspect`, and press "Inspect". 7. Format your code with [prettier](https://github.com/prettier/prettier) (`yarn prettier`). 8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only check changed files. 9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`). 10. If you haven't already, complete the CLA. Learn more about contributing: https://reactjs.org/docs/how-to-contribute.html --> ## Summary This change converts the eslint hooks plugin to typescript, which also allows us to include type declarations in the package, for those using [typescript eslint configs](https://eslint.org/blog/2025/01/eslint-v9.18.0-released/#stable-typescript-configuration-file-support). ### Constituent changes that should land before this one - [x] ~#32276 - [x] #32279 - [x] #32283 - [x] #32393 - [x] #32396 Closes #30119 --------- Co-authored-by: Lauren Tan <poteto@users.noreply.github.com>
1 parent 037b25c commit 5adf402

File tree

14 files changed

+574
-857
lines changed

14 files changed

+574
-857
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* This file is purely being used for local jest runs, and doesn't participate in the build process.
3+
*/
4+
'use strict';
5+
6+
module.exports = {
7+
extends: '../../babel.config-ts.js',
8+
};
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
1-
/**
2-
* Copyright (c) Meta Platforms, Inc. and affiliates.
3-
*
4-
* This source code is licensed under the MIT license found in the
5-
* LICENSE file in the root directory of this source tree.
6-
*/
7-
8-
export * from './src/index';
1+
module.exports = require('./src/index.ts');
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
3+
process.env.NODE_ENV = 'development';
4+
5+
module.exports = {
6+
setupFiles: [require.resolve('../../scripts/jest/setupEnvironment.js')],
7+
moduleFileExtensions: ['ts', 'js', 'json'],
8+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './cjs/eslint-plugin-react-hooks';

packages/eslint-plugin-react-hooks/package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,26 @@
1010
"files": [
1111
"LICENSE",
1212
"README.md",
13+
"cjs",
1314
"index.js",
14-
"cjs"
15+
"index.d.ts"
1516
],
1617
"keywords": [
1718
"eslint",
1819
"eslint-plugin",
1920
"eslintplugin",
2021
"react"
2122
],
23+
"scripts": {
24+
"test": "jest",
25+
"typecheck": "tsc --noEmit"
26+
},
2227
"license": "MIT",
2328
"bugs": {
2429
"url": "https://github.com/facebook/react/issues"
2530
},
31+
"main": "./index.js",
32+
"types": "./index.d.ts",
2633
"engines": {
2734
"node": ">=10"
2835
},
@@ -32,6 +39,7 @@
3239
},
3340
"devDependencies": {
3441
"@babel/eslint-parser": "^7.11.4",
42+
"@babel/preset-typescript": "^7.26.0",
3543
"@tsconfig/strictest": "^2.0.5",
3644
"@typescript-eslint/parser-v2": "npm:@typescript-eslint/parser@^2.26.0",
3745
"@typescript-eslint/parser-v3": "npm:@typescript-eslint/parser@^3.10.0",
@@ -45,7 +53,6 @@
4553
"eslint-v7": "npm:eslint@^7.7.0",
4654
"eslint-v9": "npm:eslint@^9.0.0",
4755
"jest": "^29.5.0",
48-
"tsup": "^8.3.5",
4956
"typescript": "^5.4.3"
5057
}
5158
}

0 commit comments

Comments
 (0)