Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit875f4ce

Browse files
authored
Migrate to TypeScript (#1047)
1 parentb7f56df commit875f4ce

File tree

60 files changed

+11135
-14442
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+11135
-14442
lines changed

‎.babelrc.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ module.exports = {
1212
},
1313
],
1414
"@babel/preset-react",
15-
"@babel/preset-flow",
15+
"@babel/preset-typescript",
1616
],
1717
plugins:[
18-
"@babel/plugin-transform-flow-strip-types",
1918
"@babel/plugin-syntax-dynamic-import",
2019
"@babel/plugin-syntax-import-meta",
2120
test&&"@babel/plugin-transform-react-jsx-source",

‎.codesandbox/ci.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"/examples/submission-errors",
77
"/examples/subscriptions"
88
],
9-
"node":"14"
9+
"node":"18",
10+
"installCommand":"setup"
1011
}

‎.eslintignore‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
-name:Use Node.js ${{ matrix.node_version }}
1313
uses:actions/setup-node@v2
1414
with:
15-
node-version:"14"
15+
node-version:"22"
1616
-name:Prepare env
1717
run:yarn install --ignore-scripts --frozen-lockfile
1818
-name:Run linter
@@ -27,7 +27,7 @@ jobs:
2727
-name:Use Node.js ${{ matrix.node_version }}
2828
uses:actions/setup-node@v2
2929
with:
30-
node-version:"14"
30+
node-version:"22"
3131
-name:Prepare env
3232
run:yarn install --ignore-scripts --frozen-lockfile
3333
-name:Run prettier
@@ -42,7 +42,7 @@ jobs:
4242
-name:Use Node.js ${{ matrix.node_version }}
4343
uses:actions/setup-node@v2
4444
with:
45-
node-version:"14"
45+
node-version:"22"
4646
-name:Prepare env
4747
run:yarn install --ignore-scripts --frozen-lockfile
4848
-name:Run unit tests

‎.gitignore‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ lib
99
es
1010
npm-debug.log
1111
.DS_Store
12-
yarn.lock
1312
.yalc
1413
yalc.lock

