Skip to content

Commit 8eacf0b

Browse files
authored
Knip 8: remove unused exports (#1778)
## Summary: Knip identified these as both unused internally and not exported through our main export files, but please double check! As far as I can tell, a lot of this was copy/pasted from Webapp where there are duplicate declarations there. Author: handeyeco Reviewers: benchristel Required Reviewers: Approved By: benchristel Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald Pull Request URL: #1778
1 parent cf57871 commit 8eacf0b

File tree

9 files changed

+7
-164
lines changed

9 files changed

+7
-164
lines changed

.changeset/rotten-turkeys-pump.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@khanacademy/math-input": patch
3+
"@khanacademy/perseus": patch
4+
"@khanacademy/perseus-linter": patch
5+
---
6+
7+
Remove unused dead code

packages/math-input/src/components/aphrodite-css-transition-group/util.ts

-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {entries} from "@khanacademy/wonder-stuff-core";
22
import {StyleSheet, css} from "aphrodite";
33

4-
import type {InAnimationStyles} from "./types";
54
import type {StyleType} from "@khanacademy/wonder-blocks-core";
65
import type {CSSProperties} from "aphrodite";
76

@@ -88,10 +87,3 @@ export function processStyleType(style?: StyleType): {
8887
className: css(...stylesheetStyles),
8988
};
9089
}
91-
92-
export const createTransition = (styles: InAnimationStyles) => {
93-
// NOTE(kevinb): TypeScript infers the optional properties on `InAnimationStyles`
94-
// as `CSSProperties | undefined`. This is not compatible with `StyleSheet.create`
95-
// which expects `CSSProperties` on the object that's passed in to it.
96-
return StyleSheet.create(styles as any);
97-
};

packages/math-input/src/components/tabbar/item.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,4 @@ function TabbarItem(props: TabItemProps): React.ReactElement {
165165
);
166166
}
167167

168-
export const TabbarItemForTesting = TabbarItem;
169-
170168
export default TabbarItem;

packages/perseus-linter/src/rules/lint-utils.ts

-31
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,3 @@ export function getHostname(url: string): string {
1414
const match = url.match(HOSTNAME);
1515
return match ? match[1] : "";
1616
}
17-
18-
// This list of domains that count as internal domains is from
19-
// webapp/content/models.py and webapp/url_util.py
20-
const internalDomains = {
21-
"khanacademy.org": true,
22-
"www.khanacademy.org": true,
23-
"kasandbox.org": true,
24-
"fastly.kastatic.org": true,
25-
"cdn.kastatic.org": true, // This isn't a link to cdn.kastatic.org
26-
"ka-youtube-converted.storage.googleapis.com": true,
27-
"KA-share.s3.amazonaws.com": true,
28-
"ka-article-iframes.s3.amazonaws.com": true,
29-
"ka-cs-algorithms.s3.amazonaws.com": true,
30-
"ka-cs-challenge-images.s3.amazonaws.com": true,
31-
"ka-cs-scratchpad-audio.s3.amazonaws.com": true,
32-
"ka-exercise-screenshots.s3.amazonaws.com": true,
33-
"ka-exercise-screenshots-2.s3.amazonaws.com": true,
34-
"ka-exercise-screenshots-3.s3.amazonaws.com": true,
35-
"ka-learnstorm.s3.amazonaws.com": true,
36-
"ka-mobile.s3.amazonaws.com": true,
37-
"ka-perseus-graphie.s3.amazonaws.com": true,
38-
"ka-perseus-images.s3.amazonaws.com": true,
39-
} as const;
40-
41-
// Returns true if this URL is relative, or if it is an absolute
42-
// URL with one of the domains listed above as its hostname.
43-
export function isInternalURL(url: string): boolean {
44-
const hostname = getHostname(url);
45-
// eslint-disable-next-line no-prototype-builtins
46-
return hostname === "" || internalDomains.hasOwnProperty(hostname);
47-
}

packages/perseus/src/multi-items/prop-type-builders.ts

-30
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,6 @@ import PropTypes from "prop-types";
1111

1212
import type {Shape} from "./shape-types";
1313

