@khanacademy/perseus-linter 0.1.0 → 0.2.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/CHANGELOG.md +15 -0
- package/dist/es/index.js +5 -5
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/matcher_test.js +1 -1
- package/src/__tests__/rule_test.js +1 -1
- package/src/__tests__/selector-parser_test.js +1 -1
- package/src/__tests__/tree-transformer_test.js +1 -1
- package/src/index.js +1 -1
- package/src/proptypes.js +2 -2
- package/src/rule.js +3 -3
- package/src/tree-transformer.js +3 -3
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": "0.1
|
|
6
|
+
"version": "0.2.1",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@khanacademy/perseus-error": "^0.1.
|
|
24
|
+
"@khanacademy/perseus-error": "^0.1.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@khanacademy/pure-markdown": "^0.1.
|
|
27
|
+
"@khanacademy/pure-markdown": "^0.1.1"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {},
|
|
30
30
|
"keywords": []
|
|
@@ -8,7 +8,7 @@ import * as PureMarkdown from "@khanacademy/pure-markdown";
|
|
|
8
8
|
import Selector from "../selector.js";
|
|
9
9
|
import TreeTransformer from "../tree-transformer.js";
|
|
10
10
|
|
|
11
|
-
describe("
|
|
11
|
+
describe("PerseusLinter selector matching:", () => {
|
|
12
12
|
const markdown = `
|
|
13
13
|
### A
|
|
14
14
|
|
|
@@ -4,7 +4,7 @@ import * as PureMarkdown from "@khanacademy/pure-markdown";
|
|
|
4
4
|
import Rule from "../rule.js";
|
|
5
5
|
import TreeTransformer from "../tree-transformer.js";
|
|
6
6
|
|
|
7
|
-
describe("
|
|
7
|
+
describe("PerseusLinter lint Rules class", () => {
|
|
8
8
|
const markdown = `
|
|
9
9
|
## This Heading is in Title Case
|
|
10
10
|
|
package/src/index.js
CHANGED
|
@@ -13,7 +13,7 @@ const allLintRules: $ReadOnlyArray<$FlowFixMe> = AllRules.filter(
|
|
|
13
13
|
export {Rule, allLintRules as rules};
|
|
14
14
|
|
|
15
15
|
//
|
|
16
|
-
// Run the
|
|
16
|
+
// Run the Perseus linter over the specified markdown parse tree,
|
|
17
17
|
// with the specified context object, and
|
|
18
18
|
// return a (possibly empty) array of lint warning objects. If the
|
|
19
19
|
// highlight argument is true, this function also modifies the parse
|
package/src/proptypes.js
CHANGED
|
@@ -9,9 +9,9 @@ import type {LinterContextProps} from "./types.js";
|
|
|
9
9
|
export const linterContextProps: React$PropType$Primitive<{
|
|
10
10
|
contentType?: string,
|
|
11
11
|
highlightLint?: boolean,
|
|
12
|
-
// eslint-disable-next-line
|
|
12
|
+
// eslint-disable-next-line ft-flow/no-mutable-array
|
|
13
13
|
paths?: Array<string>,
|
|
14
|
-
// eslint-disable-next-line
|
|
14
|
+
// eslint-disable-next-line ft-flow/no-mutable-array
|
|
15
15
|
stack?: Array<string>,
|
|
16
16
|
...
|
|
17
17
|
}> = PropTypes.shape({
|
package/src/rule.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
/**
|
|
3
|
-
* The Rule class represents a
|
|
3
|
+
* The Rule class represents a Perseus lint rule. A Rule instance has a check()
|
|
4
4
|
* method that takes the same (node, state, content) arguments that a
|
|
5
5
|
* TreeTransformer traversal callback function does. Call the check() method
|
|
6
6
|
* during a tree traversal to determine whether the current node of the tree
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* an error message, and the start and end positions within the node's content
|
|
10
10
|
* string of the lint.
|
|
11
11
|
*
|
|
12
|
-
* A
|
|
12
|
+
* A Perseus lint rule consists of a name, a severity, a selector, a pattern
|
|
13
13
|
* (RegExp) and two functions. The check() method uses the selector, pattern,
|
|
14
14
|
* and functions as follows:
|
|
15
15
|
*
|
|
@@ -178,7 +178,7 @@ export type LintTester = (
|
|
|
178
178
|
export type AppliesTester = (context: LintRuleContextObject) => boolean;
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
|
-
* A Rule object describes a
|
|
181
|
+
* A Rule object describes a Perseus lint rule. See the comment at the top of
|
|
182
182
|
* this file for detailed description.
|
|
183
183
|
*/
|
|
184
184
|
export default class Rule {
|
package/src/tree-transformer.js
CHANGED
|
@@ -117,7 +117,7 @@ export default class TreeTransformer {
|
|
|
117
117
|
// details. Note that this method uses the TraversalState object to store
|
|
118
118
|
// information about the structure of the tree.
|
|
119
119
|
_traverse(
|
|
120
|
-
// eslint-disable-next-line
|
|
120
|
+
// eslint-disable-next-line ft-flow/no-mutable-array
|
|
121
121
|
n: TreeNode | Array<TreeNode>,
|
|
122
122
|
state: TraversalState,
|
|
123
123
|
f: TraversalCallback,
|
|
@@ -243,7 +243,7 @@ export class TraversalState {
|
|
|
243
243
|
// node. This is hard for Flow to deal with, so you'll see a number of
|
|
244
244
|
// Flow casts through the any type when working with these two properties.
|
|
245
245
|
_currentNode: ?TreeNode;
|
|
246
|
-
// eslint-disable-next-line
|
|
246
|
+
// eslint-disable-next-line ft-flow/no-mutable-array
|
|
247
247
|
_containers: Stack<TreeNode | Array<TreeNode>>;
|
|
248
248
|
_indexes: Stack<string | number>;
|
|
249
249
|
_ancestors: Stack<TreeNode>;
|
|
@@ -527,7 +527,7 @@ export class TraversalState {
|
|
|
527
527
|
* the TraversalState class simpler in a number of places.
|
|
528
528
|
*/
|
|
529
529
|
class Stack<T> {
|
|
530
|
-
// eslint-disable-next-line
|
|
530
|
+
// eslint-disable-next-line ft-flow/no-mutable-array
|
|
531
531
|
stack: Array<T>;
|
|
532
532
|
|
|
533
533
|
constructor(array: ?$ReadOnlyArray<T>) {
|