@khanacademy/perseus-linter 0.3.3 → 0.3.5
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/CHANGELOG.md +17 -0
- package/dist/es/index.js +31 -25
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +25 -0
- package/dist/index.js +31 -24
- package/dist/index.js.map +1 -1
- package/dist/version.d.ts +1 -0
- package/package.json +4 -3
- package/src/index.ts +26 -24
- package/src/version.ts +10 -0
- package/tsconfig-build.json +1 -0
- package/tsconfig-build.tsbuildinfo +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
import Rule from "./rule";
|
|
2
|
+
export { libVersion } from "./version";
|
|
2
3
|
export { linterContextProps, linterContextDefault } from "./proptypes";
|
|
3
4
|
export type { LinterContextProps } from "./types";
|
|
4
5
|
declare const allLintRules: ReadonlyArray<any>;
|
|
5
6
|
export { Rule, allLintRules as rules };
|
|
7
|
+
/**
|
|
8
|
+
* Run the Perseus linter over the specified markdown parse tree,
|
|
9
|
+
* with the specified context object, and
|
|
10
|
+
* return a (possibly empty) array of lint warning objects. If the
|
|
11
|
+
* highlight argument is true, this function also modifies the parse
|
|
12
|
+
* tree to add "lint" nodes that can be visually rendered,
|
|
13
|
+
* highlighting the problems for the user. The optional rules argument
|
|
14
|
+
* is an array of Rule objects specifying which lint rules should be
|
|
15
|
+
* applied to this parse tree. When omitted, a default set of rules is used.
|
|
16
|
+
*
|
|
17
|
+
* The context object may have additional properties that some lint
|
|
18
|
+
* rules require:
|
|
19
|
+
*
|
|
20
|
+
* context.content is the source content string that was parsed to create
|
|
21
|
+
* the parse tree.
|
|
22
|
+
*
|
|
23
|
+
* context.widgets is the widgets object associated
|
|
24
|
+
* with the content string
|
|
25
|
+
*
|
|
26
|
+
* TODO: to make this even more general, allow the first argument to be
|
|
27
|
+
* a string and run the parser over it in that case? (but ignore highlight
|
|
28
|
+
* in that case). This would allow the one function to be used for both
|
|
29
|
+
* online linting and batch linting.
|
|
30
|
+
*/
|
|
6
31
|
export declare function runLinter(tree: any, context: any, highlight: boolean, rules?: ReadonlyArray<any>): ReadonlyArray<any>;
|
|
7
32
|
export declare function pushContextStack(context: any, name: string): any;
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var perseusError = require('@khanacademy/perseus-error');
|
|
6
|
+
var perseusCore = require('@khanacademy/perseus-core');
|
|
6
7
|
var PropTypes = require('prop-types');
|
|
7
8
|
|
|
8
9
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -1550,6 +1551,11 @@ class Stack {
|
|
|
1550
1551
|
}
|
|
1551
1552
|
}
|
|
1552
1553
|
|
|
1554
|
+
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
1555
|
+
const libName = "@khanacademy/perseus-linter";
|
|
1556
|
+
const libVersion = "0.3.5";
|
|
1557
|
+
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
1558
|
+
|
|
1553
1559
|
// Define the shape of the linter context object that is passed through the
|
|
1554
1560
|
const linterContextProps = PropTypes__default["default"].shape({
|
|
1555
1561
|
contentType: PropTypes__default["default"].string,
|
|
@@ -1566,30 +1572,30 @@ const linterContextDefault = {
|
|
|
1566
1572
|
|
|
1567
1573
|
const allLintRules = AllRules.filter(r => r.severity < Rule.Severity.BULK_WARNING);
|
|
1568
1574
|
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1575
|
+
/**
|
|
1576
|
+
* Run the Perseus linter over the specified markdown parse tree,
|
|
1577
|
+
* with the specified context object, and
|
|
1578
|
+
* return a (possibly empty) array of lint warning objects. If the
|
|
1579
|
+
* highlight argument is true, this function also modifies the parse
|
|
1580
|
+
* tree to add "lint" nodes that can be visually rendered,
|
|
1581
|
+
* highlighting the problems for the user. The optional rules argument
|
|
1582
|
+
* is an array of Rule objects specifying which lint rules should be
|
|
1583
|
+
* applied to this parse tree. When omitted, a default set of rules is used.
|
|
1584
|
+
*
|
|
1585
|
+
* The context object may have additional properties that some lint
|
|
1586
|
+
* rules require:
|
|
1587
|
+
*
|
|
1588
|
+
* context.content is the source content string that was parsed to create
|
|
1589
|
+
* the parse tree.
|
|
1590
|
+
*
|
|
1591
|
+
* context.widgets is the widgets object associated
|
|
1592
|
+
* with the content string
|
|
1593
|
+
*
|
|
1594
|
+
* TODO: to make this even more general, allow the first argument to be
|
|
1595
|
+
* a string and run the parser over it in that case? (but ignore highlight
|
|
1596
|
+
* in that case). This would allow the one function to be used for both
|
|
1597
|
+
* online linting and batch linting.
|
|
1598
|
+
*/
|
|
1593
1599
|
function runLinter(tree, context, highlight) {
|
|
1594
1600
|
let rules = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : allLintRules;
|
|
1595
1601
|
const warnings = [];
|
|
@@ -1822,6 +1828,7 @@ function pushContextStack(context, name) {
|
|
|
1822
1828
|
}
|
|
1823
1829
|
|
|
1824
1830
|
exports.Rule = Rule;
|
|
1831
|
+
exports.libVersion = libVersion;
|
|
1825
1832
|
exports.linterContextDefault = linterContextDefault;
|
|
1826
1833
|
exports.linterContextProps = linterContextProps;
|
|
1827
1834
|
exports.pushContextStack = pushContextStack;
|