14-
/**
15-
* A recursive PropType that accepts Shape objects, and rejects other objects.
16-
*
17-
* Usage: `propTypes: {shape: shapePropType}`.
18-
*/
19-
export function shapePropType(...args: ReadonlyArray<any>): any {
20-
const itemShape = PropTypes.oneOfType([
21-
PropTypes.shape({
22-
type: PropTypes.oneOf(["content"]).isRequired,
23-
}).isRequired,
24-
PropTypes.shape({
25-
type: PropTypes.oneOf(["hint"]).isRequired,
26-
}).isRequired,
27-
PropTypes.shape({
28-
type: PropTypes.oneOf(["tags"]).isRequired,
29-
}).isRequired,
30-
PropTypes.shape({
31-
type: PropTypes.oneOf(["object"]).isRequired,
32-
shape: PropTypes.objectOf(shapePropType),
33-
}).isRequired,
34-
PropTypes.shape({
35-
type: PropTypes.oneOf(["array"]).isRequired,
36-
elementShape: shapePropType,
37-
}).isRequired,
38-
]);
39-
40-
// @ts-expect-error - TS2556 - A spread argument must either have a tuple type or be passed to a rest parameter.
41-
return itemShape(...args);
42-
}
43-
4414
/**
4515
* Return a PropType that accepts Items of the given shape, and rejects other
4616
* objects.

packages/perseus/src/sigfigs.ts

-45
Original file line numberDiff line numberDiff line change
@@ -15,51 +15,6 @@
1515
* GNU General Public License for more details.
1616
*/
1717

18-
/**
19-
* An object tho both scans floating points to
20-
* determine the number of significant figures.
21-
* and can display a floating point using any number
22-
* of significant figures.
23-
*
24-
* @param s A string representation of a floating point.
25-
*/
26-
export class SignificantFigures {
27-
order: number;
28-
mantissa: string;
29-
positive: boolean;
30-
sigFigs: number;
31-
sigDecs: number;
32-
33-
constructor(s: string) {
34-
this.order = parseOrder(s);
35-
this.mantissa = parseMantissa(s);
36-
this.positive = parseSign(s);
37-
38-
/**
39-
* Get the number of significant figures this object uses.
40-
* Leading zeros are not significant. Traling zeros up to
41-
* and after the decimal point are significant.
42-
* Significant figures is good to know when the number is
43-
* used in multiplication.
44-
*
45-
* @return the number of significant figures.
46-
*/
47-
this.sigFigs = this.mantissa.length;
48-
49-
/**
50-
* Get the least significant decimal this object uses.
51-
* This is useful to know if a number is being used
52-
* in addition.
53-
* 400 - 2 the hundreds place (10^2) is the least significant decimal.
54-
* 75 - 0 the ones place (10^0) is the least significant decimal.
55-
* .543 - -3 the 1/1000's place (10^-3) is the least significant decimal.
56-
*
57-
* @return an integer representing the least significant decimal place.
58-
*/
59-
this.sigDecs = this.order - this.mantissa.length;
60-
}
61-
}
62-
6318
/**
6419
* Format a floating point for display using the specified
6520
* number of significant figures and least significant decimal.

packages/perseus/src/widgets/interactive-graphs/graphs/use-transform.ts

-5
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,3 @@ export function pixelsToVectors(
6868
return [x, y];
6969
});
7070
}
71-
72-
export const useTransformPixelsToVectors = (...pixels: vec.Vector2[]) => {
73-
const graphState = useGraphConfig();
74-
return pixelsToVectors(pixels, graphState);
75-
};

packages/perseus/src/widgets/numeric-input/numeric-input.testdata.ts

-33
Original file line numberDiff line numberDiff line change
@@ -33,39 +33,6 @@ export const question1: PerseusRenderer = {
3333
},
3434
};
3535

36-
export const question2: PerseusRenderer = {
37-
content: "$5008 \\div 4 =$ [[\u2603 numeric-input 1]] ",
38-
images: {},
39-
widgets: {
40-
"numeric-input 1": {
41-
graded: true,
42-
version: {
43-
major: 0,
44-
minor: 0,
45-
},
46-
static: false,
47-
type: "numeric-input",
48-
options: {
49-
coefficient: false,
50-
static: false,
51-
answers: [
52-
{
53-
status: "correct",
54-
maxError: null,
55-
strict: false,
56-
value: 1252,
57-
simplify: "required",
58-
message: "",
59-
},
60-
],
61-
labelText: "What's the answer?",
62-
size: "normal",
63-
},
64-
alignment: "default",
65-
} as NumericInputWidget,
66-
},
67-
};
68-
6936
export const percentageProblem: PerseusRenderer = {
7037
content: "$5008 \\div 4 =$ [[\u2603 numeric-input 1]] ",
7138
images: {},

testing/wait.ts

-10
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,6 @@ export const wait: (options?: WaitOptions) => Promise<void> = ({
8484
return unverifiedWait(normalizedDelay, normalizedCount);
8585
};
8686

87-
const FRAME_DURATION = 17;
88-
89-
/**
90-
* Wait for the given delay.
91-
*
92-
* This will throw if jest.useRealTimers() is not used.
93-
*/
94-
export const waitForAnimationFrame: () => Promise<void> = () =>
95-
wait({delay: FRAME_DURATION});
96-
9787
/**
9888
* Waits for the initial Graphie render.
9989
*

0 commit comments

Comments
 (0)