Skip to content

Add Numeric Input widget save warnings to perseus linter#3053

Merged
nishasy merged 7 commits intomainfrom
lint-error-4-numeric-input
Nov 21, 2025
Merged

Add Numeric Input widget save warnings to perseus linter#3053
nishasy merged 7 commits intomainfrom
lint-error-4-numeric-input

Conversation

@nishasy
Copy link
Copy Markdown
Contributor

@nishasy nishasy commented Nov 20, 2025

Summary:

To make sure that save warnings get surfaced, I'm adding them to the Perseus linter. This means that they should also show up as part of the issues panel.

In this PR, I'm adding a linter rule for numeric input widget save warnings.

Issue: https://khanacademy.atlassian.net/browse/LEMS-3643

Test plan:

pnpm jest packages/perseus-linter/src/rules/numeric-input-widget-error.test.ts

Storybook

  • Go to /?path=/story/editors-editorpage--demo
  • Add a numeric input widget
  • Confirm that it has an error saying there's a missing answer
  • Input an answer
  • Confirm that there is no longer an error saying there's a missing answer
  • Select "Required" under "Answer formats are:"
  • Confirm an error shows up saying the answer format is required but one isn't selected
  • Choose a format under "Possible answer formats"
  • Confirm there are no errors
Empty answer error Answer format error Multiple errors No error
Screenshot 2025-11-19 at 4 27 04 PM Screenshot 2025-11-19 at 4 48 01 PM image Screenshot 2025-11-19 at 4 27 11 PM

…nter

To make sure that save warnings get surfaced, I'm adding them to the Perseus linter. This means that they should also show up as part of the issues panel.

In this PR, I'm adding a linter rule for matcher widget save warnings.

Issue: https://khanacademy.atlassian.net/browse/LEMS-3643

Test plan:
`pnpm jest packages/perseus-linter/src/rules/matcher-widget-error.test.ts`

Storybook
- Go to `/?path=/story/editors-editorpage--demo`
- Add a matcher widget
- Type into the blank option in the left or right column
- Confirm that the error shows up in the issues panel
…o perseus linter

To make sure that save warnings get surfaced, I'm adding them to the Perseus linter. This means that they should also show up as part of the issues panel.

In this PR, I'm adding a linter rule for numeric input widget save warnings.

Issue: https://khanacademy.atlassian.net/browse/LEMS-3643

Test plan:
`pnpm jest packages/perseus-linter/src/rules/numeric-input-widget-error.test.ts`

