@khanacademy/perseus-linter 5.3.1 → 5.4.0
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 +3 -3
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/rules/sorter-widget-warning.d.ts +0 -1
- package/package.json +3 -3
package/dist/es/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { addLibraryVersionToPerseusDebug } from '@khanacademy/perseus-utils';
|
|
2
|
-
import { PerseusError, Errors, CoreWidgetRegistry, makeSafeUrl } from '@khanacademy/perseus-core';
|
|
2
|
+
import { PerseusError, Errors, CoreWidgetRegistry, makeSafeUrl, SORTER_MAX_CARDS } from '@khanacademy/perseus-core';
|
|
3
3
|
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="5.
|
|
7
|
+
const libName="@khanacademy/perseus-linter";const libVersion="5.4.0";addLibraryVersionToPerseusDebug(libName,libVersion);
|
|
8
8
|
|
|
9
9
|
const linterContextDefault={contentType:"",highlightLint:false,stack:[]};
|
|
10
10
|
|
|
@@ -141,7 +141,7 @@ var RadioWidgetError = Rule.makeRule({name:"radio-widget-error",severity:Rule.Se
|
|
|
141
141
|
|
|
142
142
|
const minCards=2;var SorterWidgetError = Rule.makeRule({name:"sorter-widget-error",severity:Rule.Severity.ERROR,selector:"widget",lint:function(state,content,nodes,match,context){if(state.currentNode().widgetType!=="sorter"){return}const nodeId=state.currentNode().id;if(!nodeId){return}const widget=context?.widgets?.[nodeId];if(!widget){return}const warnings=[];const correct=widget.options.correct??[];if(correct.length<minCards){warnings.push(`Sorter requires at least ${minCards} cards.`);}if(correct.some(card=>card.trim()==="")){warnings.push("Sorter cards cannot be blank.");}return warnings.join("\n\n")}});
|
|
143
143
|
|
|
144
|
-
const
|
|
144
|
+
const sorterMaxIdealCards=5;const sorterMaxHorizontalCards=5;var SorterWidgetWarning = Rule.makeRule({name:"sorter-widget-warning",severity:Rule.Severity.WARNING,selector:"widget",lint:function(state,content,nodes,match,context){if(state.currentNode().widgetType!=="sorter"){return}const nodeId=state.currentNode().id;if(!nodeId){return}const widget=context?.widgets?.[nodeId];if(!widget){return}const warnings=[];const options=widget.options;const{layout,correct=[]}=options;if(correct.length>SORTER_MAX_CARDS){warnings.push(`Sorter cannot have more than ${SORTER_MAX_CARDS} cards.`);}if(layout==="horizontal"&&correct.length>sorterMaxHorizontalCards){warnings.push(`Sorter cannot have more than ${sorterMaxHorizontalCards} cards in horizontal layout.`);}if(correct.length>sorterMaxIdealCards){warnings.push(`Having more than ${sorterMaxIdealCards} cards in Sorter is discouraged.`);}return warnings.join("\n\n")}});
|
|
145
145
|
|
|
146
146
|
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).`}}});
|
|
147
147
|
|