@khanacademy/perseus-linter 1.0.0 → 1.1.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/index.js CHANGED
@@ -1158,6 +1158,27 @@ nested lists are hard to read on mobile devices;
1158
1158
  do not use additional indentation.`
1159
1159
  });
1160
1160
 
1161
+ var StaticWidgetInQuestionStem = Rule.makeRule({
1162
+ name: "static-widget-in-question-stem",
1163
+ severity: Rule.Severity.WARNING,
1164
+ selector: "widget",
1165
+ lint: (state, content, nodes, match, context) => {
1166
+ if (context.contentType !== "exercise") {
1167
+ return;
1168
+ }
1169
+ if (context.stack.includes("hint")) {
1170
+ return;
1171
+ }
1172
+ const widget = context?.widgets?.[state.currentNode().id];
1173
+ if (!widget) {
1174
+ return;
1175
+ }
1176
+ if (widget.static) {
1177
+ return `Widget in question stem is static (non-interactive).`;
1178
+ }
1179
+ }
1180
+ });
1181
+
1161
1182
  var TableMissingCells = Rule.makeRule({
1162
1183
  name: "table-missing-cells",
1163
1184
  severity: Rule.Severity.WARNING,
@@ -1205,7 +1226,7 @@ do not put widgets inside of tables.`
1205
1226
  });
1206
1227
 
1207
1228
  // TODO(davidflanagan):
1208
- var AllRules = [AbsoluteUrl, BlockquotedMath, BlockquotedWidget, DoubleSpacingAfterTerminal, ExtraContentSpacing, HeadingLevel1, HeadingLevelSkip, HeadingSentenceCase, HeadingTitleCase, ImageAltText, ImageInTable, LinkClickHere, LongParagraph, MathAdjacent, MathAlignExtraBreak, MathAlignLinebreaks, MathEmpty, MathFontSize, MathFrac, MathNested, MathStartsWithSpace, MathTextEmpty, NestedLists, TableMissingCells, UnescapedDollar, WidgetInTable, MathWithoutDollars, UnbalancedCodeDelimiters, ImageSpacesAroundUrls, ImageWidget];
1229
+ var AllRules = [AbsoluteUrl, BlockquotedMath, BlockquotedWidget, DoubleSpacingAfterTerminal, ExtraContentSpacing, HeadingLevel1, HeadingLevelSkip, HeadingSentenceCase, HeadingTitleCase, ImageAltText, ImageInTable, LinkClickHere, LongParagraph, MathAdjacent, MathAlignExtraBreak, MathAlignLinebreaks, MathEmpty, MathFontSize, MathFrac, MathNested, MathStartsWithSpace, MathTextEmpty, NestedLists, StaticWidgetInQuestionStem, TableMissingCells, UnescapedDollar, WidgetInTable, MathWithoutDollars, UnbalancedCodeDelimiters, ImageSpacesAroundUrls, ImageWidget];
1209
1230
 
1210
1231
  /**
1211
1232
  * TreeTransformer is a class for traversing and transforming trees. Create a
@@ -1752,7 +1773,7 @@ class Stack {
1752
1773
 
1753
1774
  // This file is processed by a Rollup plugin (replace) to inject the production
1754
1775
  const libName = "@khanacademy/perseus-linter";
1755
- const libVersion = "1.0.0";
1776
+ const libVersion = "1.1.0";
1756
1777
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
1757
1778
 
1758
1779
  // Define the shape of the linter context object that is passed through the