@khanacademy/perseus-linter 1.1.0 → 1.2.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/rule.d.ts CHANGED
@@ -122,22 +122,37 @@
122
122
  */
123
123
  import Selector from "./selector";
124
124
  import type { TraversalState, TreeNode } from "./tree-transformer";
125
- export type PatternMatchType = any;
126
- export type RuleCheckReturnType = {
125
+ export type MakeRuleOptions = {
126
+ name: string;
127
+ pattern?: RegExp;
128
+ severity?: number;
129
+ selector?: string;
130
+ locale?: string;
131
+ message?: string;
132
+ lint?: (state: TraversalState, content: string, nodes: any, match: any, context: LintRuleContextObject) => string | undefined;
133
+ applies?: AppliesTester;
134
+ };
135
+ type PatternMatchType = any;
136
+ type RuleCheckReturnType = {
127
137
  rule: string;
128
138
  message: string;
129
139
  start: number;
130
140
  end: number;
131
141
  severity?: number;
132
142
  } | null | undefined;
133
- export type LintTesterReturnType = string | {
143
+ type LintTesterReturnType = string | {
134
144
  message: string;
135
145
  start: number;
136
146
  end: number;
137
147
  } | null | undefined;
138
- export type LintRuleContextObject = any | null | undefined;
139
- export type LintTester = (state: TraversalState, content: string, selectorMatch: ReadonlyArray<TreeNode>, patternMatch: PatternMatchType, context: LintRuleContextObject) => LintTesterReturnType;
140
- export type AppliesTester = (context: LintRuleContextObject) => boolean;
148
+ type LintRuleContextObject = {
149
+ content: string;
150
+ contentType: "article" | "exercise";
151
+ stack: string[];
152
+ widgets: any[];
153
+ } | null | undefined;
154
+ type LintTester = (state: TraversalState, content: string, selectorMatch: ReadonlyArray<TreeNode>, patternMatch: PatternMatchType, context: LintRuleContextObject) => LintTesterReturnType;
155
+ type AppliesTester = (context: LintRuleContextObject) => boolean;
141
156
  /**
142
157
  * A Rule object describes a Perseus lint rule. See the comment at the top of
143
158
  * this file for detailed description.
@@ -151,8 +166,8 @@ export default class Rule {
151
166
  applies: AppliesTester;
152
167
  message: string | null | undefined;
153
168
  static DEFAULT_SELECTOR: Selector;
154
- constructor(name: string | null | undefined, severity: number | null | undefined, selector: Selector | null | undefined, pattern: RegExp | null | undefined, lint: LintTester | string, applies: AppliesTester);
155
- static makeRule(options: any): Rule;
169
+ constructor(name: string | null | undefined, severity: number | null | undefined, selector: Selector | null | undefined, pattern: RegExp | null | undefined, lint: LintTester | string | undefined, applies: AppliesTester | undefined);
170
+ static makeRule(options: MakeRuleOptions): Rule;
156
171
  check(node: TreeNode, traversalState: TraversalState, content: string, context: LintRuleContextObject): RuleCheckReturnType;
157
172
  _defaultLintFunction(state: TraversalState, content: string, selectorMatch: ReadonlyArray<TreeNode>, patternMatch: PatternMatchType, context: LintRuleContextObject): {
158
173
  end: number;
@@ -168,3 +183,4 @@ export default class Rule {
168
183
  WARNING: number;
169
184
  };
170
185
  }
186
+ export {};
@@ -0,0 +1,9 @@
1
+ import Rule from "../rule";
2
+ /**
3
+ * Rule to make sure that Expression questions that require
4
+ * a specific math symbol to answer have that math symbol
5
+ * available in the keypad (desktop learners can use a keyboard,
6
+ * but mobile learners must use the MathInput keypad)
7
+ */
8
+ declare const _default: Rule;
9
+ export default _default;
@@ -57,6 +57,8 @@
57
57
  **/
58
58
  export type TreeNode = {
59
59
  type: string;
60
+ widgetType?: string;
61
+ id?: string;
60
62
  };
61
63
  export type TraversalCallback = (node: TreeNode, state: TraversalState, content: string) => void;
62
64
  export default class TreeTransformer {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Linter engine for Perseus",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "1.1.0",
6
+ "version": "1.2.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },