@putout/processor-markdown 9.0.1 → 10.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.
package/README.md CHANGED
@@ -19,9 +19,7 @@ npm i @putout/processor-markdown -D
19
19
 
20
20
  ```json
21
21
  {
22
- "processors": [
23
- "markdown"
24
- ]
22
+ "processors": ["markdown"]
25
23
  }
26
24
  ```
27
25
 
package/lib/markdown.js CHANGED
@@ -4,14 +4,12 @@ import {
4
4
  } from '@putout/processor-json';
5
5
  import stringify from 'remark-stringify';
6
6
  import preset from 'remark-preset-lint-consistent';
7
-
8
7
  import removeDependenciesStatusBadge from './rules/remove-dependencies-status-badge.js';
9
8
  import removeTrailingWhitespacesFromHeading from './rules/remove-trailing-whitespaces-from-heading.js';
10
9
  import mergeHeadingSpceces from './rules/merge-heading-spaces.js';
11
10
  import {run} from './rules/index.js';
12
11
  import {visit} from 'unist-util-visit';
13
12
  import {unified} from 'unified';
14
-
15
13
  import {toPlace} from './parse-place.js';
16
14
  import {initParseStore} from './parse-store.js';
17
15
 
@@ -24,6 +22,7 @@ const plugins = [
24
22
  const parseStore = initParseStore();
25
23
 
26
24
  const text = ({value}) => value;
25
+
27
26
  const stringifyOptions = {
28
27
  bullet: '-',
29
28
  listItemIndent: 'one',
@@ -34,10 +33,7 @@ const stringifyOptions = {
34
33
  },
35
34
  };
36
35
 
37
- export const files = [
38
- '*.md',
39
- ];
40
-
36
+ export const files = ['*.md'];
41
37
  export const find = async (rawSource, options = {}) => {
42
38
  await parseStore.init();
43
39
 
@@ -57,10 +53,8 @@ export const find = async (rawSource, options = {}) => {
57
53
  .use(stringify, stringifyOptions)
58
54
  .process(rawSource);
59
55
 
60
- return messages
61
- .map(toPlace);
56
+ return messages.map(toPlace);
62
57
  };
63
-
64
58
  export const fix = async (rawSource, options = {}) => {
65
59
  await parseStore.init();
66
60
 
@@ -79,7 +73,6 @@ export const fix = async (rawSource, options = {}) => {
79
73
 
80
74
  return value;
81
75
  };
82
-
83
76
  export const branch = async (rawSource) => {
84
77
  const list = [];
85
78
 
@@ -94,7 +87,6 @@ export const branch = async (rawSource) => {
94
87
 
95
88
  return list;
96
89
  };
97
-
98
90
  export const merge = async (rawSource, list) => {
99
91
  const newList = list.slice();
100
92
 
@@ -116,6 +108,7 @@ export const merge = async (rawSource, list) => {
116
108
  const collect = ({list, visit}) => (node) => {
117
109
  visit(node, 'code', (node) => {
118
110
  const {lang, value} = node;
111
+
119
112
  const startLine = node.position.start.line;
120
113
 
121
114
  if (/^(js|javascript)$/.test(lang)) {
@@ -190,4 +183,3 @@ const apply = ({list, visit}) => (node) => {
190
183
  }
191
184
  });
192
185
  };
193
-
@@ -32,4 +32,3 @@ function parseWatermark({reason, ruleId, source}) {
32
32
  rule: `${ruleId} (${source})`,
33
33
  };
34
34
  }
35
-
@@ -28,4 +28,3 @@ export const initParseStore = () => {
28
28
 
29
29
  return fn;
30
30
  };
31
-
@@ -20,4 +20,3 @@ export const run = lintRule('remark-lint:run', (tree, file, options) => {
20
20
  }
21
21
  }
22
22
  });
23
-
@@ -38,10 +38,7 @@ const bothSpaces = (node, nextNode) => {
38
38
  if (node.type !== 'text' || node.value !== ' ')
39
39
  return false;
40
40
 
41
- if (nextNode.type !== 'text' || nextNode.value !== ' ')
42
- return false;
43
-
44
- return true;
41
+ return !(nextNode.type !== 'text' || nextNode.value !== ' ');
45
42
  };
46
43
 
47
44
  export default {
@@ -11,6 +11,7 @@ export default {
11
11
 
12
12
  function fix(node, tree) {
13
13
  const children = tree.children.filter(isDependencyStatus());
14
+
14
15
  tree.children = children;
15
16
 
16
17
  const [heading] = children;
@@ -19,6 +20,7 @@ function fix(node, tree) {
19
20
  return;
20
21
 
21
22
  const headingChildren = heading.children.filter(isDependencyLink);
23
+
22
24
  tree.children[0].children = headingChildren;
23
25
  }
24
26
 
@@ -35,19 +37,12 @@ const isDependencyStatus = (push = noop) => (child) => {
35
37
  return false;
36
38
  }
37
39
 
38
- if (child.label === 'DependencyStatusIMGURL')
39
- return false;
40
-
41
- return true;
40
+ return child.label !== 'DependencyStatusIMGURL';
42
41
  };
43
42
 
44
43
  const isDependencyLink = (child) => {
45
44
  if (child.type !== 'linkReference')
46
45
  return true;
47
46
 
48
- if (child.children[0].label === 'DependencyStatusIMGURL')
49
- return false;
50
-
51
- return true;
47
+ return child.children[0].label !== 'DependencyStatusIMGURL';
52
48
  };
53
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/processor-markdown",
3
- "version": "9.0.1",
3
+ "version": "10.0.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout processor adds ability to parse markdown files and lint JavaScript, JSX, TypeScript and JSON snippets",
@@ -36,7 +36,7 @@
36
36
  "remark-stringify": "^10.0.0",
37
37
  "unified": "^10.0.0",
38
38
  "unified-lint-rule": "^2.1.0",
39
- "unist-util-visit": "^4.0.0"
39
+ "unist-util-visit": "^5.0.0"
40
40
  },
41
41
  "keywords": [
42
42
  "putout",
@@ -44,22 +44,22 @@
44
44
  "markdown"
45
45
  ],
46
46
  "devDependencies": {
47
- "@putout/test": "^6.0.0",
48
- "c8": "^7.5.0",
49
- "escover": "^2.1.2",
47
+ "@putout/test": "^7.0.0",
48
+ "c8": "^8.0.0",
49
+ "escover": "^3.2.3",
50
50
  "eslint": "^8.0.1",
51
- "eslint-plugin-n": "^15.2.4",
52
- "eslint-plugin-putout": "^17.0.0",
51
+ "eslint-plugin-n": "^16.0.0",
52
+ "eslint-plugin-putout": "^19.0.0",
53
53
  "lerna": "^6.0.1",
54
54
  "madcut": "^1.0.0",
55
55
  "madrun": "^9.0.0",
56
56
  "montag": "^1.2.1",
57
- "nodemon": "^2.0.1",
57
+ "nodemon": "^3.0.1",
58
58
  "putout": "*",
59
59
  "supertape": "^8.0.0"
60
60
  },
61
61
  "peerDependencies": {
62
- "putout": ">=29"
62
+ "putout": ">=31"
63
63
  },
64
64
  "engines": {
65
65
  "node": ">=16"