@khanacademy/perseus-linter 8.2.1 → 8.3.1
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/help-links.d.ts +8 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +180 -143
- package/dist/index.js.map +1 -1
- package/dist/rule.d.ts +16 -4
- package/dist/rules/table-empty-column-header.d.ts +4 -0
- package/package.json +3 -3
package/dist/rule.d.ts
CHANGED
|
@@ -44,17 +44,27 @@
|
|
|
44
44
|
import Selector from "./selector";
|
|
45
45
|
import type { Lint } from "./lint";
|
|
46
46
|
import type { TraversalState, TreeNode } from "./tree-transformer";
|
|
47
|
-
import type { PerseusWidgetTypes } from "@khanacademy/perseus-core";
|
|
47
|
+
import type { PerseusWidgetsMap, PerseusWidgetTypes } from "@khanacademy/perseus-core";
|
|
48
|
+
/**
|
|
49
|
+
* A link to additional documentation or explanation for a lint rule.
|
|
50
|
+
*/
|
|
51
|
+
export type LintHelpLink = {
|
|
52
|
+
/** The link's visible text, e.g. "Learn more about [rule]" */
|
|
53
|
+
text: string;
|
|
54
|
+
url: string;
|
|
55
|
+
};
|
|
48
56
|
export type MakeRuleOptions = {
|
|
49
57
|
name: string;
|
|
50
58
|
pattern?: RegExp;
|
|
51
59
|
selector?: string;
|
|
52
60
|
locale?: string;
|
|
61
|
+
helpLink?: LintHelpLink;
|
|
53
62
|
lint: LintTester;
|
|
54
63
|
};
|
|
55
64
|
export type MakeWidgetRuleOptions<TWidgetType extends keyof PerseusWidgetTypes> = {
|
|
56
65
|
name: string;
|
|
57
66
|
widgetType: TWidgetType;
|
|
67
|
+
helpLink?: LintHelpLink;
|
|
58
68
|
lint: (widgetInfo: PerseusWidgetTypes[TWidgetType], context: any) => undefined | Lint | Lint[];
|
|
59
69
|
};
|
|
60
70
|
export type MakeLintFunctionOptions = {
|
|
@@ -70,12 +80,13 @@ export type LinterIssue = {
|
|
|
70
80
|
target?: string;
|
|
71
81
|
severity: number;
|
|
72
82
|
metadata?: Record<string, any>;
|
|
83
|
+
helpLink: LintHelpLink;
|
|
73
84
|
};
|
|
74
|
-
type LintRuleContextObject = {
|
|
85
|
+
export type LintRuleContextObject = {
|
|
75
86
|
content: string;
|
|
76
87
|
contentType: "article" | "exercise";
|
|
77
88
|
stack: string[];
|
|
78
|
-
widgets:
|
|
89
|
+
widgets: PerseusWidgetsMap;
|
|
79
90
|
} | null | undefined;
|
|
80
91
|
type LintTester = (state: TraversalState, content: string, selectorMatch: ReadonlyArray<TreeNode>, patternMatch: PatternMatchType, context: LintRuleContextObject) => Lint | Lint[] | undefined;
|
|
81
92
|
/**
|
|
@@ -87,8 +98,9 @@ export default class Rule {
|
|
|
87
98
|
selector: Selector;
|
|
88
99
|
pattern: RegExp | null | undefined;
|
|
89
100
|
lint: LintTester;
|
|
101
|
+
helpLink: LintHelpLink;
|
|
90
102
|
static DEFAULT_SELECTOR: Selector;
|
|
91
|
-
constructor(name: string | null | undefined, selector: Selector | null | undefined, pattern: RegExp | null | undefined, lint: LintTester);
|
|
103
|
+
constructor(name: string | null | undefined, selector: Selector | null | undefined, pattern: RegExp | null | undefined, lint: LintTester, helpLink?: LintHelpLink);
|
|
92
104
|
static makeRule(options: MakeRuleOptions): Rule;
|
|
93
105
|
static makeWidgetRule<TWidgetType extends keyof PerseusWidgetTypes>(options: MakeWidgetRuleOptions<TWidgetType>): Rule;
|
|
94
106
|
check(node: TreeNode, traversalState: TraversalState, content: string, context: LintRuleContextObject): LinterIssue[];
|
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": "8.
|
|
6
|
+
"version": "8.3.1",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@khanacademy/kas": "3.1.1",
|
|
27
|
-
"@khanacademy/kmath": "3.1.
|
|
28
|
-
"@khanacademy/perseus-core": "
|
|
27
|
+
"@khanacademy/kmath": "3.1.11",
|
|
28
|
+
"@khanacademy/perseus-core": "43.0.0",
|
|
29
29
|
"@khanacademy/perseus-utils": "3.0.2",
|
|
30
30
|
"@khanacademy/pure-markdown": "4.0.0"
|
|
31
31
|
},
|