diff --git a/.changeset/rotten-turkeys-pump.md b/.changeset/rotten-turkeys-pump.md new file mode 100644 index 0000000000..dc9138961f --- /dev/null +++ b/.changeset/rotten-turkeys-pump.md @@ -0,0 +1,7 @@ +--- +"@khanacademy/math-input": patch +"@khanacademy/perseus": patch +"@khanacademy/perseus-linter": patch +--- + +Remove unused dead code diff --git a/packages/math-input/src/components/aphrodite-css-transition-group/util.ts b/packages/math-input/src/components/aphrodite-css-transition-group/util.ts index 9f5b6cb635..3b064ed3d9 100644 --- a/packages/math-input/src/components/aphrodite-css-transition-group/util.ts +++ b/packages/math-input/src/components/aphrodite-css-transition-group/util.ts @@ -1,7 +1,6 @@ import {entries} from "@khanacademy/wonder-stuff-core"; import {StyleSheet, css} from "aphrodite"; -import type {InAnimationStyles} from "./types"; import type {StyleType} from "@khanacademy/wonder-blocks-core"; import type {CSSProperties} from "aphrodite"; @@ -88,10 +87,3 @@ export function processStyleType(style?: StyleType): { className: css(...stylesheetStyles), }; } - -export const createTransition = (styles: InAnimationStyles) => { - // NOTE(kevinb): TypeScript infers the optional properties on `InAnimationStyles` - // as `CSSProperties | undefined`. This is not compatible with `StyleSheet.create` - // which expects `CSSProperties` on the object that's passed in to it. - return StyleSheet.create(styles as any); -}; diff --git a/packages/math-input/src/components/tabbar/item.tsx b/packages/math-input/src/components/tabbar/item.tsx index e8683fcb3d..a88464f364 100644 --- a/packages/math-input/src/components/tabbar/item.tsx +++ b/packages/math-input/src/components/tabbar/item.tsx @@ -165,6 +165,4 @@ function TabbarItem(props: TabItemProps): React.ReactElement { ); } -export const TabbarItemForTesting = TabbarItem; - export default TabbarItem; diff --git a/packages/perseus-linter/src/rules/lint-utils.ts b/packages/perseus-linter/src/rules/lint-utils.ts index 99c08335c9..b3e29743cf 100644 --- a/packages/perseus-linter/src/rules/lint-utils.ts +++ b/packages/perseus-linter/src/rules/lint-utils.ts @@ -14,34 +14,3 @@ export function getHostname(url: string): string { const match = url.match(HOSTNAME); return match ? match[1] : ""; } - -// This list of domains that count as internal domains is from -// webapp/content/models.py and webapp/url_util.py -const internalDomains = { - "khanacademy.org": true, - "www.khanacademy.org": true, - "kasandbox.org": true, - "fastly.kastatic.org": true, - "cdn.kastatic.org": true, // This isn't a link to cdn.kastatic.org - "ka-youtube-converted.storage.googleapis.com": true, - "KA-share.s3.amazonaws.com": true, - "ka-article-iframes.s3.amazonaws.com": true, - "ka-cs-algorithms.s3.amazonaws.com": true, - "ka-cs-challenge-images.s3.amazonaws.com": true, - "ka-cs-scratchpad-audio.s3.amazonaws.com": true, - "ka-exercise-screenshots.s3.amazonaws.com": true, - "ka-exercise-screenshots-2.s3.amazonaws.com": true, - "ka-exercise-screenshots-3.s3.amazonaws.com": true, - "ka-learnstorm.s3.amazonaws.com": true, - "ka-mobile.s3.amazonaws.com": true, - "ka-perseus-graphie.s3.amazonaws.com": true, - "ka-perseus-images.s3.amazonaws.com": true, -} as const; - -// Returns true if this URL is relative, or if it is an absolute -// URL with one of the domains listed above as its hostname. -export function isInternalURL(url: string): boolean { - const hostname = getHostname(url); - // eslint-disable-next-line no-prototype-builtins - return hostname === "" || internalDomains.hasOwnProperty(hostname); -} diff --git a/packages/perseus/src/multi-items/prop-type-builders.ts b/packages/perseus/src/multi-items/prop-type-builders.ts index 7c3d7d2e7a..397eba865c 100644 --- a/packages/perseus/src/multi-items/prop-type-builders.ts +++ b/packages/perseus/src/multi-items/prop-type-builders.ts @@ -11,36 +11,6 @@ import PropTypes from "prop-types"; import type {Shape} from "./shape-types"; -/** - * A recursive PropType that accepts Shape objects, and rejects other objects. - * - * Usage: `propTypes: {shape: shapePropType}`. - */ -export function shapePropType(...args: ReadonlyArray): any { - const itemShape = PropTypes.oneOfType([ - PropTypes.shape({ - type: PropTypes.oneOf(["content"]).isRequired, - }).isRequired, - PropTypes.shape({ - type: PropTypes.oneOf(["hint"]).isRequired, - }).isRequired, - PropTypes.shape({ - type: PropTypes.oneOf(["tags"]).isRequired, - }).isRequired, - PropTypes.shape({ - type: PropTypes.oneOf(["object"]).isRequired, - shape: PropTypes.objectOf(shapePropType), - }).isRequired, - PropTypes.shape({ - type: PropTypes.oneOf(["array"]).isRequired, - elementShape: shapePropType, - }).isRequired, - ]); - - // @ts-expect-error - TS2556 - A spread argument must either have a tuple type or be passed to a rest parameter. - return itemShape(...args); -} - /** * Return a PropType that accepts Items of the given shape, and rejects other * objects. diff --git a/packages/perseus/src/sigfigs.ts b/packages/perseus/src/sigfigs.ts index 9d237d308b..fef645839f 100644 --- a/packages/perseus/src/sigfigs.ts +++ b/packages/perseus/src/sigfigs.ts @@ -15,51 +15,6 @@ * GNU General Public License for more details. */ -/** - * An object tho both scans floating points to - * determine the number of significant figures. - * and can display a floating point using any number - * of significant figures. - * - * @param s A string representation of a floating point. - */ -export class SignificantFigures { - order: number; - mantissa: string; - positive: boolean; - sigFigs: number; - sigDecs: number; - - constructor(s: string) { - this.order = parseOrder(s); - this.mantissa = parseMantissa(s); - this.positive = parseSign(s); - - /** - * Get the number of significant figures this object uses. - * Leading zeros are not significant. Traling zeros up to - * and after the decimal point are significant. - * Significant figures is good to know when the number is - * used in multiplication. - * - * @return the number of significant figures. - */ - this.sigFigs = this.mantissa.length; - - /** - * Get the least significant decimal this object uses. - * This is useful to know if a number is being used - * in addition. - * 400 - 2 the hundreds place (10^2) is the least significant decimal. - * 75 - 0 the ones place (10^0) is the least significant decimal. - * .543 - -3 the 1/1000's place (10^-3) is the least significant decimal. - * - * @return an integer representing the least significant decimal place. - */ - this.sigDecs = this.order - this.mantissa.length; - } -} - /** * Format a floating point for display using the specified * number of significant figures and least significant decimal. diff --git a/packages/perseus/src/widgets/interactive-graphs/graphs/use-transform.ts b/packages/perseus/src/widgets/interactive-graphs/graphs/use-transform.ts index 9db5144f17..0eb9ab131e 100644 --- a/packages/perseus/src/widgets/interactive-graphs/graphs/use-transform.ts +++ b/packages/perseus/src/widgets/interactive-graphs/graphs/use-transform.ts @@ -68,8 +68,3 @@ export function pixelsToVectors( return [x, y]; }); } - -export const useTransformPixelsToVectors = (...pixels: vec.Vector2[]) => { - const graphState = useGraphConfig(); - return pixelsToVectors(pixels, graphState); -}; diff --git a/packages/perseus/src/widgets/numeric-input/numeric-input.testdata.ts b/packages/perseus/src/widgets/numeric-input/numeric-input.testdata.ts index caf9020f8c..fa63d220f0 100644 --- a/packages/perseus/src/widgets/numeric-input/numeric-input.testdata.ts +++ b/packages/perseus/src/widgets/numeric-input/numeric-input.testdata.ts @@ -33,39 +33,6 @@ export const question1: PerseusRenderer = { }, }; -export const question2: PerseusRenderer = { - content: "$5008 \\div 4 =$ [[\u2603 numeric-input 1]] ", - images: {}, - widgets: { - "numeric-input 1": { - graded: true, - version: { - major: 0, - minor: 0, - }, - static: false, - type: "numeric-input", - options: { - coefficient: false, - static: false, - answers: [ - { - status: "correct", - maxError: null, - strict: false, - value: 1252, - simplify: "required", - message: "", - }, - ], - labelText: "What's the answer?", - size: "normal", - }, - alignment: "default", - } as NumericInputWidget, - }, -}; - export const percentageProblem: PerseusRenderer = { content: "$5008 \\div 4 =$ [[\u2603 numeric-input 1]] ", images: {}, diff --git a/testing/wait.ts b/testing/wait.ts index dad417f8cd..661d7423ee 100644 --- a/testing/wait.ts +++ b/testing/wait.ts @@ -84,16 +84,6 @@ export const wait: (options?: WaitOptions) => Promise = ({ return unverifiedWait(normalizedDelay, normalizedCount); }; -const FRAME_DURATION = 17; - -/** - * Wait for the given delay. - * - * This will throw if jest.useRealTimers() is not used. - */ -export const waitForAnimationFrame: () => Promise = () => - wait({delay: FRAME_DURATION}); - /** * Waits for the initial Graphie render. *