@khanacademy/perseus-linter 3.0.11 → 4.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.
@@ -1,3 +1,2 @@
1
1
  import type { LinterContextProps } from "./types";
2
- export declare const linterContextProps: any;
3
2
  export declare const linterContextDefault: LinterContextProps;
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) => string | undefined;
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 RuleCheckReturnType = {
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
- } | null | undefined;
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,3 @@
1
+ import Rule from "../rule";
2
+ declare const _default: Rule;
3
+ export default _default;
@@ -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
@@ -1,3 +1,7 @@
1
+ /**
2
+ * The shape of the linter context object that is passed through the
3
+ * tree with additional information about what we are checking.
4
+ */
1
5
  export type LinterContextProps = {
2
6
  contentType: string;
3
7
  highlightLint: boolean;
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": "3.0.11",
6
+ "version": "4.0.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -22,7 +22,7 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@khanacademy/perseus-core": "12.1.0",
25
+ "@khanacademy/perseus-core": "14.0.0",
26
26
  "@khanacademy/perseus-utils": "2.0.4"
27
27
  },
28
28
  "devDependencies": {
@@ -31,7 +31,7 @@
31
31
  "perseus-build-settings": "0.6.2"
32
32
  },
33
33
  "peerDependencies": {
34
- "prop-types": "15.6.1"
34
+ "prop-types": "^15.6.1"
35
35
  },
36
36
  "keywords": [],
37
37
  "scripts": {}