diff --git a/.changeset/config.json b/.changeset/config.json index 071a841844..f9b02d6a44 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -1,13 +1,13 @@ { - "$schema": "https://unpkg.com/@changesets/config@1.7.0/schema.json", - "changelog": ["@changesets/changelog-github", {"repo": "Khan/perseus"}], - "commit": false, - "linked": [], - "access": "public", - "baseBranch": "main", - "updateInternalDependencies": "patch", - "ignore": [], - "___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": { - "updateInternalDependents": "always" - } + "$schema": "https://unpkg.com/@changesets/config@1.7.0/schema.json", + "changelog": ["@changesets/changelog-github", { "repo": "Khan/perseus" }], + "commit": false, + "linked": [], + "access": "public", + "baseBranch": "main", + "updateInternalDependencies": "patch", + "ignore": [], + "___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": { + "updateInternalDependents": "always" + } } diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8111fa6527..93b5a5da3d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,22 +1,22 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node { - "name": "Node.js & TypeScript", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/typescript-node:16", + "name": "Node.js & TypeScript", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/typescript-node:16", - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - "forwardPorts": [6006], + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [6006], - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "yarn install" + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "yarn install" - // Configure tool-specific properties. - // "customizations": {}, + // Configure tool-specific properties. + // "customizations": {}, - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" } diff --git a/.nycrc.json b/.nycrc.json index 8eaba5538e..3ff9b29ce2 100644 --- a/.nycrc.json +++ b/.nycrc.json @@ -6,9 +6,5 @@ "packages/*/src/**/*.ts", "packages/*/src/**/*.tsx" ], - "exclude": [ - "**/*.stories.tsx", - "**/*.test.ts", - "**/*.test.tsx" - ] -} \ No newline at end of file + "exclude": ["**/*.stories.tsx", "**/*.test.ts", "**/*.test.tsx"] +} diff --git a/config/cypress/tsconfig.json b/config/cypress/tsconfig.json index cf44157e20..48e292de4a 100644 --- a/config/cypress/tsconfig.json +++ b/config/cypress/tsconfig.json @@ -5,7 +5,7 @@ "esModuleInterop": true, // be explicit about types included // to avoid clashing with Jest types - "types": ["cypress", "node", "cypress-real-events"] + "types": ["cypress", "node", "cypress-real-events"], }, - "include": ["**/*.ts", "**/*.tsx"] + "include": ["**/*.ts", "**/*.tsx"], } diff --git a/package.json b/package.json index 89c34fb8d2..dd74da4bc2 100644 --- a/package.json +++ b/package.json @@ -5,11 +5,7 @@ "repository": "git@github.com:Khan/perseus.git", "license": "MIT", "private": true, - "workspaces": [ - "dev", - "packages/*", - "config/build" - ], + "workspaces": ["dev", "packages/*", "config/build"], "engines": { "node": ">=20" }, diff --git a/packages/kas/package.json b/packages/kas/package.json index 518138df00..ea5656e26f 100644 --- a/packages/kas/package.json +++ b/packages/kas/package.json @@ -18,9 +18,7 @@ "module": "dist/es/index.js", "main": "dist/index.js", "source": "src/index.js", - "files": [ - "dist" - ], + "files": ["dist"], "scripts": { "gen:parsers": "node src/parser-generator.ts", "test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'" @@ -36,11 +34,5 @@ "peerDependencies": { "underscore": "1.4.4" }, - "keywords": [ - "parsing", - "equation", - "expression", - "algebra", - "symbolic" - ] + "keywords": ["parsing", "equation", "expression", "algebra", "symbolic"] } diff --git a/packages/kas/tsconfig-build.json b/packages/kas/tsconfig-build.json index 5f2f33e952..82b1c134e7 100644 --- a/packages/kas/tsconfig-build.json +++ b/packages/kas/tsconfig-build.json @@ -2,9 +2,7 @@ "extends": "../tsconfig-shared.json", "compilerOptions": { "outDir": "./dist", - "rootDir": "src" + "rootDir": "src", }, - "references": [ - {"path": "../perseus-core/tsconfig-build.json"} - ] + "references": [{ "path": "../perseus-core/tsconfig-build.json" }], } diff --git a/packages/keypad-context/package.json b/packages/keypad-context/package.json index a5cfa1b351..9f0413b923 100644 --- a/packages/keypad-context/package.json +++ b/packages/keypad-context/package.json @@ -18,9 +18,7 @@ "module": "dist/es/index.js", "main": "dist/index.js", "source": "src/index.ts", - "files": [ - "dist" - ], + "files": ["dist"], "scripts": { "test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'" }, diff --git a/packages/keypad-context/tsconfig-build.json b/packages/keypad-context/tsconfig-build.json index e06eddef57..82b1c134e7 100644 --- a/packages/keypad-context/tsconfig-build.json +++ b/packages/keypad-context/tsconfig-build.json @@ -4,7 +4,5 @@ "outDir": "./dist", "rootDir": "src", }, - "references": [ - {"path": "../perseus-core/tsconfig-build.json"} - ] + "references": [{ "path": "../perseus-core/tsconfig-build.json" }], } diff --git a/packages/kmath/package.json b/packages/kmath/package.json index 2ae25825cf..6051ca7206 100644 --- a/packages/kmath/package.json +++ b/packages/kmath/package.json @@ -17,9 +17,7 @@ "module": "dist/es/index.js", "main": "dist/index.js", "source": "src/index.ts", - "files": [ - "dist" - ], + "files": ["dist"], "scripts": { "test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'" }, diff --git a/packages/kmath/src/__tests__/vector.test.ts b/packages/kmath/src/__tests__/vector.test.ts index bda1d9731b..aa8808643b 100644 --- a/packages/kmath/src/__tests__/vector.test.ts +++ b/packages/kmath/src/__tests__/vector.test.ts @@ -115,23 +115,17 @@ describe("kvector", function () { expect(result).toBe(false); }); - it( - "vector.collinear should return true on two collinear vectors of " + - "the same magnitude but different direction", - function () { - const result = vector.collinear([3, 3], [-3, -3]); - expect(result).toBe(true); - }, - ); - - it( - "vector.collinear should return true on two collinear vectors of " + - "different magnitudes", - function () { - const result = vector.collinear([2, 1], [6, 3]); - expect(result).toBe(true); - }, - ); + it("vector.collinear should return true on two collinear vectors of " + + "the same magnitude but different direction", function () { + const result = vector.collinear([3, 3], [-3, -3]); + expect(result).toBe(true); + }); + + it("vector.collinear should return true on two collinear vectors of " + + "different magnitudes", function () { + const result = vector.collinear([2, 1], [6, 3]); + expect(result).toBe(true); + }); it("vector.collinear should return false on non-collinear vectors", function () { const result = vector.collinear([1, 2], [-1, 2]); diff --git a/packages/kmath/tsconfig-build.json b/packages/kmath/tsconfig-build.json index e06eddef57..82b1c134e7 100644 --- a/packages/kmath/tsconfig-build.json +++ b/packages/kmath/tsconfig-build.json @@ -4,7 +4,5 @@ "outDir": "./dist", "rootDir": "src", }, - "references": [ - {"path": "../perseus-core/tsconfig-build.json"} - ] + "references": [{ "path": "../perseus-core/tsconfig-build.json" }], } diff --git a/packages/math-input/package.json b/packages/math-input/package.json index 54940a0292..ee5008c43e 100644 --- a/packages/math-input/package.json +++ b/packages/math-input/package.json @@ -33,9 +33,7 @@ }, "./styles.css": "./dist/index.css" }, - "files": [ - "dist" - ], + "files": ["dist"], "scripts": {}, "dependencies": { "@khanacademy/keypad-context": "^1.0.3", diff --git a/packages/math-input/tsconfig-build.json b/packages/math-input/tsconfig-build.json index f09f2a9f94..343cfad021 100644 --- a/packages/math-input/tsconfig-build.json +++ b/packages/math-input/tsconfig-build.json @@ -5,7 +5,7 @@ "rootDir": "src", }, "references": [ - {"path": "../perseus-core/tsconfig-build.json"}, - {"path": "../keypad-context/tsconfig-build.json"}, - ] + { "path": "../perseus-core/tsconfig-build.json" }, + { "path": "../keypad-context/tsconfig-build.json" }, + ], } diff --git a/packages/perseus-core/package.json b/packages/perseus-core/package.json index a691d66e63..baaf740634 100644 --- a/packages/perseus-core/package.json +++ b/packages/perseus-core/package.json @@ -18,9 +18,7 @@ "module": "dist/es/index.js", "main": "dist/index.js", "source": "src/index.ts", - "files": [ - "dist" - ], + "files": ["dist"], "scripts": { "test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'" }, diff --git a/packages/perseus-core/tsconfig-build.json b/packages/perseus-core/tsconfig-build.json index 950db3d439..bbabd66d20 100644 --- a/packages/perseus-core/tsconfig-build.json +++ b/packages/perseus-core/tsconfig-build.json @@ -6,14 +6,12 @@ "paths": { // NOTE(kevinb): We have to repeat this here because TS doesn't do // intelligent merge of tsconfig.json files when using `extends`. - "@khanacademy/*": [ - "../*/src" - ] - } + "@khanacademy/*": ["../*/src"], + }, }, "references": [ /* Add in-repo pacakge references here, like this: {"path": "../path/to/package/tsconfig-build.json"} */ - ] + ], } diff --git a/packages/perseus-editor/package.json b/packages/perseus-editor/package.json index a4a750b30c..fe728f31d4 100644 --- a/packages/perseus-editor/package.json +++ b/packages/perseus-editor/package.json @@ -27,9 +27,7 @@ }, "./styles.css": "./dist/index.css" }, - "files": [ - "dist" - ], + "files": ["dist"], "scripts": { "test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'" }, diff --git a/packages/perseus-editor/src/__tests__/traversal.test.ts b/packages/perseus-editor/src/__tests__/traversal.test.ts index ee135cd226..5189e440a1 100644 --- a/packages/perseus-editor/src/__tests__/traversal.test.ts +++ b/packages/perseus-editor/src/__tests__/traversal.test.ts @@ -311,9 +311,7 @@ describe("Traversal", () => { content: `${options.content}\n\nnew content!`, }); }); - expect(newOptions.content).toBe( - "[[☃ input-number 1]]\n\nnew content!", - ); + expect(newOptions.content).toBe("[[☃ input-number 1]]\n\nnew content!"); expect(newOptions.widgets).toEqual(sampleOptions.widgets); assertNonMutative(); }); diff --git a/packages/perseus-editor/src/multirenderer-editor.tsx b/packages/perseus-editor/src/multirenderer-editor.tsx index dc4cbe9371..bc8c46af14 100644 --- a/packages/perseus-editor/src/multirenderer-editor.tsx +++ b/packages/perseus-editor/src/multirenderer-editor.tsx @@ -27,7 +27,6 @@ import type { APIOptions, ChangeHandler, EditorMode, - // Multi-item item types Item, // ItemTree is used below, the linter is confused. @@ -37,7 +36,6 @@ import type { ContentNode, HintNode, TagsNode, - // Multi-item shape types Shape, ArrayShape, diff --git a/packages/perseus-editor/tsconfig-build.json b/packages/perseus-editor/tsconfig-build.json index f9d2f0b6ad..cdff10dc32 100644 --- a/packages/perseus-editor/tsconfig-build.json +++ b/packages/perseus-editor/tsconfig-build.json @@ -8,15 +8,13 @@ "hubble": ["../../vendor/hubble/hubble.js"], // NOTE(kevinb): We have to repeat this here because TS doesn't do // intelligent merge of tsconfig.json files when using `extends`. - "@khanacademy/*": [ - "../*/src" - ] - } + "@khanacademy/*": ["../*/src"], + }, }, "references": [ - {"path": "../kas/tsconfig-build.json"}, - {"path": "../kmath/tsconfig-build.json"}, - {"path": "../perseus/tsconfig-build.json"}, - {"path": "../perseus-core/tsconfig-build.json"}, - ] + { "path": "../kas/tsconfig-build.json" }, + { "path": "../kmath/tsconfig-build.json" }, + { "path": "../perseus/tsconfig-build.json" }, + { "path": "../perseus-core/tsconfig-build.json" }, + ], } diff --git a/packages/perseus-linter/package.json b/packages/perseus-linter/package.json index 1107b3604a..28a1cd57b2 100644 --- a/packages/perseus-linter/package.json +++ b/packages/perseus-linter/package.json @@ -18,9 +18,7 @@ "module": "dist/es/index.js", "main": "dist/index.js", "source": "src/index.ts", - "files": [ - "dist" - ], + "files": ["dist"], "scripts": { "test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'" }, diff --git a/packages/perseus-linter/src/__tests__/rules.test.ts b/packages/perseus-linter/src/__tests__/rules.test.ts index fd775fdfd7..b9b7233d73 100644 --- a/packages/perseus-linter/src/__tests__/rules.test.ts +++ b/packages/perseus-linter/src/__tests__/rules.test.ts @@ -654,87 +654,67 @@ describe("Individual lint rules tests", () => { ]); test("Rule static-widget-in-question-stem allows static widgets in hints", () => { - const problems = testRule( - StaticWidgetInQuestionStem, - "[[☃ radio 1]]", - { - contentType: "exercise", - stack: ["hint"], - widgets: { - "radio 1": { - static: true, - }, + const problems = testRule(StaticWidgetInQuestionStem, "[[☃ radio 1]]", { + contentType: "exercise", + stack: ["hint"], + widgets: { + "radio 1": { + static: true, }, }, - ); + }); expect(problems).toBe(null); }); test("Rule static-widget-in-question-stem allows static widgets in articles", () => { - const problems = testRule( - StaticWidgetInQuestionStem, - "[[☃ radio 1]]", - { - contentType: "article", - stack: [], - widgets: { - "radio 1": { - static: true, - }, + const problems = testRule(StaticWidgetInQuestionStem, "[[☃ radio 1]]", { + contentType: "article", + stack: [], + widgets: { + "radio 1": { + static: true, }, }, - ); + }); expect(problems).toBe(null); }); test("Rule static-widget-in-question-stem allows non-static widgets in question stems", () => { - const problems = testRule( - StaticWidgetInQuestionStem, - "[[☃ radio 1]]", - { - contentType: "exercise", - stack: [], - widgets: { - "radio 1": { - static: false, - }, + const problems = testRule(StaticWidgetInQuestionStem, "[[☃ radio 1]]", { + contentType: "exercise", + stack: [], + widgets: { + "radio 1": { + static: false, }, }, - ); + }); expect(problems).toBe(null); }); test("Rule static-widget-in-question-stem tolerates widget with no definition", () => { - const problems = testRule( - StaticWidgetInQuestionStem, - "[[☃ radio 1]]", - { - contentType: "exercise", - stack: [], - widgets: {}, - }, - ); + const problems = testRule(StaticWidgetInQuestionStem, "[[☃ radio 1]]", { + contentType: "exercise", + stack: [], + widgets: {}, + }); expect(problems).toBe(null); }); test("Rule static-widget-in-question-stem allows warns about static widgets in question stems", () => { - const problems = testRule( - StaticWidgetInQuestionStem, - "[[☃ radio 1]]", - { - contentType: "exercise", - stack: [], - widgets: { - "radio 1": { - static: true, - }, + const problems = testRule(StaticWidgetInQuestionStem, "[[☃ radio 1]]", { + contentType: "exercise", + stack: [], + widgets: { + "radio 1": { + static: true, }, }, - ); + }); expect(problems?.length).toBe(1); expect(problems?.[0]?.message).toBe( diff --git a/packages/perseus-linter/src/__tests__/tree-transformer.test.ts b/packages/perseus-linter/src/__tests__/tree-transformer.test.ts index 0d37cb1c7d..a2c8ad2821 100644 --- a/packages/perseus-linter/src/__tests__/tree-transformer.test.ts +++ b/packages/perseus-linter/src/__tests__/tree-transformer.test.ts @@ -62,22 +62,20 @@ describe("PerseusLinter tree transformer", () => { } trees.forEach((tree: any, treenum: number) => { - it( - "does post-order traversal of each node in the tree " + treenum, - () => { - const tt = new TreeTransformer(tree); - const ids: Array = []; - - tt.traverse((n: any) => { - nodes[n.id] = n; // Remember the nodes by id for later tests - ids.push(n.id); - }); + it("does post-order traversal of each node in the tree " + + treenum, () => { + const tt = new TreeTransformer(tree); + const ids: Array = []; - // Post-order traversal means we visit the nodes on the way - // back up, not on the way down. - expect(ids).toEqual(postOrderTraversalOrder); - }, - ); + tt.traverse((n: any) => { + nodes[n.id] = n; // Remember the nodes by id for later tests + ids.push(n.id); + }); + + // Post-order traversal means we visit the nodes on the way + // back up, not on the way down. + expect(ids).toEqual(postOrderTraversalOrder); + }); it("tracks the current node " + treenum, () => { new TreeTransformer(tree).traverse((n, state) => { diff --git a/packages/perseus-linter/tsconfig-build.json b/packages/perseus-linter/tsconfig-build.json index 02a666d614..ae7fa7e2bf 100644 --- a/packages/perseus-linter/tsconfig-build.json +++ b/packages/perseus-linter/tsconfig-build.json @@ -5,7 +5,7 @@ "rootDir": "src", }, "references": [ - {"path": "../perseus-core/tsconfig-build.json"}, - {"path": "../pure-markdown/tsconfig-build.json"}, - ] + { "path": "../perseus-core/tsconfig-build.json" }, + { "path": "../pure-markdown/tsconfig-build.json" }, + ], } diff --git a/packages/perseus/package.json b/packages/perseus/package.json index e2e1a5a39b..730e48ba3d 100644 --- a/packages/perseus/package.json +++ b/packages/perseus/package.json @@ -33,9 +33,7 @@ }, "./styles.css": "./dist/index.css" }, - "files": [ - "dist" - ], + "files": ["dist"], "scripts": { "test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'" }, diff --git a/packages/perseus/src/multi-items/__stories__/multi-renderer.stories.tsx b/packages/perseus/src/multi-items/__stories__/multi-renderer.stories.tsx index 04921926dd..3020171974 100644 --- a/packages/perseus/src/multi-items/__stories__/multi-renderer.stories.tsx +++ b/packages/perseus/src/multi-items/__stories__/multi-renderer.stories.tsx @@ -46,8 +46,10 @@ export const SingleItem = (args: StoryArgs): React.ReactElement => { Hints - {// @ts-expect-error [FEI-5003] - TS2339 - Property 'firstN' does not exist on type 'readonly ReactNode[]'. - hints?.firstN(2)} + { + // @ts-expect-error [FEI-5003] - TS2339 - Property 'firstN' does not exist on type 'readonly ReactNode[]'. + hints?.firstN(2) + } diff --git a/packages/perseus/src/question-paragraph.tsx b/packages/perseus/src/question-paragraph.tsx index 6963fd6053..ac30e391c3 100644 --- a/packages/perseus/src/question-paragraph.tsx +++ b/packages/perseus/src/question-paragraph.tsx @@ -19,7 +19,7 @@ class QuestionParagraph extends React.Component {