@khanacademy/perseus-linter 1.0.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/es/index.js +85 -5
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +83 -5
- package/dist/index.js.map +1 -1
- package/dist/rule.d.ts +24 -8
- package/dist/rules/expression-widget.d.ts +9 -0
- package/dist/rules/static-widget-in-question-stem.d.ts +3 -0
- package/dist/tree-transformer.d.ts +2 -0
- package/package.json +2 -2
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
|
|
126
|
-
|
|
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
|
-
|
|
143
|
+
type LintTesterReturnType = string | {
|
|
134
144
|
message: string;
|
|
135
145
|
start: number;
|
|
136
146
|
end: number;
|
|
137
147
|
} | null | undefined;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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:
|
|
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;
|
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.
|
|
6
|
+
"version": "1.2.0",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@khanacademy/perseus-core": "1.5.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@khanacademy/pure-markdown": "^0.3.
|
|
31
|
+
"@khanacademy/pure-markdown": "^0.3.7",
|
|
32
32
|
"prop-types": "15.6.1"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|