@khanacademy/perseus-linter 3.0.12 → 4.0.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/es/index.js +12 -9
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +3 -29
- package/dist/index.js +9 -11
- package/dist/index.js.map +1 -1
- package/dist/proptypes.d.ts +0 -1
- package/dist/rule.d.ts +7 -3
- package/dist/rules/inaccessible-widget.d.ts +3 -0
- package/dist/run-linter.d.ts +27 -0
- package/dist/types.d.ts +4 -0
- package/package.json +4 -4
package/dist/proptypes.d.ts
CHANGED
package/dist/rule.d.ts
CHANGED
|
@@ -129,21 +129,25 @@ export type MakeRuleOptions = {
|
|
|
129
129
|
selector?: string;
|
|
130
130
|
locale?: string;
|
|
131
131
|
message?: string;
|
|
132
|
-
lint?: (state: TraversalState, content: string, nodes: any, match: any, context: LintRuleContextObject) =>
|
|
132
|
+
lint?: (state: TraversalState, content: string, nodes: any, match: any, context: LintRuleContextObject) => LintTesterReturnType;
|
|
133
133
|
applies?: AppliesTester;
|
|
134
134
|
};
|
|
135
135
|
type PatternMatchType = any;
|
|
136
|
-
type
|
|
136
|
+
export type LinterWarning = {
|
|
137
137
|
rule: string;
|
|
138
138
|
message: string;
|
|
139
139
|
start: number;
|
|
140
140
|
end: number;
|
|
141
|
+
target?: string;
|
|
141
142
|
severity?: number;
|
|
142
|
-
|
|
143
|
+
metadata?: Record<string, any>;
|
|
144
|
+
};
|
|
145
|
+
export type RuleCheckReturnType = LinterWarning | null | undefined;
|
|
143
146
|
type LintTesterReturnType = string | {
|
|
144
147
|
message: string;
|
|
145
148
|
start: number;
|
|
146
149
|
end: number;
|
|
150
|
+
metadata?: Record<string, any>;
|
|
147
151
|
} | null | undefined;
|
|
148
152
|
type LintRuleContextObject = {
|
|
149
153
|
content: string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Rule from "./rule";
|
|
2
|
+
import type { LinterWarning } from "./rule";
|
|
3
|
+
export declare const allLintRules: ReadonlyArray<any>;
|
|
4
|
+
/**
|
|
5
|
+
* Run the Perseus linter over the specified markdown parse tree, with the
|
|
6
|
+
* specified context object, and return a (possibly empty) array of lint
|
|
7
|
+
* warning objects. If the highlight argument is true, this function also
|
|
8
|
+
* modifies the parse tree to add "lint" nodes that can be visually rendered,
|
|
9
|
+
* highlighting the problems for the user. The optional rules argument is an
|
|
10
|
+
* array of Rule objects specifying which lint rules should be applied to this
|
|
11
|
+
* parse tree. When omitted, a default set of rules is used.
|
|
12
|
+
*
|
|
13
|
+
* The context object may have additional properties that some lint rules
|
|
14
|
+
* require:
|
|
15
|
+
*
|
|
16
|
+
* context.content is the source content string that was parsed to create
|
|
17
|
+
* the parse tree.
|
|
18
|
+
*
|
|
19
|
+
* context.widgets is the widgets object associated
|
|
20
|
+
* with the content string
|
|
21
|
+
*
|
|
22
|
+
* TODO: to make this even more general, allow the first argument to be a
|
|
23
|
+
* string and run the parser over it in that case? (but ignore highlight in
|
|
24
|
+
* that case). This would allow the one function to be used for both online
|
|
25
|
+
* linting and batch linting.
|
|
26
|
+
*/
|
|
27
|
+
export declare function runLinter(tree: any, context: any, highlight: boolean, rules?: ReadonlyArray<Rule>): ReadonlyArray<LinterWarning>;
|
package/dist/types.d.ts
CHANGED
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": "4.0.1",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@khanacademy/perseus-core": "
|
|
25
|
+
"@khanacademy/perseus-core": "14.0.1",
|
|
26
26
|
"@khanacademy/perseus-utils": "2.0.4"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"prop-types": "15.6.1",
|
|
30
|
-
"@khanacademy/pure-markdown": "2.0.
|
|
31
|
-
"perseus-build-settings": "0.
|
|
30
|
+
"@khanacademy/pure-markdown": "2.0.6",
|
|
31
|
+
"perseus-build-settings": "0.7.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"prop-types": "^15.6.1"
|