@khanacademy/perseus-linter 0.0.0-PR875-20240813215114 → 0.0.0-PR875-20250222011102
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/LICENSE +18 -0
- package/dist/es/index.js +138 -33
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +135 -18
- package/dist/index.js.map +1 -1
- package/dist/proptypes.d.ts +1 -7
- package/dist/rule.d.ts +24 -8
- package/dist/rules/expression-widget.d.ts +9 -0
- package/dist/rules/lint-utils.d.ts +0 -1
- package/dist/shared-utils/add-library-version-to-perseus-debug.d.ts +9 -0
- package/dist/tree-transformer.d.ts +3 -1
- package/package.json +35 -37
- /package/dist/rules/{math-font-size.d.ts → image-url-empty.d.ts} +0 -0
package/dist/proptypes.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import PropTypes from "prop-types";
|
|
2
1
|
import type { LinterContextProps } from "./types";
|
|
3
|
-
export declare const linterContextProps:
|
|
4
|
-
contentType: PropTypes.Requireable<string>;
|
|
5
|
-
highlightLint: PropTypes.Requireable<boolean>;
|
|
6
|
-
paths: PropTypes.Requireable<(string | null | undefined)[]>;
|
|
7
|
-
stack: PropTypes.Requireable<(string | null | undefined)[]>;
|
|
8
|
-
}>>;
|
|
2
|
+
export declare const linterContextProps: any;
|
|
9
3
|
export declare const linterContextDefault: LinterContextProps;
|
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;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds the given perseus library version information to the __perseus_debug__
|
|
3
|
+
* object and ensures that the object is attached to `globalThis` (`window` in
|
|
4
|
+
* browser environments).
|
|
5
|
+
*
|
|
6
|
+
* This allows each library to provide runtime version information to assist in
|
|
7
|
+
* debugging in production environments.
|
|
8
|
+
*/
|
|
9
|
+
export declare const addLibraryVersionToPerseusDebug: (libraryName: string, libraryVersion: string) => void;
|
|
@@ -57,8 +57,10 @@
|
|
|
57
57
|
**/
|
|
58
58
|
export type TreeNode = {
|
|
59
59
|
type: string;
|
|
60
|
+
widgetType?: string;
|
|
61
|
+
id?: string;
|
|
60
62
|
};
|
|
61
|
-
|
|
63
|
+
type TraversalCallback = (node: TreeNode, state: TraversalState, content: string) => void;
|
|
62
64
|
export default class TreeTransformer {
|
|
63
65
|
root: TreeNode;
|
|
64
66
|
constructor(root: TreeNode);
|
package/package.json
CHANGED
|
@@ -1,38 +1,36 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"keywords": []
|
|
38
|
-
}
|
|
2
|
+
"name": "@khanacademy/perseus-linter",
|
|
3
|
+
"description": "Linter engine for Perseus",
|
|
4
|
+
"author": "Khan Academy",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"version": "0.0.0-PR875-20250222011102",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/Khan/perseus.git",
|
|
13
|
+
"directory": "packages/perseus-linter"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/Khan/perseus/issues"
|
|
17
|
+
},
|
|
18
|
+
"module": "dist/es/index.js",
|
|
19
|
+
"main": "dist/index.js",
|
|
20
|
+
"source": "src/index.ts",
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@khanacademy/perseus-core": "0.0.0-PR875-20250222011102"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"prop-types": "15.6.1",
|
|
29
|
+
"@khanacademy/pure-markdown": "0.0.0-PR875-20250222011102"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"prop-types": "15.6.1"
|
|
33
|
+
},
|
|
34
|
+
"keywords": [],
|
|
35
|
+
"scripts": {}
|
|
36
|
+
}
|
|
File without changes
|