@khanacademy/perseus-linter 0.0.0-PR3061-20251121224217 → 0.0.0-PR3061-20251121231610

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.4.7";perseusUtils.addLibraryVersionToPerseusDebug(libName,libVersion);
31
+ const libName="@khanacademy/perseus-linter";const libVersion="4.5.0";perseusUtils.addLibraryVersionToPerseusDebug(libName,libVersion);
32
32
 
33
33
  const linterContextDefault={contentType:"",highlightLint:false,paths:[],stack:[]};
34
34
 
@@ -99,7 +99,7 @@ var InaccessibleWidget = Rule.makeRule({name:"inaccessible-widget",severity:Rule
99
99
 
100
100
  var InteractiveGraphWidgetError = Rule.makeRule({name:"interactive-graph-widget-error",severity:Rule.Severity.ERROR,selector:"widget",lint:function(state,content,nodes,match,context){if(state.currentNode().widgetType!=="interactive-graph"){return}const nodeId=state.currentNode().id;if(!nodeId){return}const widget=context?.widgets?.[nodeId];if(!widget){return}const issues=[];const{correct,lockedFigures}=widget.options;for(const figure of lockedFigures??[]){if(figure.type==="line"&&kmath.vector.equal(figure.points[0].coord,figure.points[1].coord)){issues.push("Locked line cannot have length 0.");}if(figure.type==="polygon"){if(figure.points.every(point=>kmath.vector.equal(point,figure.points[0]))){issues.push("Locked polygon cannot have all coordinates be the same.");}}if(figure.type==="ellipse"){if(figure.radius[0]<=0||figure.radius[1]<=0){issues.push("Locked ellipse must have positive radius values.");}}}if(correct?.type==="polygon"&&correct.numSides==="unlimited"&&correct.coords==null){issues.push("Polygon must be closed.");}const allIssuesString=issues.join("\n\n");return allIssuesString}});
101
101
 
102
- var LabelImageWidgetError = Rule.makeRule({name:"label-image-widget-error",severity:Rule.Severity.ERROR,selector:"widget",lint:function(state,content,nodes,match,context){if(state.currentNode().widgetType!=="label-image"){return}const nodeId=state.currentNode().id;if(!nodeId){return}const widget=context?.widgets?.[nodeId];if(!widget){return}const warnings=[];const{choices,imageAlt,imageUrl,markers}=widget.options;if(choices.length<2){warnings.push("Question requires at least two answer choices");}if(!imageUrl){warnings.push("Image is not specified for question");}else if(!imageAlt){warnings.push("Question image has no alt text");}if(!markers.length){warnings.push("Question has no markers, to label answers on image");}else {let numNoAnswers=0;let numNoLabels=0;for(const marker of markers){if(!marker.answers.length){numNoAnswers++;}if(!marker.label){numNoLabels++;}}if(numNoAnswers>0){warnings.push(`Question has ${numNoAnswers} markers with no answers selected`);}if(numNoLabels>0){warnings.push(`Question has ${numNoLabels} markers with no ARIA label`);}}const allWarningsString=warnings.join("\n\n");return allWarningsString}});
102
+ var LabelImageWidgetError = Rule.makeRule({name:"label-image-widget-error",severity:Rule.Severity.ERROR,selector:"widget",lint:function(state,content,nodes,match,context){if(state.currentNode().widgetType!=="label-image"){return}const nodeId=state.currentNode().id;if(!nodeId){return}const widget=context?.widgets?.[nodeId];if(!widget){return}const warnings=[];const{choices,imageAlt,imageUrl,markers}=widget.options;if(choices.length<2){warnings.push("label-image widget must have at least two answer choices");}if(!imageUrl){warnings.push("No image url provided");}else if(!imageAlt){warnings.push("No image alt text provided");}if(!markers.length){warnings.push("label-image widget requires at least one marker");}else {let numNoAnswers=0;let numNoLabels=0;for(const marker of markers){if(!marker.answers.length){numNoAnswers++;}if(!marker.label){numNoLabels++;}}if(numNoAnswers>0){warnings.push(`label-image widget has ${numNoAnswers} markers with no answers selected`);}if(numNoLabels>0){warnings.push(`label-image widget has ${numNoLabels} markers with no ARIA label`);}}const allWarningsString=warnings.join("\n\n");return allWarningsString}});
103
103
 
104
104
  var LinkClickHere = Rule.makeRule({name:"link-click-here",severity:Rule.Severity.WARNING,selector:"link",pattern:/click here/i,message:`Inappropriate link text:
105
105
  Do not use the words "click here" in links.`});
@@ -108,7 +108,7 @@ var LongParagraph = Rule.makeRule({name:"long-paragraph",severity:Rule.Severity.
108
108
  This paragraph is ${content.length} characters long.
109
109
  Shorten it to 500 characters or fewer.`}});
110
110
 
111
- var MatcherWidgetError = Rule.makeRule({name:"matcher-widget-error",severity:Rule.Severity.ERROR,selector:"widget",lint:function(state,content,nodes,match,context){if(state.currentNode().widgetType!=="matcher"){return}const nodeId=state.currentNode().id;if(!nodeId){return}const widget=context&&context.widgets&&context.widgets[nodeId];if(!widget){return}if(widget.options.left.length!==widget.options.right.length){return "The two halves of the matcher have different numbers of cards."}}});
111
+ var MatcherWidgetError = Rule.makeRule({name:"matcher-widget-error",severity:Rule.Severity.ERROR,selector:"widget",lint:function(state,content,nodes,match,context){if(state.currentNode().widgetType!=="matcher"){return}const nodeId=state.currentNode().id;if(!nodeId){return}const widget=context?.widgets?.[nodeId];if(!widget){return}if(widget.options.left.length!==widget.options.right.length){return "The two halves of the matcher have different numbers of cards."}}});
112
112
 
113
113
  var MathAdjacent = Rule.makeRule({name:"math-adjacent",severity:Rule.Severity.WARNING,selector:"blockMath+blockMath",message:`Adjacent math blocks:
114
114
  combine the blocks between \\begin{align} and \\end{align}`});