@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/index.js CHANGED
@@ -28,7 +28,7 @@ function _interopNamespaceCompat(e) {
28
28
 
29
29
  var KAS__namespace = /*#__PURE__*/_interopNamespaceCompat(KAS);
30
30
 
31
- const libName="@khanacademy/perseus-linter";const libVersion="4.6.11";perseusUtils.addLibraryVersionToPerseusDebug(libName,libVersion);
31
+ const libName="@khanacademy/perseus-linter";const libVersion="4.6.12";perseusUtils.addLibraryVersionToPerseusDebug(libName,libVersion);
32
32
 
33
33
  const linterContextDefault={contentType:"",highlightLint:false,paths:[],stack:[]};
34
34
 
@@ -93,7 +93,11 @@ var ImageWidget = Rule.makeRule({name:"image-widget",severity:Rule.Severity.WARN
93
93
  for accessibility, all images should have a text description.
94
94
  Add a description in the "Alt Text" box of the image widget.`}if(alt.trim().length<8){return `Images should have alt text:
95
95
  for accessibility, all images should have descriptive alt text.
96
- This image's alt text is only ${alt.trim().length} characters long.`}}});
96
+ This image's alt text is only ${alt.trim().length} characters long.`}if(alt.trim().length>150){return `Images should have alt text:
97
+ for accessibility, image alt text should not exceed 150 characters.
98
+ This image's alt text is ${alt.trim().length} characters long.
99
+ Please pair your alt with a long description below if you need significantly
100
+ more text to sufficiently describe the image.`}}});
97
101
 
98
102
  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=perseusCore.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}}}}});
99
103
 
@@ -144,7 +148,7 @@ var PhetSimulationWidgetError = Rule.makeRule({name:"phet-simulation-widget-erro
144
148
 
145
149
  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}});
146
150
 
147
- 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."}}});
151
+ 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}});
148
152
 
149
153
  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).`}}});
150
154