‎README.md‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
[<imgsrc="form-nerd-logo.png"align="left"/>](https://formnerd.co/react-final-form-readme)**You build great forms, but do you know HOW users use your forms?[Find out with Form Nerd!](https://formnerd.co/react-final-form-readme) Professional analytics from the creator of React Final Form.**
2-
3-
---
4-
5-
💰**Wanna get paid the big bucks writing React?[Take this quiz](https://triplebyte.com/a/V6j0KPS/rff) and get offers from top tech companies!** 💰
6-
7-
---
8-
91
#🏁 React Final Form
102

113
[![React Final Form](banner.png)](https://final-form.org/react)

‎eslint.config.js‎

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
importjsfrom"@eslint/js";
2+
importtypescriptParserfrom"@typescript-eslint/parser";
3+
importtypescriptPluginfrom"@typescript-eslint/eslint-plugin";
4+
importreactPluginfrom"eslint-plugin-react";
5+
importreactHooksfrom"eslint-plugin-react-hooks";
6+
importjsxA11yfrom"eslint-plugin-jsx-a11y";
7+
8+
// Manually defined globals to avoid issues with the 'globals' package
9+
constbrowserGlobals={
10+
window:"readonly",
11+
document:"readonly",
12+
navigator:"readonly",
13+
console:"readonly",
14+
fetch:"readonly",
15+
setTimeout:"readonly",
16+
HTMLInputElement:"readonly",
17+
HTMLElement:"readonly",
18+
};
19+
constnodeGlobals={
20+
process:"readonly",
21+
require:"readonly",
22+
module:"readonly",
23+
exports:"writable",
24+
__dirname:"readonly",
25+
__filename:"readonly",
26+
global:"readonly",
27+
console:"readonly",
28+
};
29+
constjestGlobals={
30+
jest:"readonly",
31+
describe:"readonly",
32+
it:"readonly",
33+
expect:"readonly",
34+
afterEach:"readonly",
35+
beforeEach:"readonly",
36+
test:"readonly",
37+
beforeAll:"readonly",
38+
afterAll:"readonly",
39+
};
40+
41+
exportdefault[
42+
// Base config for all JS/TS files (can be overridden)
43+
{
44+
ignores:[
45+
"node_modules/**",
46+
"dist/**",
47+
"coverage/**",
48+
"*.min.js",
49+
"examples/**",
50+
],
51+
},
52+
js.configs.recommended,// Apply ESLint recommended rules globally (respecting ignores)
53+
54+
// Configuration for TypeScript files in src/
55+
{
56+
files:["src/**/*.{ts,tsx}"],
57+
ignores:["**/*.test.ts","**/*.test.tsx"],
58+
languageOptions:{
59+
parser:typescriptParser,
60+
parserOptions:{
61+
ecmaFeatures:{jsx:true},
62+
ecmaVersion:"latest",
63+
sourceType:"module",
64+
project:"./tsconfig.json",// Project-aware linting for src files
65+
},
66+
globals:{
67+
...browserGlobals,
68+
...nodeGlobals,
69+
...jestGlobals,
70+
es2021:true,
71+
},
72+
},
73+
plugins:{
74+
"@typescript-eslint":typescriptPlugin,
75+
react:reactPlugin,
76+
"react-hooks":reactHooks,
77+
"jsx-a11y":jsxA11y,
78+
},
79+
rules:{
80+
...typescriptPlugin.configs.recommended.rules,
81+
...reactPlugin.configs.recommended.rules,
82+
"react/react-in-jsx-scope":"off",
83+
"react/jsx-uses-react":"off",
84+
"jsx-a11y/href-no-hash":"off",
85+
"react-hooks/rules-of-hooks":"error",
86+
"react-hooks/exhaustive-deps":"warn",
87+
"@typescript-eslint/no-unused-vars":[
88+
"warn",
89+
{argsIgnorePattern:"^_",varsIgnorePattern:"^_"},
90+
],
91+
"@typescript-eslint/no-explicit-any":"off",
92+
"@typescript-eslint/no-non-null-assertion":"off",
93+
"@typescript-eslint/explicit-module-boundary-types":"off",
94+
"@typescript-eslint/no-unsafe-function-type":"off",
95+
"react/no-children-prop":"off",
96+
"@typescript-eslint/no-unused-expressions":"off",
97+
"no-undef":"off",// TypeScript handles this for .ts/.tsx
98+
},
99+
settings:{
100+
react:{version:"detect"},
101+
},
102+
},
103+
104+
// Configuration for TypeScript test files in typescript/ (for dtslint, no project parsing)
105+
{
106+
files:["typescript/**/*.ts","typescript/**/*.tsx"],
107+
languageOptions:{
108+
parser:typescriptParser,
109+
parserOptions:{
110+
ecmaFeatures:{jsx:true},// Allow JSX in .tsx test files
111+
ecmaVersion:"latest",
112+
sourceType:"module",
113+
},
114+
globals:{
115+
...browserGlobals,
116+
...nodeGlobals,
117+
...jestGlobals,
118+
es2021:true,
119+
},// General globals for TS test files
120+
},
121+
plugins:{
122+
"@typescript-eslint":typescriptPlugin,
123+
// Add other plugins if relevant for these test files, e.g., react if they use React
124+
},
125+
rules:{
126+
// Lighter ruleset for .d.ts test files or general TS syntax checking
127+
"@typescript-eslint/no-explicit-any":"off",
128+
"@typescript-eslint/no-unused-vars":"off",
129+
"no-unused-vars":"off",
130+
"no-undef":"off",// Disable no-undef for TypeScript files
131+
},
132+
},
133+
134+
// Configuration for JavaScript files (e.g., .js test files in src/, config files)
135+
{
136+
files:["**/*.js","**/*.jsx"],
137+
ignores:["examples/**"],
138+
languageOptions:{
139+
ecmaVersion:"latest",
140+
sourceType:"module",
141+
parserOptions:{
142+
ecmaFeatures:{
143+
jsx:true,
144+
},
145+
},
146+
globals:{
147+
...browserGlobals,
148+
...nodeGlobals,
149+
...jestGlobals,
150+
es2021:true,
151+
},
152+
},
153+
plugins:{
154+
react:reactPlugin,
155+
},
156+
rules:{
157+
"no-undef":"error",
158+
"react/jsx-uses-vars":"warn",
159+
"react/react-in-jsx-scope":"off",
160+
"no-unused-vars":["warn",{argsIgnorePattern:"^_"}],// Enforce _ prefix for unused vars in JS files
161+
},
162+
},
163+
164+
// Specific overrides for ALL test files (JS and TS)
165+
{
166+
files:["**/*.test.js","**/*.test.jsx","**/*.test.ts","**/*.test.tsx"],
167+
rules:{
168+
"no-unused-vars":"off",
169+
"@typescript-eslint/no-unused-vars":"off",
170+
},
171+
},
172+
];

‎examples/async-redux-submission/asyncSubmissionMiddleware.js‎

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,18 @@ const submit = async (values) => {
1111
};
1212

1313
/** This is to mimic the behavior of one of the various Redux async middlewares */
14-
constasyncSubmissionMiddleware=
15-
(store)=>
16-
(next:Next)=>
17-
(action:Action):State=>{
18-
if(action&&action.type===REGISTER){
19-
submit(action.payload).then(
20-
()=>store.dispatch({type:REGISTER_SUCCESS}),
21-
(errors)=>{
22-
// NOTE!! We are passing REGISTER_SUCCESS here because 🏁 Final Form expects
23-
// submit errors to come back in a *resolved* promise.
24-
store.dispatch({type:REGISTER_SUCCESS,payload:errors});
25-
},
26-
);
27-
}
28-
returnnext(action);
29-
};
14+
constasyncSubmissionMiddleware=(store)=>(next)=>(action)=>{
15+
if(action&&action.type===REGISTER){
16+
submit(action.payload).then(
17+
()=>store.dispatch({type:REGISTER_SUCCESS}),
18+
(errors)=>{
19+
// NOTE!! We are passing REGISTER_SUCCESS here because 🏁 Final Form expects
20+
// submit errors to come back in a *resolved* promise.
21+
store.dispatch({type:REGISTER_SUCCESS,payload:errors});
22+
},
23+
);
24+
}
25+
returnnext(action);
26+
};
3027

3128
exportdefaultasyncSubmissionMiddleware;

‎examples/async-redux-submission/store.js‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@ import asyncSubmissionMiddleware from "./asyncSubmissionMiddleware";
55

66
constreduxPromiseListener=createReduxPromiseListener();
77

8-
constlogger=
9-
(store)=>
10-
(next:Next)=>
11-
(action:Action):State=>{
12-
console.log(action);
13-
returnnext(action);
14-
};
8+
constlogger=(store)=>(next)=>(action)=>{
9+
console.log(action);
10+
returnnext(action);
11+
};
1512

1613
constreducer=combineReducers({
1714
registration,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp