Skip to content

Commit

Permalink
remove some error suppressions (#1920)
Browse files Browse the repository at this point in the history
## Summary:
idk, just following some threads by un-excepting errors.

Author: handeyeco

Reviewers: handeyeco, jeremywiebe

Required Reviewers:

Approved By: jeremywiebe

Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (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), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald

Pull Request URL: #1920
  • Loading branch information
handeyeco authored Nov 27, 2024
1 parent 799ffe4 commit 88ba71b
Show file tree
Hide file tree
Showing 18 changed files with 96 additions and 116 deletions.
8 changes: 8 additions & 0 deletions .changeset/few-jokes-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@khanacademy/kas": patch
"@khanacademy/perseus": patch
"@khanacademy/perseus-editor": patch
"@khanacademy/simple-markdown": patch
---

Fix some file-wide error suppressions
1 change: 0 additions & 1 deletion config/test/test-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ if (typeof window !== "undefined") {
// Override the window.location implementation to mock out assign()
// We need to access window.location.assign to verify that we're
// redirecting to the right place.
/* eslint-disable no-restricted-syntax */
const oldLocation = window.location;
// @ts-expect-error - TS2790 - The operand of a 'delete' operator must be optional.
delete window.location;
Expand Down
3 changes: 1 addition & 2 deletions packages/kas/src/nodes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable prettier/prettier */
/* eslint-disable import/order */
/* TODO(charlie): fix these lint errors (http://eslint.org/docs/rules): */
/* eslint-disable indent, no-undef, no-var, one-var, no-dupe-keys, no-new-func, no-redeclare, @typescript-eslint/no-unused-vars, comma-dangle, max-len, prefer-spread, space-infix-ops, space-unary-ops */
/* eslint-disable indent, no-undef, no-var, no-dupe-keys, no-new-func, no-redeclare, comma-dangle, max-len, prefer-spread, space-infix-ops, space-unary-ops */
import _ from "underscore";

import {unitParser} from "./__genfiles__/unitparser";
Expand Down Expand Up @@ -1414,7 +1414,6 @@ export class Mul extends Seq {
rational = rational.addHint("fraction");
}

var result;
if (num.n < 0 && right.n < 0) {
rational.d = -rational.d;
return left.replace(num, [NumNeg, rational]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import "../styles/perseus-editor.less";
type Props = React.ComponentProps<typeof ItemExtrasEditor>;

const Wrapper = (props: Props) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const {onChange, ...rest} = props;
const [extras, setExtras] =
React.useState<Partial<typeof ItemExtrasEditor.defaultProps>>(rest);
Expand All @@ -19,7 +18,7 @@ const Wrapper = (props: Props) => {
<ItemExtrasEditor
{...extras}
onChange={(e) => {
props.onChange?.(e); // to register action in storybook
onChange?.(e); // to register action in storybook
setExtras((prevExtras) => ({...prevExtras, ...e}));
}}
/>
Expand Down
3 changes: 1 addition & 2 deletions packages/perseus-editor/src/multirenderer-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ import type {

// Multi-item item types
Item,
// ItemTree is used below, the linter is confused.
ItemTree, // eslint-disable-line @typescript-eslint/no-unused-vars
ItemTree,
ItemObjectNode,
ItemArrayNode,
ContentNode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import * as React from "react";

import {flags} from "../../../__stories__/flags-for-api-options";

// Disabling the following linting error because the import is needed for mocking purposes.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import examples from "./locked-function-examples";
import LockedFunctionSettings from "./locked-function-settings";
import {
getDefaultFigureForType,
Expand Down
10 changes: 5 additions & 5 deletions packages/perseus-editor/src/widgets/orderer-editor.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/* eslint-disable @khanacademy/ts-no-error-suppressions */
/* eslint-disable one-var, react/forbid-prop-types */
/* eslint-disable react/forbid-prop-types */
import {components} from "@khanacademy/perseus";
import PropTypes from "prop-types";
import * as React from "react";
import _ from "underscore";

const {InfoTip, TextListEditor} = components;

const NORMAL = "normal",
AUTO = "auto",
HORIZONTAL = "horizontal",
VERTICAL = "vertical";
const NORMAL = "normal";
const AUTO = "auto";
const HORIZONTAL = "horizontal";
const VERTICAL = "vertical";

type Props = any;

Expand Down
1 change: 0 additions & 1 deletion packages/perseus/src/hints-renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @khanacademy/ts-no-error-suppressions */
import * as PerseusLinter from "@khanacademy/perseus-linter";
import {StyleSheet, css} from "aphrodite";
import classnames from "classnames";
Expand Down
1 change: 0 additions & 1 deletion packages/perseus/src/interactive2/wrapped-drawing.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @babel/no-invalid-this */
/**
* Default methods for a wrapped movable.
*/
Expand Down
3 changes: 1 addition & 2 deletions packages/perseus/src/perseus-markdown.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-useless-escape, no-prototype-builtins */
import {pureMarkdownRules} from "@khanacademy/pure-markdown";
import SimpleMarkdown from "@khanacademy/simple-markdown";
import * as React from "react";
Expand Down Expand Up @@ -201,7 +200,7 @@ const rules = {
// link was not put together properly, let's make sure it's there so we
// don't break the entire page.
const isKAUrl = href
? href.match(/https?:\/\/[^\/]*khanacademy.org|^\//)
? href.match(/https?:\/\/[^/]*khanacademy.org|^\//)
: false;
if (!isKAUrl) {
// Prevents "reverse tabnabbing" phishing attacks
Expand Down
4 changes: 2 additions & 2 deletions packages/perseus/src/perseus-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1171,9 +1171,9 @@ export type PerseusOrdererWidgetOptions = {
// Cards that are not part of the answer
otherOptions: ReadonlyArray<PerseusRenderer>;
// "normal" for text options. "auto" for image options.
height: string;
height: "normal" | "auto";
// Use the "horizontal" layout for short text and small images. The "vertical" layout is best for longer text (e.g. proofs).
layout: string;
layout: "horizontal" | "vertical";
};

export type PerseusPassageWidgetOptions = {
Expand Down
5 changes: 2 additions & 3 deletions packages/perseus/src/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @babel/no-invalid-this, getter-return, one-var */
import {Errors, PerseusError} from "@khanacademy/perseus-core";
import _ from "underscore";

Expand Down Expand Up @@ -150,8 +149,8 @@ function shuffle<T>(
do {
// Fischer-Yates shuffle
for (let top = shuffled.length; top > 0; top--) {
const newEnd = Math.floor(random() * top),
temp = shuffled[newEnd];
const newEnd = Math.floor(random() * top);
const temp = shuffled[newEnd];

// @ts-expect-error - TS2542 - Index signature in type 'readonly T[]' only permits reading.
shuffled[newEnd] = shuffled[top - 1];
Expand Down
1 change: 0 additions & 1 deletion packages/perseus/src/util/graphie.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @babel/no-invalid-this */
import {
point as kpoint,
vector as kvector,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {array, constant, object, string} from "../general-purpose-parsers";
import {array, constant, enumeration, object} from "../general-purpose-parsers";

import {parsePerseusRenderer} from "./perseus-renderer";
import {parseWidget} from "./widget";
Expand All @@ -19,7 +19,7 @@ export const parseOrdererWidget: Parser<OrdererWidget> = parseWidget(
options: array(parseRenderer),
correctOptions: array(parseRenderer),
otherOptions: array(parseRenderer),
height: string,
layout: string,
height: enumeration("normal", "auto"),
layout: enumeration("horizontal", "vertical"),
}),
);
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,8 @@ describe("parseWidgetsMap", () => {
options: [],
correctOptions: [],
otherOptions: [],
height: "",
layout: "",
height: "normal",
layout: "horizontal",
},
},
};
Expand Down
89 changes: 44 additions & 45 deletions packages/perseus/src/widgets/grapher/util.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable one-var */
import {point as kpoint} from "@khanacademy/kmath";
import * as React from "react";
import _ from "underscore";
Expand Down Expand Up @@ -141,15 +140,15 @@ const Linear: LinearType = _.extend({}, PlotDefaults, {
},

getFunctionForCoeffs: function (coeffs: ReadonlyArray<number>, x: number) {
const m = coeffs[0],
b = coeffs[1];
const m = coeffs[0];
const b = coeffs[1];
return m * x + b;
},

getEquationString: function (coords: Coords) {
const coeffs: ReadonlyArray<number> = this.getCoefficients(coords);
const m: number = coeffs[0],
b: number = coeffs[1];
const m: number = coeffs[0];
const b: number = coeffs[1];
return "y = " + m.toFixed(3) + "x + " + b.toFixed(3);
},
});
Expand Down Expand Up @@ -184,9 +183,9 @@ const Quadratic: QuadraticType = _.extend({}, PlotDefaults, {
coeffs: ReadonlyArray<number>,
x: number,
): number {
const a = coeffs[0],
b = coeffs[1],
c = coeffs[2];
const a = coeffs[0];
const b = coeffs[1];
const c = coeffs[2];
return (a * x + b) * x + c;
},

Expand All @@ -204,9 +203,9 @@ const Quadratic: QuadraticType = _.extend({}, PlotDefaults, {

getEquationString: function (coords: Coords) {
const coeffs = this.getCoefficients(coords);
const a = coeffs[0],
b = coeffs[1],
c = coeffs[2];
const a = coeffs[0];
const b = coeffs[1];
const c = coeffs[2];
return (
"y = " +
a.toFixed(3) +
Expand Down Expand Up @@ -241,10 +240,10 @@ const Sinusoid: SinusoidType = _.extend({}, PlotDefaults, {
},

getFunctionForCoeffs: function (coeffs: ReadonlyArray<number>, x: number) {
const a = coeffs[0],
b = coeffs[1],
c = coeffs[2],
d = coeffs[3];
const a = coeffs[0];
const b = coeffs[1];
const c = coeffs[2];
const d = coeffs[3];
return a * Math.sin(b * x - c) + d;
},

Expand All @@ -259,10 +258,10 @@ const Sinusoid: SinusoidType = _.extend({}, PlotDefaults, {

getEquationString: function (coords: Coords) {
const coeffs = this.getCoefficients(coords);
const a = coeffs[0],
b = coeffs[1],
c = coeffs[2],
d = coeffs[3];
const a = coeffs[0];
const b = coeffs[1];
const c = coeffs[2];
const d = coeffs[3];
return (
"y = " +
a.toFixed(3) +
Expand Down Expand Up @@ -307,19 +306,19 @@ const Tangent: TangentType = _.extend({}, PlotDefaults, {
},

getFunctionForCoeffs: function (coeffs: ReadonlyArray<number>, x: number) {
const a = coeffs[0],
b = coeffs[1],
c = coeffs[2],
d = coeffs[3];
const a = coeffs[0];
const b = coeffs[1];
const c = coeffs[2];
const d = coeffs[3];
return a * Math.tan(b * x - c) + d;
},

getEquationString: function (coords: Coords) {
const coeffs = this.getCoefficients(coords);
const a = coeffs[0],
b = coeffs[1],
c = coeffs[2],
d = coeffs[3];
const a = coeffs[0];
const b = coeffs[1];
const c = coeffs[2];
const d = coeffs[3];
return (
"y = " +
a.toFixed(3) +
Expand Down Expand Up @@ -430,9 +429,9 @@ const Exponential: ExponentialType = _.extend({}, PlotDefaults, {
coeffs: ReadonlyArray<number>,
x: number,
): number {
const a = coeffs[0],
b = coeffs[1],
c = coeffs[2];
const a = coeffs[0];
const b = coeffs[1];
const c = coeffs[2];
return a * Math.exp(b * x) + c;
},

Expand All @@ -441,9 +440,9 @@ const Exponential: ExponentialType = _.extend({}, PlotDefaults, {
return null;
}
const coeffs = this.getCoefficients(coords, asymptote);
const a = coeffs[0],
b = coeffs[1],
c = coeffs[2];
const a = coeffs[0];
const b = coeffs[1];
const c = coeffs[2];
return (
"y = " +
a.toFixed(3) +
Expand Down Expand Up @@ -537,9 +536,9 @@ const Logarithm: LogarithmType = _.extend({}, PlotDefaults, {
x: number,
asymptote: Coords,
) {
const a = coeffs[0],
b = coeffs[1],
c = coeffs[2];
const a = coeffs[0];
const b = coeffs[1];
const c = coeffs[2];
return a * Math.log(b * x + c);
},

Expand All @@ -551,9 +550,9 @@ const Logarithm: LogarithmType = _.extend({}, PlotDefaults, {
coords,
asymptote,
);
const a = coeffs[0],
b = coeffs[1],
c = coeffs[2];
const a = coeffs[0];
const b = coeffs[1];
const c = coeffs[2];
return (
"y = ln(" +
a.toFixed(3) +
Expand Down Expand Up @@ -597,17 +596,17 @@ const AbsoluteValue: AbsoluteValueType = _.extend({}, PlotDefaults, {
},

getFunctionForCoeffs: function (coeffs: ReadonlyArray<number>, x: number) {
const m = coeffs[0],
horizontalOffset = coeffs[1],
verticalOffset = coeffs[2];
const m = coeffs[0];
const horizontalOffset = coeffs[1];
const verticalOffset = coeffs[2];
return m * Math.abs(x - horizontalOffset) + verticalOffset;
},

getEquationString: function (coords: Coords) {
const coeffs: ReadonlyArray<number> = this.getCoefficients(coords);
const m = coeffs[0],
horizontalOffset = coeffs[1],
verticalOffset = coeffs[2];
const m = coeffs[0];
const horizontalOffset = coeffs[1];
const verticalOffset = coeffs[2];
return (
"y = " +
m.toFixed(3) +
Expand Down
Loading

0 comments on commit 88ba71b

Please sign in to comment.