@putout/processor-markdown 7.0.1 → 7.2.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/lib/markdown.js +41 -8
- package/lib/rules/{index.mjs → index.js} +1 -14
- package/lib/rules/{merge-heading-spaces.mjs → merge-heading-spaces.js} +0 -0
- package/lib/rules/{remove-dependencies-status-badge.mjs → remove-dependencies-status-badge.js} +0 -0
- package/lib/rules/{remove-trailing-whitespaces-from-heading.mjs → remove-trailing-whitespaces-from-heading.js} +0 -0
- package/package.json +4 -2
package/lib/markdown.js
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
toJS,
|
|
3
|
+
fromJS,
|
|
4
|
+
} from '@putout/processor-json';
|
|
2
5
|
import stringify from 'remark-stringify';
|
|
3
6
|
import preset from 'remark-preset-lint-consistent';
|
|
4
7
|
|
|
5
|
-
import
|
|
8
|
+
import removeDependenciesStatusBadge from './rules/remove-dependencies-status-badge.js';
|
|
9
|
+
import removeTrailingWhitespacesFromHeading from './rules/remove-trailing-whitespaces-from-heading.js';
|
|
10
|
+
import mergeHeadingSpceces from './rules/merge-heading-spaces.js';
|
|
11
|
+
|
|
12
|
+
const plugins = [
|
|
13
|
+
removeDependenciesStatusBadge,
|
|
14
|
+
removeTrailingWhitespacesFromHeading,
|
|
15
|
+
mergeHeadingSpceces,
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
import {run} from './rules/index.js';
|
|
6
19
|
import {visit} from 'unist-util-visit';
|
|
7
20
|
import {unified} from 'unified';
|
|
8
21
|
|
|
@@ -32,7 +45,7 @@ export const find = async (rawSource) => {
|
|
|
32
45
|
const {messages} = await unified()
|
|
33
46
|
.use(parseStore)
|
|
34
47
|
.use(preset)
|
|
35
|
-
.use(run, {fix: false})
|
|
48
|
+
.use(run, {plugins, fix: false})
|
|
36
49
|
.use(stringify, stringifyOptions)
|
|
37
50
|
.process(rawSource);
|
|
38
51
|
|
|
@@ -46,7 +59,7 @@ export const fix = async (rawSource) => {
|
|
|
46
59
|
const {value} = await unified()
|
|
47
60
|
.use(parseStore)
|
|
48
61
|
.use(preset)
|
|
49
|
-
.use(run, {fix: true})
|
|
62
|
+
.use(run, {plugins, fix: true})
|
|
50
63
|
.use(stringify, stringifyOptions)
|
|
51
64
|
.process(rawSource);
|
|
52
65
|
|
|
@@ -101,6 +114,16 @@ const collect = ({list, visit}) => (node) => {
|
|
|
101
114
|
return;
|
|
102
115
|
}
|
|
103
116
|
|
|
117
|
+
if (lang === 'jsx') {
|
|
118
|
+
list.push({
|
|
119
|
+
startLine,
|
|
120
|
+
source: value,
|
|
121
|
+
extension: 'jsx',
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
104
127
|
if (/^(ts|typescript)$/.test(lang)) {
|
|
105
128
|
list.push({
|
|
106
129
|
startLine,
|
|
@@ -111,8 +134,18 @@ const collect = ({list, visit}) => (node) => {
|
|
|
111
134
|
return;
|
|
112
135
|
}
|
|
113
136
|
|
|
137
|
+
if (lang === 'tsx') {
|
|
138
|
+
list.push({
|
|
139
|
+
startLine,
|
|
140
|
+
source: value,
|
|
141
|
+
extension: 'tsx',
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
114
147
|
if (lang === 'json') {
|
|
115
|
-
const source =
|
|
148
|
+
const source = toJS(value);
|
|
116
149
|
|
|
117
150
|
list.push({
|
|
118
151
|
startLine,
|
|
@@ -127,12 +160,12 @@ const apply = ({list, visit}) => (node) => {
|
|
|
127
160
|
visit(node, 'code', (node) => {
|
|
128
161
|
const {lang} = node;
|
|
129
162
|
|
|
130
|
-
if (/^(
|
|
163
|
+
if (/^(jsx?|javascript)$/.test(lang)) {
|
|
131
164
|
node.value = list.shift();
|
|
132
165
|
return;
|
|
133
166
|
}
|
|
134
167
|
|
|
135
|
-
if (/^(
|
|
168
|
+
if (/^(tsx?|typescript)$/.test(lang)) {
|
|
136
169
|
node.value = list.shift();
|
|
137
170
|
return;
|
|
138
171
|
}
|
|
@@ -140,7 +173,7 @@ const apply = ({list, visit}) => (node) => {
|
|
|
140
173
|
if (lang === 'json') {
|
|
141
174
|
const code = list.shift();
|
|
142
175
|
|
|
143
|
-
node.value =
|
|
176
|
+
node.value = fromJS(code);
|
|
144
177
|
}
|
|
145
178
|
});
|
|
146
179
|
};
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import {lintRule} from 'unified-lint-rule';
|
|
2
|
-
import removeDependenciesStatusBadge from './remove-dependencies-status-badge.mjs';
|
|
3
|
-
import removeTrailingWhitespacesFromHeading from './remove-trailing-whitespaces-from-heading.mjs';
|
|
4
|
-
import mergeHeadingSpceces from './merge-heading-spaces.mjs';
|
|
5
|
-
|
|
6
|
-
const plugins = [
|
|
7
|
-
removeDependenciesStatusBadge,
|
|
8
|
-
removeTrailingWhitespacesFromHeading,
|
|
9
|
-
mergeHeadingSpceces,
|
|
10
|
-
];
|
|
11
2
|
|
|
12
3
|
export const run = lintRule('remark-lint:run', (tree, file, options) => {
|
|
13
|
-
for (const {fix, traverse, report, name} of plugins) {
|
|
4
|
+
for (const {fix, traverse, report, name} of options.plugins) {
|
|
14
5
|
const nodes = [];
|
|
15
6
|
const push = nodes.push.bind(nodes);
|
|
16
7
|
|
|
@@ -30,7 +21,3 @@ export const run = lintRule('remark-lint:run', (tree, file, options) => {
|
|
|
30
21
|
}
|
|
31
22
|
});
|
|
32
23
|
|
|
33
|
-
export const rules = {
|
|
34
|
-
plugins,
|
|
35
|
-
};
|
|
36
|
-
|
|
File without changes
|
package/lib/rules/{remove-dependencies-status-badge.mjs → remove-dependencies-status-badge.js}
RENAMED
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/processor-markdown",
|
|
3
|
-
"version": "7.0
|
|
3
|
+
"version": "7.2.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 js snippets",
|
|
@@ -21,10 +21,11 @@
|
|
|
21
21
|
"lint:fresh": "madrun lint:fresh",
|
|
22
22
|
"fix:lint": "madrun fix:lint",
|
|
23
23
|
"coverage": "madrun coverage",
|
|
24
|
+
"coverage:old": "madrun coverage:old",
|
|
24
25
|
"report": "madrun report"
|
|
25
26
|
},
|
|
26
27
|
"dependencies": {
|
|
27
|
-
"@putout/processor-json": "^
|
|
28
|
+
"@putout/processor-json": "^5.0.0",
|
|
28
29
|
"once": "^1.4.0",
|
|
29
30
|
"remark-parse": "^10.0.0",
|
|
30
31
|
"remark-preset-lint-consistent": "^5.0.0",
|
|
@@ -41,6 +42,7 @@
|
|
|
41
42
|
"devDependencies": {
|
|
42
43
|
"@putout/test": "^5.0.0",
|
|
43
44
|
"c8": "^7.5.0",
|
|
45
|
+
"escover": "^2.1.2",
|
|
44
46
|
"eslint": "^8.0.1",
|
|
45
47
|
"eslint-plugin-node": "^11.0.0",
|
|
46
48
|
"eslint-plugin-putout": "^15.0.0",
|