@khanacademy/perseus-linter 6.2.0 → 7.0.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.d.ts +2 -1
- package/dist/index.js +1133 -177
- package/dist/index.js.map +1 -1
- package/dist/rule.d.ts +10 -3
- package/dist/rules/all-rules.d.ts +1 -2
- package/dist/rules/explanation-in-graded-group.d.ts +2 -2
- package/dist/rules/expression-widget.d.ts +10 -2
- package/dist/run-linter.d.ts +1 -2
- package/package.json +7 -7
- package/dist/rules/double-spacing-after-terminal.d.ts +0 -3
- package/dist/rules/expression-widget-error.d.ts +0 -3
- package/dist/rules/extra-content-spacing.d.ts +0 -3
- package/dist/rules/image-in-table.d.ts +0 -3
- package/dist/rules/widget-in-table.d.ts +0 -3
package/dist/rule.d.ts
CHANGED
|
@@ -119,16 +119,23 @@
|
|
|
119
119
|
*/
|
|
120
120
|
import Selector from "./selector";
|
|
121
121
|
import type { TraversalState, TreeNode } from "./tree-transformer";
|
|
122
|
+
import type { PerseusWidgetTypes } from "@khanacademy/perseus-core";
|
|
122
123
|
export type MakeRuleOptions = {
|
|
123
124
|
name: string;
|
|
124
125
|
pattern?: RegExp;
|
|
125
|
-
severity
|
|
126
|
+
severity: number;
|
|
126
127
|
selector?: string;
|
|
127
128
|
locale?: string;
|
|
128
129
|
message?: string;
|
|
129
130
|
lint?: (state: TraversalState, content: string, nodes: any, match: any, context: LintRuleContextObject) => LintTesterReturnType;
|
|
130
131
|
applies?: AppliesTester;
|
|
131
132
|
};
|
|
133
|
+
export type MakeWidgetRuleOptions<TWidgetType extends keyof PerseusWidgetTypes> = {
|
|
134
|
+
name: string;
|
|
135
|
+
severity: number;
|
|
136
|
+
widgetType: TWidgetType;
|
|
137
|
+
lint: (widgetInfo: PerseusWidgetTypes[TWidgetType]) => string | undefined;
|
|
138
|
+
};
|
|
132
139
|
type PatternMatchType = any;
|
|
133
140
|
export type LinterWarning = {
|
|
134
141
|
rule: string;
|
|
@@ -167,8 +174,9 @@ export default class Rule {
|
|
|
167
174
|
applies: AppliesTester;
|
|
168
175
|
message: string | null | undefined;
|
|
169
176
|
static DEFAULT_SELECTOR: Selector;
|
|
170
|
-
constructor(name: string | null | undefined, severity: number
|
|
177
|
+
constructor(name: string | null | undefined, severity: number, selector: Selector | null | undefined, pattern: RegExp | null | undefined, lint: LintTester | string | undefined, applies: AppliesTester | undefined);
|
|
171
178
|
static makeRule(options: MakeRuleOptions): Rule;
|
|
179
|
+
static makeWidgetRule<TWidgetType extends keyof PerseusWidgetTypes>(options: MakeWidgetRuleOptions<TWidgetType>): Rule;
|
|
172
180
|
check(node: TreeNode, traversalState: TraversalState, content: string, context: LintRuleContextObject): RuleCheckReturnType;
|
|
173
181
|
_defaultLintFunction(state: TraversalState, content: string, selectorMatch: ReadonlyArray<TreeNode>, patternMatch: PatternMatchType, context: LintRuleContextObject): {
|
|
174
182
|
end: number;
|
|
@@ -178,7 +186,6 @@ export default class Rule {
|
|
|
178
186
|
static makePattern(pattern?: RegExp | string | null): RegExp | null | undefined;
|
|
179
187
|
static FakePatternMatch(input: string, match: string | null | undefined, index: number): PatternMatchType;
|
|
180
188
|
static Severity: {
|
|
181
|
-
BULK_WARNING: number;
|
|
182
189
|
ERROR: number;
|
|
183
190
|
GUIDELINE: number;
|
|
184
191
|
WARNING: number;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
export default _default;
|
|
1
|
+
export declare const allRules: import("..").Rule[];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import Rule from "../rule";
|
|
2
|
-
declare const
|
|
3
|
-
export
|
|
2
|
+
export declare const ExplanationInGradedGroup: Rule;
|
|
3
|
+
export declare const ExplanationInGradedGroupSet: Rule;
|
|
@@ -5,5 +5,13 @@ import Rule from "../rule";
|
|
|
5
5
|
* available in the keypad (desktop learners can use a keyboard,
|
|
6
6
|
* but mobile learners must use the MathInput keypad)
|
|
7
7
|
*/
|
|
8
|
-
declare const
|
|
9
|
-
|
|
8
|
+
export declare const ExpressionWidgetButtons: Rule;
|
|
9
|
+
/**
|
|
10
|
+
* Checks that expression widgets have a correct answer.
|
|
11
|
+
*/
|
|
12
|
+
export declare const ExpressionWidgetCorrectAnswer: Rule;
|
|
13
|
+
/**
|
|
14
|
+
* Checks that each of an expression widget's answers is a parseable
|
|
15
|
+
* expression, and is simplified if the answer requires simplification.
|
|
16
|
+
*/
|
|
17
|
+
export declare const ExpressionWidgetAnswerForms: Rule;
|
package/dist/run-linter.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import Rule from "./rule";
|
|
1
|
+
import type Rule from "./rule";
|
|
2
2
|
import type { LinterWarning } from "./rule";
|
|
3
|
-
export declare const allLintRules: ReadonlyArray<any>;
|
|
4
3
|
/**
|
|
5
4
|
* Run the Perseus linter over the specified markdown parse tree, with the
|
|
6
5
|
* specified context object, and return a (possibly empty) array of lint
|
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": "
|
|
6
|
+
"version": "7.0.0",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@khanacademy/kas": "3.0
|
|
27
|
-
"@khanacademy/kmath": "3.1.
|
|
28
|
-
"@khanacademy/perseus-core": "42.0.
|
|
29
|
-
"@khanacademy/perseus-utils": "3.0.
|
|
30
|
-
"@khanacademy/pure-markdown": "3.1.
|
|
26
|
+
"@khanacademy/kas": "3.1.0",
|
|
27
|
+
"@khanacademy/kmath": "3.1.2",
|
|
28
|
+
"@khanacademy/perseus-core": "42.0.2",
|
|
29
|
+
"@khanacademy/perseus-utils": "3.0.2",
|
|
30
|
+
"@khanacademy/pure-markdown": "3.1.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"
|
|
33
|
+
"@internal/build-settings": "0.9.2"
|
|
34
34
|
},
|
|
35
35
|
"keywords": [],
|
|
36
36
|
"khan": {
|