Skip to content

Commit 23a8585

Browse files
authoredJan 9, 2024
Deflowify wonder-stuff (#1001)
## Summary: We're finished the TypeScript migration so we no longer need Flow related stuff kicking around. Issue: None ## Test plan: - yarn test - cd packages/eslint-plugin-khan - yarn test Author: kevinbarabash Reviewers: jeresig, somewhatabstract Required Reviewers: Approved By: jeresig, somewhatabstract Checks: ✅ codecov/project, ✅ Test (macos-latest, 20.x), ✅ CodeQL, ✅ Lint, typecheck, and coverage check (ubuntu-latest, 20.x), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ✅ gerald, ⏭️ dependabot, ✅ Analyze (javascript) Pull Request URL: #1001

34 files changed

+27
-1513
lines changed
 

‎.changeset/calm-boxes-exist.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@khanacademy/eslint-plugin": major
3+
---
4+
5+
Remove Flow related rules

‎.changeset/light-apes-matter.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@khanacademy/wonder-stuff-render-environment-jsdom": patch
3+
"@khanacademy/wonder-stuff-render-server": patch
4+
"@khanacademy/wonder-stuff-server": patch
5+
"@khanacademy/wonder-stuff-core": patch
6+
---
7+
8+
Update comments to no longer reference Flow

‎.codecov.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ coverage:
55

66
status:
77
project:
8-
default: on
8+
default: true
99
patch:
1010
default: off
1111
changes:
@@ -14,14 +14,13 @@ coverage:
1414
comment:
1515
layout: "header, reach, diff, flags, files, footer"
1616
behavior: default
17-
require_changes: no
18-
require_base: no
19-
require_head: yes
17+
require_changes: false
18+
require_base: false
19+
require_head: true
2020

2121
ignore:
2222
- "build-settings/*.js"
2323
- "utils/*.js"
2424
- "packages/**/dist/index.js"
2525
- "packages/**/types/**/*.ts"
2626
- "packages/**/examples/**/*.ts"
27-
- "packages/**/*.flowtest.js"

‎CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ We love code reviews. If there are open pull requests, please feel free to revie
4444

4545
#### Automated
4646

47-
To ensure code quality, we use prettier, flow, eslint, and jest. These are all executed automatically on commit, so don't worry if you forget to run them before you commit. They are also executed when you submit, edit, or push to a pull request to ensure the contribution meets our code quality standard.
47+
To ensure code quality, we use prettier, TypeScript, eslint, and jest. These are all executed automatically on commit, so don't worry if you forget to run them before you commit. They are also executed when you submit, edit, or push to a pull request to ensure the contribution meets our code quality standard.
4848

4949
To execute these operations outside of a pull request or commit operation, you can use `yarn`.
5050

51-
- `yarn flow`
51+
- `yarn typecheck`
5252
- `yarn lint`
5353
- `yarn test`
5454

‎packages/eslint-plugin-khan/README.md

-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ eslint plugin with our set of custom rules for various things
66

77
## Rules
88

9-
- [khan/flow-array-type-style](docs/flow-array-type-style.md)
10-
- [khan/flow-exact-props](docs/flow-exact-props.md)
11-
- [khan/flow-exact-state](docs/flow-exact-state.md)
12-
- [khan/flow-no-one-tuple](docs/flow-no-one-tuple.md)
13-
- [khan/imports-requiring-flow](docs/imports-requiring-flow.md)
149
- [khan/jest-async-use-real-timers](docs/jest-async-use-real-timers.md)
1510
- [khan/jest-enzyme-matchers](docs/jest-enzyme-matchers.md)
1611
- [khan/react-no-method-jsx-attribute](docs/react-no-method-jsx-attribute.md)

‎packages/eslint-plugin-khan/babel.config.js

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// NOTE(kevinb): This should only be used by eslint-plugin-khan
33
module.exports = {
44
presets: [
5-
"@babel/preset-flow",
65
[
76
"@babel/preset-env",
87
{

‎packages/eslint-plugin-khan/docs/flow-array-type-style.md

-29
This file was deleted.

‎packages/eslint-plugin-khan/docs/flow-exact-props.md

-44
This file was deleted.

‎packages/eslint-plugin-khan/docs/flow-exact-state.md

-38
This file was deleted.

‎packages/eslint-plugin-khan/docs/flow-no-one-tuple.md

-33
This file was deleted.

‎packages/eslint-plugin-khan/docs/imports-requiring-flow.md

-107
This file was deleted.

‎packages/eslint-plugin-khan/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"devDependencies": {
2121
"@babel/eslint-parser": "^7.22.15",
2222
"@babel/preset-env": "^7.23.2",
23-
"@babel/preset-flow": "^7.22.15",
2423
"@babel/preset-react": "^7.22.15",
2524
"@swc-node/register": "^1.6.8",
2625
"@swc/core": "^1.3.93",

‎packages/eslint-plugin-khan/src/rules/flow-array-type-style.js

-44
This file was deleted.

‎packages/eslint-plugin-khan/src/rules/flow-exact-props.js

-76
This file was deleted.

‎packages/eslint-plugin-khan/src/rules/flow-exact-state.js

-66
This file was deleted.

‎packages/eslint-plugin-khan/src/rules/flow-no-one-tuple.js

-44
This file was deleted.

‎packages/eslint-plugin-khan/src/rules/imports-requiring-flow.js

-130
This file was deleted.

‎packages/eslint-plugin-khan/src/rules/index.ts

-12
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ import reactNoSubscriptionsBeforeMount from "./react-no-subscriptions-before-mou
77
import reactSvgPathPrecision from "./react-svg-path-precision";
88
import syncTag from "./sync-tag";
99
import tsNoErrorSupressions from "./ts-no-error-suppressions";
10-
11-
import flowArrayTypeStyle from "./flow-array-type-style";
12-
import flowExactProps from "./flow-exact-props";
13-
import flowExactState from "./flow-exact-state";
14-
import flowNoOneTuple from "./flow-no-one-tuple";
15-
import importsRequiringFlow from "./imports-requiring-flow";
1610
import jestEnzymeMatchers from "./jest-enzyme-matchers";
1711

1812
export default {
@@ -25,11 +19,5 @@ export default {
2519
"react-no-subscriptions-before-mount": reactNoSubscriptionsBeforeMount,
2620
"react-svg-path-precision": reactSvgPathPrecision,
2721
"sync-tag": syncTag,
28-
29-
"flow-array-type-style": flowArrayTypeStyle,
30-
"flow-exact-props": flowExactProps,
31-
"flow-exact-state": flowExactState,
32-
"flow-no-one-tuple": flowNoOneTuple,
33-
"imports-requiring-flow": importsRequiringFlow,
3422
"jest-enzyme-matchers": jestEnzymeMatchers,
3523
};

‎packages/eslint-plugin-khan/test/rules/flow-array-type-style.test.js

-40
This file was deleted.

‎packages/eslint-plugin-khan/test/rules/flow-exact-props.test.js

-78
This file was deleted.

‎packages/eslint-plugin-khan/test/rules/flow-exact-state.test.js

-75
This file was deleted.

‎packages/eslint-plugin-khan/test/rules/flow-no-one-tuple.test.js

-44
This file was deleted.

‎packages/eslint-plugin-khan/test/rules/imports-requiring-flow.test.js

-372
This file was deleted.

‎packages/wonder-stuff-core/src/__tests__/entries.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @flow
21
import {entries} from "../entries";
32

43
describe("#entries", () => {

‎packages/wonder-stuff-core/src/type-predicates.js.flow

-14
This file was deleted.

‎packages/wonder-stuff-core/src/types.js.flow

-34
This file was deleted.

‎packages/wonder-stuff-render-environment-jsdom/src/types.js.flow

-111
This file was deleted.

‎packages/wonder-stuff-render-server/src/handlers/__tests__/make-render-handler.test.ts

+6-75
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ describe("#makeRenderHandler", () => {
5252
const handler = makeRenderHandler(fakeRenderEnvironment);
5353

5454
// Act
55-
/**
56-
* $FlowIgnore[incompatible-call] Middleware<Request, Response>
57-
* can mean two different call signatures, and sadly, they both
58-
* have completely different argument type ordering, which
59-
* totally confused flow here.
60-
*/
6155
await handler(fakeRequest, fakeResponse, nextFn);
6256

6357
// Assert
@@ -92,12 +86,6 @@ describe("#makeRenderHandler", () => {
9286
const handler = makeRenderHandler(fakeRenderEnvironment);
9387

9488
// Act
95-
/**
96-
* $FlowIgnore[incompatible-call] Middleware<Request, Response>
97-
* can mean two different call signatures, and sadly, they both
98-
* have completely different argument type ordering, which
99-
* totally confused flow here.
100-
*/
10189
const underTest = handler(fakeRequest, fakeResponse, nextFn);
10290

10391
// Assert
@@ -136,12 +124,6 @@ describe("#makeRenderHandler", () => {
136124
const handler = makeRenderHandler(fakeRenderEnvironment);
137125

138126
// Act
139-
/**
140-
* $FlowIgnore[incompatible-call] Middleware<Request, Response>
141-
* can mean two different call signatures, and sadly, they both
142-
* have completely different argument type ordering, which
143-
* totally confused flow here.
144-
*/
145127
const underTest = handler(fakeRequest, fakeResponse, nextFn);
146128

147129
// Assert
@@ -185,12 +167,6 @@ describe("#makeRenderHandler", () => {
185167
const handler = makeRenderHandler(fakeRenderEnvironment);
186168

187169
// Act
188-
/**
189-
* $FlowIgnore[incompatible-call] Middleware<Request, Response>
190-
* can mean two different call signatures, and sadly, they both
191-
* have completely different argument type ordering, which
192-
* totally confused flow here.
193-
*/
194170
await handler(fakeRequest, fakeResponse, nextFn);
195171

196172
// Assert
@@ -238,14 +214,6 @@ describe("#makeRenderHandler", () => {
238214
addLabel: jest.fn(),
239215
} as any);
240216
const handler = makeRenderHandler(fakeRenderEnvironment);
241-
/**
242-
* $FlowIgnore[incompatible-call]
243-
*
244-
* Middleware<Request, Response> can mean two different
245-
* call signatures, and sadly, they both have completely
246-
* different argument type ordering, which totally confused
247-
* flow here.
248-
*/
249217
await handler(fakeRequest, fakeResponse, nextFn);
250218
const underTest =
251219
fakeRenderEnvironment.render.mock.calls[0][1].trace;
@@ -297,12 +265,7 @@ describe("#makeRenderHandler", () => {
297265
const handler = makeRenderHandler(fakeRenderEnvironment);
298266

299267
// Act
300-
/**
301-
* $FlowIgnore[incompatible-call] Middleware<Request, Response>
302-
* can mean two different call signatures, and sadly, they both
303-
* have completely different argument type ordering, which
304-
* totally confused flow here.
305-
*/
268+
306269
await handler(fakeRequest, fakeResponse, nextFn);
307270

308271
// Assert
@@ -362,13 +325,6 @@ describe("#makeRenderHandler", () => {
362325
);
363326

364327
// Act
365-
/**
366-
* $FlowIgnore[incompatible-call]
367-
* Middleware<Request, Response> can mean two different
368-
* call signatures, and sadly, they both have completely
369-
* different argument type ordering, which totally confused
370-
* flow here.
371-
*/
372328
await handler(fakeRequest, fakeResponse, nextFn);
373329

374330
// Assert
@@ -417,12 +373,7 @@ describe("#makeRenderHandler", () => {
417373
const handler = makeRenderHandler(fakeRenderEnvironment);
418374

419375
// Act
420-
/**
421-
* $FlowIgnore[incompatible-call] Middleware<Request, Response>
422-
* can mean two different call signatures, and sadly, they both
423-
* have completely different argument type ordering, which
424-
* totally confused flow here.
425-
*/
376+
426377
await handler(fakeRequest, fakeResponse, nextFn);
427378

428379
// Assert
@@ -459,12 +410,7 @@ describe("#makeRenderHandler", () => {
459410
const handler = makeRenderHandler(fakeRenderEnvironment);
460411

461412
// Act
462-
/**
463-
* $FlowIgnore[incompatible-call] Middleware<Request, Response>
464-
* can mean two different call signatures, and sadly, they both
465-
* have completely different argument type ordering, which
466-
* totally confused flow here.
467-
*/
413+
468414
await handler(fakeRequest, fakeResponse, nextFn);
469415

470416
// Assert
@@ -501,12 +447,7 @@ describe("#makeRenderHandler", () => {
501447
const handler = makeRenderHandler(fakeRenderEnvironment);
502448

503449
// Act
504-
/**
505-
* $FlowIgnore[incompatible-call] Middleware<Request, Response>
506-
* can mean two different call signatures, and sadly, they both
507-
* have completely different argument type ordering, which
508-
* totally confused flow here.
509-
*/
450+
510451
await handler(fakeRequest, fakeResponse, nextFn);
511452

512453
// Assert
@@ -550,12 +491,7 @@ describe("#makeRenderHandler", () => {
550491
const handleErrorSpy = jest.spyOn(HandleError, "handleError");
551492

552493
// Act
553-
/**
554-
* $FlowIgnore[incompatible-call] Middleware<Request, Response>
555-
* can mean two different call signatures, and sadly, they both
556-
* have completely different argument type ordering, which
557-
* totally confused flow here.
558-
*/
494+
559495
await handler(fakeRequest, fakeResponse, nextFn);
560496

561497
// Assert
@@ -603,12 +539,7 @@ describe("#makeRenderHandler", () => {
603539
);
604540

605541
// Act
606-
/**
607-
* $FlowIgnore[incompatible-call] Middleware<Request, Response>
608-
* can mean two different call signatures, and sadly, they both
609-
* have completely different argument type ordering, which
610-
* totally confused flow here.
611-
*/
542+
612543
await handler(fakeRequest, fakeResponse, nextFn);
613544

614545
// Assert

‎packages/wonder-stuff-render-server/src/handlers/handle-error.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const handleError = async (
4242

4343
/**
4444
* The calling code should handle if the original request was valid or
45-
* not, so we just appease flow here.
45+
* not, so we just appease TypeScript here.
4646
*/
4747
const requestURL = typeof req.query.url === "string" ? req.query.url : "";
4848

‎packages/wonder-stuff-render-server/src/handlers/make-render-handler.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @flow
21
import type {RequestHandler, NextFunction} from "express";
32
import {KindError, Errors} from "@khanacademy/wonder-stuff-core";
43
import {trace, getLogger} from "@khanacademy/wonder-stuff-server";

‎packages/wonder-stuff-server/src/middleware/__tests__/request-authentication.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @flow
21
import {secret} from "@khanacademy/wonder-stuff-core";
32
import * as GetRuntimeMode from "../../get-runtime-mode";
43
import * as GetLogger from "../../get-logger";

‎packages/wonder-stuff-server/src/trace-impl.ts

-4
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@ export const traceImpl = (
100100

101101
/**
102102
* Add some session information to the span as labels.
103-
*
104-
* Flow doesn't trust the inexact objects returned by memoryUsage()
105-
* and so `getDelta` isn't typed to handle that. Have to rethink
106-
* how to make that work.
107103
*/
108104
// @ts-expect-error [FEI-5011] - TS2345 - Argument of type 'MemoryUsage' is not assignable to parameter of type 'NumberObj'.
109105
addLabel("/memory/delta", getDelta(beforeMemory, afterMemory));

‎packages/wonder-stuff-server/src/trace.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const trace: ITrace = (
6262
Object.prototype.hasOwnProperty.call(requestOrLogger, "url")
6363
) {
6464
// We have done a little check to make sure this is either null
65-
// or a request, so just tell Flow it's OK.
65+
// or a request, so just tell TypeScript it's OK.
6666
const logger = getLogger(requestOrLogger);
6767
return traceImpl(logger, action, message, tracer);
6868
}

‎yarn.lock

-24
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,6 @@
408408
dependencies:
409409
"@babel/helper-plugin-utils" "^7.8.3"
410410

411-
"@babel/plugin-syntax-flow@^7.22.5":
412-
version "7.22.5"
413-
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.22.5.tgz#163b820b9e7696ce134df3ee716d9c0c98035859"
414-
integrity sha512-9RdCl0i+q0QExayk2nOS7853w08yLucnnPML6EN9S8fgMPVtdLDCdx/cOQ/i44Lb9UeQX9A35yaqBBOMMZxPxQ==
415-
dependencies:
416-
"@babel/helper-plugin-utils" "^7.22.5"
417-
418411
"@babel/plugin-syntax-import-assertions@^7.22.5":
419412
version "7.22.5"
420413
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.22.5.tgz#07d252e2aa0bc6125567f742cd58619cb14dce98"
@@ -647,14 +640,6 @@
647640
"@babel/helper-plugin-utils" "^7.22.5"
648641
"@babel/plugin-syntax-export-namespace-from" "^7.8.3"
649642

650-
"@babel/plugin-transform-flow-strip-types@^7.22.5":
651-
version "7.22.5"
652-
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.22.5.tgz#0bb17110c7bf5b35a60754b2f00c58302381dee2"
653-
integrity sha512-tujNbZdxdG0/54g/oua8ISToaXTFBf8EnSb5PgQSciIXWOWKX3S4+JR7ZE9ol8FZwf9kxitzkGQ+QWeov/mCiA==
654-
dependencies:
655-
"@babel/helper-plugin-utils" "^7.22.5"
656-
"@babel/plugin-syntax-flow" "^7.22.5"
657-
658643
"@babel/plugin-transform-for-of@^7.22.15":
659644
version "7.22.15"
660645
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.22.15.tgz#f64b4ccc3a4f131a996388fae7680b472b306b29"
@@ -1046,15 +1031,6 @@
10461031
core-js-compat "^3.31.0"
10471032
semver "^6.3.1"
10481033

1049-
"@babel/preset-flow@^7.22.15":
1050-
version "7.22.15"
1051-
resolved "https://registry.yarnpkg.com/@babel/preset-flow/-/preset-flow-7.22.15.tgz#30318deb9b3ebd9f5738e96da03a531e0cd3165d"
1052-
integrity sha512-dB5aIMqpkgbTfN5vDdTRPzjqtWiZcRESNR88QYnoPR+bmdYoluOzMX9tQerTv0XzSgZYctPfO1oc0N5zdog1ew==
1053-
dependencies:
1054-
"@babel/helper-plugin-utils" "^7.22.5"
1055-
"@babel/helper-validator-option" "^7.22.15"
1056-
"@babel/plugin-transform-flow-strip-types" "^7.22.5"
1057-
10581034
"@babel/preset-modules@0.1.6-no-external-plugins":
10591035
version "0.1.6-no-external-plugins"
10601036
resolved "https://registry.yarnpkg.com/@babel/preset-modules/-/preset-modules-0.1.6-no-external-plugins.tgz#ccb88a2c49c817236861fee7826080573b8a923a"

0 commit comments

Comments
 (0)
Please sign in to comment.