Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Knip 8: remove unused exports #1778

Open
wants to merge 2 commits into
base: add-knip
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/rotten-turkeys-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@khanacademy/math-input": patch
"@khanacademy/perseus": patch
"@khanacademy/perseus-linter": patch
---

Remove unused dead code
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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);
};
2 changes: 0 additions & 2 deletions packages/math-input/src/components/tabbar/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,4 @@ function TabbarItem(props: TabItemProps): React.ReactElement {
);
}

export const TabbarItemForTesting = TabbarItem;

export default TabbarItem;
31 changes: 0 additions & 31 deletions packages/perseus-linter/src/rules/lint-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
30 changes: 0 additions & 30 deletions packages/perseus/src/multi-items/prop-type-builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>): 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.
Expand Down
45 changes: 0 additions & 45 deletions packages/perseus/src/sigfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,3 @@ export function pixelsToVectors(
return [x, y];
});
}

export const useTransformPixelsToVectors = (...pixels: vec.Vector2[]) => {
const graphState = useGraphConfig();
return pixelsToVectors(pixels, graphState);
};
Original file line number Diff line number Diff line change
Expand Up @@ -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: {},
Expand Down
10 changes: 0 additions & 10 deletions testing/wait.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,6 @@ export const wait: (options?: WaitOptions) => Promise<void> = ({
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<void> = () =>
wait({delay: FRAME_DURATION});

/**
* Waits for the initial Graphie render.
*
Expand Down