From d05a4a22895c2c939e5c90a9b412ddfaaa0ba2f0 Mon Sep 17 00:00:00 2001 From: Matthew Date: Tue, 22 Oct 2024 10:35:21 -0500 Subject: [PATCH] Knip 6: remove needless exports (#1776) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary: Knip found a bunch of exports for things that didn't need to be exported. Author: handeyeco Reviewers: benchristel Required Reviewers: Approved By: benchristel Checks: ✅ Publish npm snapshot (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), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald Pull Request URL: https://github.com/Khan/perseus/pull/1776 --- .changeset/real-insects-film.md | 8 ++++++++ dev/flipbook-model.ts | 2 +- .../src/components/input/mathquill-helpers.ts | 10 +++++----- .../src/components/input/scroll-into-view.ts | 2 +- packages/math-input/src/enums.ts | 2 +- .../perseus-editor/src/components/dropdown-option.tsx | 2 +- packages/perseus/src/util/math.ts | 2 +- packages/perseus/src/widgets/expression/expression.tsx | 2 +- .../graphs/components/movable-line.tsx | 2 +- .../src/widgets/interactive-graphs/graphs/point.tsx | 4 ++-- .../src/widgets/interactive-graphs/protractor.tsx | 2 +- packages/perseus/src/widgets/molecule/molecule.tsx | 2 +- 12 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 .changeset/real-insects-film.md diff --git a/.changeset/real-insects-film.md b/.changeset/real-insects-film.md new file mode 100644 index 0000000000..72aab2ef94 --- /dev/null +++ b/.changeset/real-insects-film.md @@ -0,0 +1,8 @@ +--- +"@khanacademy/perseus-dev-ui": patch +"@khanacademy/math-input": patch +"@khanacademy/perseus": patch +"@khanacademy/perseus-editor": patch +--- + +Don't export things that aren't used externally diff --git a/dev/flipbook-model.ts b/dev/flipbook-model.ts index ac10f3c9b9..b90b02323c 100644 --- a/dev/flipbook-model.ts +++ b/dev/flipbook-model.ts @@ -120,7 +120,7 @@ function clampIndex(index: number, array: unknown[]): number { // Selectors // --------------------------------------------------------------------------- -export const selectQuestionsAsJSON = cache((state: FlipbookModel): string[] => { +const selectQuestionsAsJSON = cache((state: FlipbookModel): string[] => { return state.questions .split("\n") .map((s) => s.trim()) diff --git a/packages/math-input/src/components/input/mathquill-helpers.ts b/packages/math-input/src/components/input/mathquill-helpers.ts index 0cc310264f..dc7d8d2ff4 100644 --- a/packages/math-input/src/components/input/mathquill-helpers.ts +++ b/packages/math-input/src/components/input/mathquill-helpers.ts @@ -52,15 +52,15 @@ export function isFraction(node): boolean { return mqNodeHasClass(node, "mq-fraction"); } -export function isNumerator(node): boolean { +function isNumerator(node): boolean { return mqNodeHasClass(node, "mq-numerator"); } -export function isDenominator(node): boolean { +function isDenominator(node): boolean { return mqNodeHasClass(node, "mq-denominator"); } -export function isSubScript(node): boolean { +function isSubScript(node): boolean { // NOTE(charlie): MyScript has a structure whereby its superscripts seem // to be represented as a parent node with 'mq-sup-only' containing a // single child with 'mq-sup'. @@ -69,7 +69,7 @@ export function isSubScript(node): boolean { ); } -export function isSuperScript(node): boolean { +function isSuperScript(node): boolean { // NOTE(charlie): MyScript has a structure whereby its superscripts seem // to be represented as a parent node with 'mq-sup-only' containing a // single child with 'mq-sup'. @@ -82,7 +82,7 @@ export function isParens(node): boolean { return node && node.ctrlSeq === "\\left("; } -export function isLeaf(node): boolean { +function isLeaf(node): boolean { return node && node.ctrlSeq && ValidLeaves.includes(node.ctrlSeq.trim()); } diff --git a/packages/math-input/src/components/input/scroll-into-view.ts b/packages/math-input/src/components/input/scroll-into-view.ts index 93e3a57fdd..45fda07ccb 100644 --- a/packages/math-input/src/components/input/scroll-into-view.ts +++ b/packages/math-input/src/components/input/scroll-into-view.ts @@ -12,7 +12,7 @@ // HACK(charlie): This should be injected by webapp somehow. // TODO(charlie): Add a link to the webapp location as soon as the footer // has settled down. -export const toolbarHeightPx = 60; +const toolbarHeightPx = 60; export const scrollIntoView = (containerNode, keypadNode) => { // TODO(charlie): There's no need for us to be reading the keypad bounds diff --git a/packages/math-input/src/enums.ts b/packages/math-input/src/enums.ts index 0908fe9ad2..e9c32a12c1 100644 --- a/packages/math-input/src/enums.ts +++ b/packages/math-input/src/enums.ts @@ -7,7 +7,7 @@ export enum KeypadType { EXPRESSION = "EXPRESSION", } -export const KeyTypes = [ +const KeyTypes = [ "EMPTY", // For numerals, variables, and any other characters that themselves // compose 'values'. diff --git a/packages/perseus-editor/src/components/dropdown-option.tsx b/packages/perseus-editor/src/components/dropdown-option.tsx index 76236c23d0..317538855c 100644 --- a/packages/perseus-editor/src/components/dropdown-option.tsx +++ b/packages/perseus-editor/src/components/dropdown-option.tsx @@ -64,7 +64,7 @@ const check = `M10,3.8C10,4,9.9,4.2,9.8,4.3L5.1,8.9L4.3,9.8C4.2,9.9,4,10,3.8,10 -0.1,0.3-0.2,0.4-0.2c0.2,0,0.3,0.1,0.4,0.2l0.9,0.9C9.9,3.5,10,3.7, 10,3.8z`; -export const optionHeight = 30; +const optionHeight = 30; class Option extends React.Component { // @ts-expect-error - TS2564 - Property 'node' has no initializer and is not definitely assigned in the constructor. diff --git a/packages/perseus/src/util/math.ts b/packages/perseus/src/util/math.ts index 3771bef104..4e677daffa 100644 --- a/packages/perseus/src/util/math.ts +++ b/packages/perseus/src/util/math.ts @@ -287,7 +287,7 @@ export function sum(array: number[]): number { return array.reduce(add, 0); } -export function add(a: number, b: number): number { +function add(a: number, b: number): number { return a + b; } diff --git a/packages/perseus/src/widgets/expression/expression.tsx b/packages/perseus/src/widgets/expression/expression.tsx index 2dc06dc088..8de7fa4a7b 100644 --- a/packages/perseus/src/widgets/expression/expression.tsx +++ b/packages/perseus/src/widgets/expression/expression.tsx @@ -421,7 +421,7 @@ const styles = StyleSheet.create({ * to be included as keys on the keypad. These are scraped from the answer * forms. */ -export const keypadConfigurationForProps = ( +const keypadConfigurationForProps = ( widgetOptions: PerseusExpressionWidgetOptions, ): KeypadConfiguration => { // Always use the Expression keypad, regardless of the button sets that have diff --git a/packages/perseus/src/widgets/interactive-graphs/graphs/components/movable-line.tsx b/packages/perseus/src/widgets/interactive-graphs/graphs/components/movable-line.tsx index c7c5afec12..f2793f4da2 100644 --- a/packages/perseus/src/widgets/interactive-graphs/graphs/components/movable-line.tsx +++ b/packages/perseus/src/widgets/interactive-graphs/graphs/components/movable-line.tsx @@ -138,7 +138,7 @@ type LineProps = { }; }; -export const Line = (props: LineProps) => { +const Line = (props: LineProps) => { const {start, end, onMove, extend, stroke = defaultStroke} = props; const [startPtPx, endPtPx] = useTransformVectorsToPixels(start, end); diff --git a/packages/perseus/src/widgets/interactive-graphs/graphs/point.tsx b/packages/perseus/src/widgets/interactive-graphs/graphs/point.tsx index 5d6c451cac..62e85fe7ab 100644 --- a/packages/perseus/src/widgets/interactive-graphs/graphs/point.tsx +++ b/packages/perseus/src/widgets/interactive-graphs/graphs/point.tsx @@ -15,7 +15,7 @@ import type {PointGraphState, MafsGraphProps} from "../types"; type PointGraphProps = MafsGraphProps; -export function LimitedPointGraph(props: PointGraphProps) { +function LimitedPointGraph(props: PointGraphProps) { const {dispatch} = props; return ( @@ -33,7 +33,7 @@ export function LimitedPointGraph(props: PointGraphProps) { ); } -export function UnlimitedPointGraph(props: PointGraphProps) { +function UnlimitedPointGraph(props: PointGraphProps) { const {dispatch} = props; const graphState = useGraphConfig(); const { diff --git a/packages/perseus/src/widgets/interactive-graphs/protractor.tsx b/packages/perseus/src/widgets/interactive-graphs/protractor.tsx index 3325838d9e..6931c4a75f 100644 --- a/packages/perseus/src/widgets/interactive-graphs/protractor.tsx +++ b/packages/perseus/src/widgets/interactive-graphs/protractor.tsx @@ -30,7 +30,7 @@ const centerToTopLeft: vec.Vector2 = [-180, -170]; // The vector from the center of the protractor to the center of the rotation // handle. -export const centerToRotationHandle: vec.Vector2 = [-176, -15]; +const centerToRotationHandle: vec.Vector2 = [-176, -15]; export function Protractor() { const {range, snapStep} = useGraphConfig(); diff --git a/packages/perseus/src/widgets/molecule/molecule.tsx b/packages/perseus/src/widgets/molecule/molecule.tsx index e48fbcc8f7..38127883c8 100644 --- a/packages/perseus/src/widgets/molecule/molecule.tsx +++ b/packages/perseus/src/widgets/molecule/molecule.tsx @@ -28,7 +28,7 @@ type Props = { rotationAngle: PerseusMoleculeRendererWidgetOptions["rotationAngle"]; }; -export class Molecule extends React.Component { +class Molecule extends React.Component { static contextType = PerseusI18nContext; declare context: React.ContextType;