Storybook
- Go to `/?path=/story/editors-editorpage--demo`
- Add a numeric input widget
- Confirm that it has an error saying there's a missing answer
- Input an answer
- Confirm that there is no longer an error saying there's a missing answer
- Select "Required" under "Answer formats are:"
- Confirm an error shows up saying the answer format is required but one isn't selected
- Choose a format under "Possible answer formats"
- Confirm there are no errors
@nishasy nishasy self-assigned this Nov 20, 2025
@github-actions github-actions Bot added schema-change Attached to PRs when we detect Perseus Schema changes in it item-splitting-change labels Nov 20, 2025
(!answer.answerForms || answer.answerForms.length === 0);
if (formatError) {
issues.push(
`Answer ${i + 1} requires a format, but no format was selected`,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the messaging here to make it clearer with Third's help.

@github-actions github-actions Bot removed the schema-change Attached to PRs when we detect Perseus Schema changes in it label Nov 20, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 20, 2025

🗄️ Schema Change: No Changes ✅

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 20, 2025

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (2d53d2f) and published it to npm. You
can install it using the tag PR3053.

Example:

pnpm add @khanacademy/perseus@PR3053

If you are working in Khan Academy's frontend, you can run the below command.

./dev/tools/bump_perseus_version.ts -t PR3053

If you are working in Khan Academy's webapp, you can run the below command.

./dev/tools/bump_perseus_version.js -t PR3053

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 20, 2025

🛠️ Item Splitting: No Changes ✅

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 20, 2025

Size Change: +139 B (+0.03%)

Total Size: 497 kB

Filename Size Change
packages/perseus-linter/dist/es/index.js 7.89 kB +139 B (+1.79%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 20.8 kB
packages/keypad-context/dist/es/index.js 1 kB
packages/kmath/dist/es/index.js 5.98 kB
packages/math-input/dist/es/index.js 99.2 kB
packages/math-input/dist/es/strings.js 1.61 kB
packages/perseus-core/dist/es/index.item-splitting.js 13.1 kB
packages/perseus-core/dist/es/index.js 22.4 kB
packages/perseus-editor/dist/es/index.js 97.9 kB
packages/perseus-score/dist/es/index.js 9.2 kB
packages/perseus-utils/dist/es/index.js 403 B
packages/perseus/dist/es/index.js 202 kB
packages/perseus/dist/es/strings.js 7.73 kB
packages/pure-markdown/dist/es/index.js 1.39 kB
packages/simple-markdown/dist/es/index.js 6.71 kB

compressed-size-action


// If it can't find a definition for the widget it does nothing
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
const widget = context && context.widgets && context.widgets[nodeId];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be easier to read:

const widget = context?.widgets?.[nodeId];

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh I see. You may see this in multiple PRs because it's copy-pasted from other code 😅

Copy link
Copy Markdown
Contributor

@mark-fitzgerald mark-fitzgerald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Soooo helpful. Thank you!

Base automatically changed from lint-error-3-matcher to main November 21, 2025 22:09
@nishasy nishasy merged commit c9066e6 into main Nov 21, 2025
11 checks passed
@nishasy nishasy deleted the lint-error-4-numeric-input branch November 21, 2025 22:18
SonicScrewdriver added a commit that referenced this pull request Nov 24, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @khanacademy/perseus-editor@28.8.0

### Minor Changes

- [#2976](#2976)
[`9f9bb23276`](9f9bb23)
Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! -
Resolving a long-standing Perseus Editor cursor jumping bug by removing
the debounce on changes in the Editor and moving it upstream.

### Patch Changes

- [#3053](#3053)
[`c9066e6ac0`](c9066e6)
Thanks [@nishasy](https://github.com/nishasy)! - Add Numeric Input
widget save warnings to perseus linter


- [#3060](#3060)
[`bae4cfa6f1`](bae4cfa)
Thanks [@nishasy](https://github.com/nishasy)! - Add Label Image widget
save warnings to perseus linter


- [#3052](#3052)
[`5f01d377f4`](5f01d37)
Thanks [@nishasy](https://github.com/nishasy)! - Add Matcher widget save
warnings to perseus linter


- [#3066](#3066)
[`2baef997c0`](2baef99)
Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Sync
Dependencies and Hashes


- [#3058](#3058)
[`58f942cb9c`](58f942c)
Thanks [@nishasy](https://github.com/nishasy)! - Add Python Program
widget save warnings to perseus linter


- [#3061](#3061)
[`022624f6f6`](022624f)
Thanks [@nishasy](https://github.com/nishasy)! - Add Interactive Graph
widget save warnings to perseus linter


- [#3006](#3006)
[`01d273fcfb`](01d273f)
Thanks [@Myranae](https://github.com/Myranae)! - Add catalog hash system
for dependency tracking


- [#3057](#3057)
[`723d2101e7`](723d210)
Thanks [@nishasy](https://github.com/nishasy)! - Add Phet Simulation
widget save warnings to perseus linter

- Updated dependencies
\[[`c9066e6ac0`](c9066e6),
[`bae4cfa6f1`](bae4cfa),
[`5f01d377f4`](5f01d37),
[`2baef997c0`](2baef99),
[`58f942cb9c`](58f942c),
[`022624f6f6`](022624f),
[`01d273fcfb`](01d273f),
[`723d2101e7`](723d210),
[`d697b6439b`](d697b64)]:
    -   @khanacademy/perseus-linter@4.6.0
    -   @khanacademy/perseus@72.2.1
    -   @khanacademy/perseus-core@20.2.1
    -   @khanacademy/math-input@26.2.21
    -   @khanacademy/kas@2.1.5
    -   @khanacademy/keypad-context@3.2.18
    -   @khanacademy/kmath@2.2.18
    -   @khanacademy/perseus-score@8.0.7
    -   @khanacademy/perseus-utils@2.1.3

## @khanacademy/perseus-linter@4.6.0

### Minor Changes

- [#3053](#3053)
[`c9066e6ac0`](c9066e6)
Thanks [@nishasy](https://github.com/nishasy)! - Add Numeric Input
widget save warnings to perseus linter


- [#3060](#3060)
[`bae4cfa6f1`](bae4cfa)
Thanks [@nishasy](https://github.com/nishasy)! - Add Label Image widget
save warnings to perseus linter


- [#3052](#3052)
[`5f01d377f4`](5f01d37)
Thanks [@nishasy](https://github.com/nishasy)! - Add Matcher widget save
warnings to perseus linter


- [#3058](#3058)
[`58f942cb9c`](58f942c)
Thanks [@nishasy](https://github.com/nishasy)! - Add Python Program
widget save warnings to perseus linter


- [#3061](#3061)
[`022624f6f6`](022624f)
Thanks [@nishasy](https://github.com/nishasy)! - Add Interactive Graph
widget save warnings to perseus linter


- [#3057](#3057)
[`723d2101e7`](723d210)
Thanks [@nishasy](https://github.com/nishasy)! - Add Phet Simulation
widget save warnings to perseus linter

### Patch Changes

- [#3006](#3006)
[`01d273fcfb`](01d273f)
Thanks [@Myranae](https://github.com/Myranae)! - Add catalog hash system
for dependency tracking

- Updated dependencies
\[[`bae4cfa6f1`](bae4cfa),
[`58f942cb9c`](58f942c),
[`022624f6f6`](022624f),
[`01d273fcfb`](01d273f),
[`723d2101e7`](723d210)]:
    -   @khanacademy/perseus-core@20.2.1
    -   @khanacademy/kas@2.1.5
    -   @khanacademy/kmath@2.2.18
    -   @khanacademy/perseus-utils@2.1.3

## @khanacademy/kas@2.1.5

### Patch Changes

- [#3006](#3006)
[`01d273fcfb`](01d273f)
Thanks [@Myranae](https://github.com/Myranae)! - Add catalog hash system
for dependency tracking

- Updated dependencies
\[[`01d273fcfb`](01d273f)]:
    -   @khanacademy/perseus-utils@2.1.3

## @khanacademy/keypad-context@3.2.18

### Patch Changes

- [#3006](#3006)
[`01d273fcfb`](01d273f)
Thanks [@Myranae](https://github.com/Myranae)! - Add catalog hash system
for dependency tracking

- Updated dependencies
\[[`bae4cfa6f1`](bae4cfa),
[`58f942cb9c`](58f942c),
[`022624f6f6`](022624f),
[`01d273fcfb`](01d273f),
[`723d2101e7`](723d210)]:
    -   @khanacademy/perseus-core@20.2.1

## @khanacademy/kmath@2.2.18

### Patch Changes

- [#3006](#3006)
[`01d273fcfb`](01d273f)
Thanks [@Myranae](https://github.com/Myranae)! - Add catalog hash system
for dependency tracking

- Updated dependencies
\[[`bae4cfa6f1`](bae4cfa),
[`58f942cb9c`](58f942c),
[`022624f6f6`](022624f),
[`01d273fcfb`](01d273f),
[`723d2101e7`](723d210)]:
    -   @khanacademy/perseus-core@20.2.1
    -   @khanacademy/perseus-utils@2.1.3

## @khanacademy/math-input@26.2.21

### Patch Changes

- [#3066](#3066)
[`2baef997c0`](2baef99)
Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Sync
Dependencies and Hashes


- [#3006](#3006)
[`01d273fcfb`](01d273f)
Thanks [@Myranae](https://github.com/Myranae)! - Add catalog hash system
for dependency tracking

- Updated dependencies
\[[`bae4cfa6f1`](bae4cfa),
[`58f942cb9c`](58f942c),
[`022624f6f6`](022624f),
[`01d273fcfb`](01d273f),
[`723d2101e7`](723d210)]:
    -   @khanacademy/perseus-core@20.2.1
    -   @khanacademy/keypad-context@3.2.18
    -   @khanacademy/perseus-utils@2.1.3

## @khanacademy/perseus@72.2.1

### Patch Changes

- [#3060](#3060)
[`bae4cfa6f1`](bae4cfa)
Thanks [@nishasy](https://github.com/nishasy)! - Add Label Image widget
save warnings to perseus linter


- [#3066](#3066)
[`2baef997c0`](2baef99)
Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Sync
Dependencies and Hashes


- [#3058](#3058)
[`58f942cb9c`](58f942c)
Thanks [@nishasy](https://github.com/nishasy)! - Add Python Program
widget save warnings to perseus linter


- [#3061](#3061)
[`022624f6f6`](022624f)
Thanks [@nishasy](https://github.com/nishasy)! - Add Interactive Graph
widget save warnings to perseus linter


- [#3006](#3006)
[`01d273fcfb`](01d273f)
Thanks [@Myranae](https://github.com/Myranae)! - Add catalog hash system
for dependency tracking


- [#3057](#3057)
[`723d2101e7`](723d210)
Thanks [@nishasy](https://github.com/nishasy)! - Add Phet Simulation
widget save warnings to perseus linter


- [#3038](#3038)
[`d697b6439b`](d697b64)
Thanks [@anakaren-rojas](https://github.com/anakaren-rojas)! - Updates
css to reference new radio data widget name

- Updated dependencies
\[[`c9066e6ac0`](c9066e6),
[`bae4cfa6f1`](bae4cfa),
[`5f01d377f4`](5f01d37),
[`2baef997c0`](2baef99),
[`58f942cb9c`](58f942c),
[`022624f6f6`](022624f),
[`01d273fcfb`](01d273f),
[`723d2101e7`](723d210)]:
    -   @khanacademy/perseus-linter@4.6.0
    -   @khanacademy/perseus-core@20.2.1
    -   @khanacademy/math-input@26.2.21
    -   @khanacademy/kas@2.1.5
    -   @khanacademy/keypad-context@3.2.18
    -   @khanacademy/kmath@2.2.18
    -   @khanacademy/perseus-score@8.0.7
    -   @khanacademy/perseus-utils@2.1.3
    -   @khanacademy/pure-markdown@2.2.3
    -   @khanacademy/simple-markdown@2.1.3

## @khanacademy/perseus-core@20.2.1

### Patch Changes

- [#3060](#3060)
[`bae4cfa6f1`](bae4cfa)
Thanks [@nishasy](https://github.com/nishasy)! - Add Label Image widget
save warnings to perseus linter


- [#3058](#3058)
[`58f942cb9c`](58f942c)
Thanks [@nishasy](https://github.com/nishasy)! - Add Python Program
widget save warnings to perseus linter


- [#3061](#3061)
[`022624f6f6`](022624f)
Thanks [@nishasy](https://github.com/nishasy)! - Add Interactive Graph
widget save warnings to perseus linter


- [#3006](#3006)
[`01d273fcfb`](01d273f)
Thanks [@Myranae](https://github.com/Myranae)! - Add catalog hash system
for dependency tracking


- [#3057](#3057)
[`723d2101e7`](723d210)
Thanks [@nishasy](https://github.com/nishasy)! - Add Phet Simulation
widget save warnings to perseus linter

- Updated dependencies
\[[`01d273fcfb`](01d273f)]:
    -   @khanacademy/kas@2.1.5
    -   @khanacademy/perseus-utils@2.1.3
    -   @khanacademy/pure-markdown@2.2.3

## @khanacademy/perseus-score@8.0.7

### Patch Changes

- [#3006](#3006)
[`01d273fcfb`](01d273f)
Thanks [@Myranae](https://github.com/Myranae)! - Add catalog hash system
for dependency tracking

- Updated dependencies
\[[`bae4cfa6f1`](bae4cfa),
[`58f942cb9c`](58f942c),
[`022624f6f6`](022624f),
[`01d273fcfb`](01d273f),
[`723d2101e7`](723d210)]:
    -   @khanacademy/perseus-core@20.2.1
    -   @khanacademy/kas@2.1.5
    -   @khanacademy/kmath@2.2.18
    -   @khanacademy/perseus-utils@2.1.3

## @khanacademy/perseus-utils@2.1.3

### Patch Changes

- [#3006](#3006)
[`01d273fcfb`](01d273f)
Thanks [@Myranae](https://github.com/Myranae)! - Add catalog hash system
for dependency tracking

## @khanacademy/pure-markdown@2.2.3

### Patch Changes

- [#3006](#3006)
[`01d273fcfb`](01d273f)
Thanks [@Myranae](https://github.com/Myranae)! - Add catalog hash system
for dependency tracking

- Updated dependencies
\[[`01d273fcfb`](01d273f)]:
    -   @khanacademy/perseus-utils@2.1.3
    -   @khanacademy/simple-markdown@2.1.3

## @khanacademy/simple-markdown@2.1.3

### Patch Changes

- [#3006](#3006)
[`01d273fcfb`](01d273f)
Thanks [@Myranae](https://github.com/Myranae)! - Add catalog hash system
for dependency tracking

- Updated dependencies
\[[`01d273fcfb`](01d273f)]:
    -   @khanacademy/perseus-utils@2.1.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants