@khanacademy/perseus-linter 5.1.7 → 5.1.9

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="5.1.7";perseusUtils.addLibraryVersionToPerseusDebug(libName,libVersion);
31
+ const libName="@khanacademy/perseus-linter";const libVersion="5.1.9";perseusUtils.addLibraryVersionToPerseusDebug(libName,libVersion);
32
32
 
33
33
  const linterContextDefault={contentType:"",highlightLint:false,stack:[]};
34
34
 
@@ -105,7 +105,7 @@ Please use the "Reset to original size" button to set the size of the image.`}}}
105
105
 
106
106
  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}}}}});
107
107
 
108
- 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,graph,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.");}if(graph?.type==="exponential"&&graph.startCoords!=null){const{coords,asymptote}=graph.startCoords;const asymptoteY=asymptote;const minY=Math.min(coords[0][1],coords[1][1]);const maxY=Math.max(coords[0][1],coords[1][1]);if(asymptoteY>=minY&&asymptoteY<=maxY){issues.push("The exponential start asymptote must not fall between or on the curve's start points.");}}checkShowPointLabelsHasLabels(graph,issues);checkShowPointLabelsHasLabels(correct,issues);const allIssuesString=issues.join("\n\n");return allIssuesString}});function checkShowPointLabelsHasLabels(g,issues){if(g==null||g.type==="none"||g.type==="vector"){return}if(g.showPointLabels!==true){return}const labels=g.pointLabels;if(labels==null||labels.length===0){issues.push("showPointLabels is true but pointLabels is missing. Provide a label for every point.");return}if(labels.some(l=>l==null||l==="")){issues.push("showPointLabels is true but pointLabels has empty entries. Provide a label for every point.");}}
108
+ 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,graph,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.");}if(graph?.type==="exponential"&&graph.startCoords!=null){const{coords,asymptote}=graph.startCoords;const asymptoteY=asymptote;const minY=Math.min(coords[0][1],coords[1][1]);const maxY=Math.max(coords[0][1],coords[1][1]);if(asymptoteY>=minY&&asymptoteY<=maxY){issues.push("The exponential start asymptote must not fall between or on the curve's start points.");}}checkShowPointLabelsHasLabels(graph,issues);checkShowPointLabelsHasLabels(correct,issues);const allIssuesString=issues.join("\n\n");return allIssuesString}});function checkShowPointLabelsHasLabels(g,issues){if(g==null||g.type==="none"||g.type==="vector"){return}if(g.showPointLabels!==true){return}const labels=g.pointLabels;if(labels===undefined||labels.every(l=>l==null||l==="")){issues.push("showPointLabels is true but pointLabels has no labels. Provide a label for at least one point.");}}
109
109
 
110
110
  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}});
111
111