diff --git a/packages/kas/src/nodes.ts b/packages/kas/src/nodes.ts index 670efef23b..9d33c1fe05 100644 --- a/packages/kas/src/nodes.ts +++ b/packages/kas/src/nodes.ts @@ -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, 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"; @@ -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]); diff --git a/packages/perseus-editor/src/__stories__/item-editor.stories.tsx b/packages/perseus-editor/src/__stories__/item-editor.stories.tsx index 26862e4c5d..cef53e11bf 100644 --- a/packages/perseus-editor/src/__stories__/item-editor.stories.tsx +++ b/packages/perseus-editor/src/__stories__/item-editor.stories.tsx @@ -10,7 +10,6 @@ import "../styles/perseus-editor.less"; type Props = React.ComponentProps; const Wrapper = (props: Props) => { - // eslint-disable-next-line @typescript-eslint/no-unused-vars const {onChange, ...rest} = props; const [extras, setExtras] = React.useState>(rest); @@ -19,7 +18,7 @@ const Wrapper = (props: Props) => { { - props.onChange?.(e); // to register action in storybook + onChange?.(e); // to register action in storybook setExtras((prevExtras) => ({...prevExtras, ...e})); }} /> diff --git a/packages/perseus-editor/src/multirenderer-editor.tsx b/packages/perseus-editor/src/multirenderer-editor.tsx index 9a9264b1f8..2d0445c7fd 100644 --- a/packages/perseus-editor/src/multirenderer-editor.tsx +++ b/packages/perseus-editor/src/multirenderer-editor.tsx @@ -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, diff --git a/packages/perseus-editor/src/widgets/interactive-graph-editor/locked-figures/locked-function-settings.test.tsx b/packages/perseus-editor/src/widgets/interactive-graph-editor/locked-figures/locked-function-settings.test.tsx index 5caaf10b6e..3d9df676d1 100644 --- a/packages/perseus-editor/src/widgets/interactive-graph-editor/locked-figures/locked-function-settings.test.tsx +++ b/packages/perseus-editor/src/widgets/interactive-graph-editor/locked-figures/locked-function-settings.test.tsx @@ -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, diff --git a/packages/perseus/src/perseus-types.ts b/packages/perseus/src/perseus-types.ts index 786c00fbda..3897728400 100644 --- a/packages/perseus/src/perseus-types.ts +++ b/packages/perseus/src/perseus-types.ts @@ -1166,9 +1166,9 @@ export type PerseusOrdererWidgetOptions = { // Cards that are not part of the answer otherOptions: ReadonlyArray; // "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 = { diff --git a/packages/perseus/src/util/graphie.ts b/packages/perseus/src/util/graphie.ts index 308efaf7f3..7909feeb95 100644 --- a/packages/perseus/src/util/graphie.ts +++ b/packages/perseus/src/util/graphie.ts @@ -1,4 +1,3 @@ -/* eslint-disable @babel/no-invalid-this */ import { point as kpoint, vector as kvector, diff --git a/packages/perseus/src/util/parse-perseus-json/perseus-parsers/orderer-widget.ts b/packages/perseus/src/util/parse-perseus-json/perseus-parsers/orderer-widget.ts index 4c8f72e52c..b0c72ab602 100644 --- a/packages/perseus/src/util/parse-perseus-json/perseus-parsers/orderer-widget.ts +++ b/packages/perseus/src/util/parse-perseus-json/perseus-parsers/orderer-widget.ts @@ -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"; @@ -19,7 +19,7 @@ export const parseOrdererWidget: Parser = parseWidget( options: array(parseRenderer), correctOptions: array(parseRenderer), otherOptions: array(parseRenderer), - height: string, - layout: string, + height: enumeration("normal", "auto"), + layout: enumeration("horizontal", "vertical"), }), ); diff --git a/packages/perseus/src/util/parse-perseus-json/perseus-parsers/widgets-map.test.ts b/packages/perseus/src/util/parse-perseus-json/perseus-parsers/widgets-map.test.ts index 89f0dead25..f92814976f 100644 --- a/packages/perseus/src/util/parse-perseus-json/perseus-parsers/widgets-map.test.ts +++ b/packages/perseus/src/util/parse-perseus-json/perseus-parsers/widgets-map.test.ts @@ -512,8 +512,8 @@ describe("parseWidgetsMap", () => { options: [], correctOptions: [], otherOptions: [], - height: "", - layout: "", + height: "normal", + layout: "horizontal", }, }, }; diff --git a/packages/perseus/src/widgets/orderer/orderer.tsx b/packages/perseus/src/widgets/orderer/orderer.tsx index 7b638f6641..972f50fd02 100644 --- a/packages/perseus/src/widgets/orderer/orderer.tsx +++ b/packages/perseus/src/widgets/orderer/orderer.tsx @@ -1,5 +1,5 @@ /* eslint-disable @khanacademy/ts-no-error-suppressions */ -/* eslint-disable @babel/no-invalid-this, @typescript-eslint/no-unused-vars, react/no-unsafe */ +/* eslint-disable @babel/no-invalid-this, react/no-unsafe */ import {Errors} from "@khanacademy/perseus-core"; import {linterContextDefault} from "@khanacademy/perseus-linter"; import $ from "jquery"; @@ -17,12 +17,7 @@ import {getPromptJSON as _getPromptJSON} from "../../widget-ai-utils/orderer/ord import {scoreOrderer} from "./score-orderer"; import type {PerseusOrdererWidgetOptions} from "../../perseus-types"; -import type { - PerseusScore, - WidgetExports, - WidgetProps, - Widget, -} from "../../types"; +import type {WidgetExports, WidgetProps, Widget} from "../../types"; import type { PerseusOrdererRubric, PerseusOrdererUserInput, @@ -300,11 +295,6 @@ class Card extends React.Component { } } -const NORMAL = "normal"; -const AUTO = "auto"; -const HORIZONTAL = "horizontal"; -const VERTICAL = "vertical"; - type RenderProps = PerseusOrdererWidgetOptions & { current: any; }; @@ -344,8 +334,8 @@ class Orderer current: [], options: [], correctOptions: [], - height: NORMAL, - layout: HORIZONTAL, + height: "normal", + layout: "horizontal", linterContext: linterContextDefault, }; @@ -521,7 +511,7 @@ class Orderer findCorrectIndex: (arg1: any, arg2: any) => any = (draggable, list) => { // Find the correct index for a card given the current cards. - const isHorizontal = this.props.layout === HORIZONTAL; + const isHorizontal = this.props.layout === "horizontal"; // eslint-disable-next-line react/no-string-refs // @ts-expect-error - TS2769 - No overload matches this call. const $dragList = $(ReactDOM.findDOMNode(this.refs.dragList)); @@ -585,7 +575,7 @@ class Orderer return false; } - const isHorizontal = this.props.layout === HORIZONTAL; + const isHorizontal = this.props.layout === "horizontal"; // @ts-expect-error - TS2769 - No overload matches this call. const $draggable = $(ReactDOM.findDOMNode(draggable)); // eslint-disable-next-line react/no-string-refs @@ -601,10 +591,6 @@ class Orderer const bankHeight = $bank.outerHeight(true); // @ts-expect-error - TS2339 - Property 'outerWidth' does not exist on type 'JQueryStatic'. const bankWidth = $bank.outerWidth(true); - // eslint-disable-next-line react/no-string-refs - const dragList = ReactDOM.findDOMNode(this.refs.dragList); - // @ts-expect-error - TS2769 - No overload matches this call. | TS2339 - Property 'width' does not exist on type 'JQueryStatic'. - const dragListWidth = $(dragList).width(); // @ts-expect-error - TS2339 - Property 'outerWidth' does not exist on type 'JQueryStatic'. const draggableWidth = $draggable.outerWidth(true); diff --git a/packages/simple-markdown/src/index.ts b/packages/simple-markdown/src/index.ts index 18feefe347..e4ad7187b2 100644 --- a/packages/simple-markdown/src/index.ts +++ b/packages/simple-markdown/src/index.ts @@ -1,4 +1,4 @@ -/* eslint-disable prefer-spread, no-regex-spaces, @typescript-eslint/no-unused-vars, guard-for-in, no-console, no-var */ +/* eslint-disable prefer-spread, no-regex-spaces, guard-for-in, no-console, no-var */ /** * Simple-Markdown * =============== @@ -710,7 +710,6 @@ var TABLES = (function () { // predefine regexes so we don't have to create them inside functions // sure, regex literals should be fast, even inside functions, but they // aren't in all browsers. - var TABLE_BLOCK_TRIM = /\n+/g; var TABLE_ROW_SEPARATOR_TRIM = /^ *\| *| *\| *$/g; var TABLE_CELL_END_TRIM = / *$/; var TABLE_RIGHT_ALIGN = /^ *-+: *$/; @@ -931,7 +930,7 @@ var defaultRules: DefaultRules = { // map output over the ast, except group any text // nodes together into a single string output. - for (var i = 0, key = 0; i < arr.length; i++) { + for (var i = 0; i < arr.length; i++) { var node = arr[i]; if (node.type === "text") { node = {type: "text", content: node.content}; @@ -1901,7 +1900,7 @@ var markdownToHtml = function (source: string, state?: State | null): string { // TODO: This needs definition type Props = any; -var ReactMarkdown = function (props): React.ReactElement { +var ReactMarkdown = function (props: Props): React.ReactElement { var divProps: Record = {}; for (var prop in props) {