@khanacademy/perseus-linter 4.6.11 → 4.6.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/es/index.js CHANGED
@@ -4,7 +4,7 @@ import * as KAS from '@khanacademy/kas';
4
4
  import { parse, traverseContent } from '@khanacademy/pure-markdown';
5
5
  import { vector } from '@khanacademy/kmath';
6
6
 
7
- const libName="@khanacademy/perseus-linter";const libVersion="4.6.11";addLibraryVersionToPerseusDebug(libName,libVersion);
7
+ const libName="@khanacademy/perseus-linter";const libVersion="4.6.12";addLibraryVersionToPerseusDebug(libName,libVersion);
8
8
 
9
9
  const linterContextDefault={contentType:"",highlightLint:false,paths:[],stack:[]};
10
10
 
@@ -69,7 +69,11 @@ var ImageWidget = Rule.makeRule({name:"image-widget",severity:Rule.Severity.WARN
69
69
  for accessibility, all images should have a text description.
70
70
  Add a description in the "Alt Text" box of the image widget.`}if(alt.trim().length<8){return `Images should have alt text:
71
71
  for accessibility, all images should have descriptive alt text.
72
- This image's alt text is only ${alt.trim().length} characters long.`}}});
72
+ This image's alt text is only ${alt.trim().length} characters long.`}if(alt.trim().length>150){return `Images should have alt text:
73
+ for accessibility, image alt text should not exceed 150 characters.
74
+ This image's alt text is ${alt.trim().length} characters long.
75
+ Please pair your alt with a long description below if you need significantly
76
+ more text to sufficiently describe the image.`}}});
73
77
 
74
78
  var InaccessibleWidget = Rule.makeRule({name:"inaccessible-widget",severity:Rule.Severity.WARNING,selector:"widget",lint:function(state,content,nodes,match,context){const node=state.currentNode();const widgetType=node.widgetType;const widgetId=node.id;if(!widgetType||!widgetId){return}const widgetInfo=context?.widgets?.[widgetId];if(!widgetInfo){return}const accessible=CoreWidgetRegistry.isAccessible(widgetType,widgetInfo.options);if(!accessible){return {message:`The "${widgetType}" widget is not accessible.`,start:0,end:content.length,metadata:{widgetType:widgetType,widgetId:widgetId}}}}});
75
79
 
@@ -120,7 +124,7 @@ var PhetSimulationWidgetError = Rule.makeRule({name:"phet-simulation-widget-erro
120
124
 
121
125
  var PythonProgramWidgetError = Rule.makeRule({name:"python-program-widget-error",severity:Rule.Severity.ERROR,selector:"widget",lint:function(state,content,nodes,match,context){if(state.currentNode().widgetType!=="python-program"){return}const nodeId=state.currentNode().id;if(!nodeId){return}const widget=context?.widgets?.[nodeId];if(!widget){return}const errors=[];const height=widget.options.height;const programID=widget.options.programID;if(programID===""){errors.push("The program ID is required.");}if(!Number.isInteger(height)||height<1){errors.push("The height must be a positive integer.");}const allErrorsString=errors.join("\n\n");return allErrorsString}});
122
126
 
123
- var RadioWidgetError = Rule.makeRule({name:"radio-widget-error",severity:Rule.Severity.ERROR,selector:"widget",lint:function(state,content,nodes,match,context){if(state.currentNode().widgetType!=="radio"){return}const nodeId=state.currentNode().id;if(!nodeId){return}const widget=context?.widgets?.[nodeId];if(!widget){return}const choices=widget.options.choices;if(!choices.some(choice=>choice.correct)){return "No choice is marked as correct."}}});
127
+ var RadioWidgetError = Rule.makeRule({name:"radio-widget-error",severity:Rule.Severity.ERROR,selector:"widget",lint:function(state,content,nodes,match,context){if(state.currentNode().widgetType!=="radio"){return}const nodeId=state.currentNode().id;if(!nodeId){return}const widget=context?.widgets?.[nodeId];if(!widget){return}const choices=widget.options.choices;if(!choices.some(choice=>choice.correct)){return "No choice is marked as correct."}const correctChoices=choices.filter(choice=>choice.correct);const hasNotaCorrect=correctChoices.some(choice=>choice.isNoneOfTheAbove);if(hasNotaCorrect&&correctChoices.length>1){return "Cannot mark both None of the Above and another choice as correct."}return}});
124
128
 
125
129
  var StaticWidgetInQuestionStem = Rule.makeRule({name:"static-widget-in-question-stem",severity:Rule.Severity.WARNING,selector:"widget",lint:(state,content,nodes,match,context)=>{if(context?.contentType!=="exercise"){return}if(context.stack.includes("hint")){return}const nodeId=state.currentNode().id;if(!nodeId){return}const widget=context?.widgets?.[nodeId];if(!widget){return}if(widget.static){return `Widget in question stem is static (non-interactive).`}}});
126
130