Skip to content

Commit 4c8f928

Browse files
andvgalcakrit
authored andcommitted
NEW: local remark-lint checks and autofix support (netdata#5898)
* NEW: Codacy remark-lint config to run locally - Use `npm run-script lint-md` to check all Markdown files (may be excessively long) - Use `npm run-script lint-md-path {path}` to check only specific path * remark-lint autofix support example * A bit revised remark-stringify configuration
1 parent 526f46e commit 4c8f928

File tree

2 files changed

+165
-10
lines changed

2 files changed

+165
-10
lines changed

.remarkrc.js

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
// Source: https://github.com/codacy/codacy-remark-lint/raw/master/.remarkrc.js
2+
3+
const fs = require("fs");
4+
const path = require("path");
5+
6+
exports.settings = {
7+
gfm: true,
8+
commonmark: true,
9+
looseTable: false,
10+
spacedTable: false,
11+
paddedTable: false,
12+
fences: true,
13+
rule: '-',
14+
ruleRepetition: 3,
15+
emphasis: "*",
16+
strong: "*",
17+
bullet: "-",
18+
listItemIndent: 'tab',
19+
incrementListMarker: true
20+
};
21+
22+
const personalDictionaryPath = path.join(__dirname, ".dictionary");
23+
const personalDictionary = fs.existsSync(personalDictionaryPath)
24+
? {
25+
personal: fs.readFileSync(personalDictionaryPath, "utf8")
26+
}
27+
: {};
28+
29+
const remarkPresetLintMarkdownStyleGuide = {
30+
plugins: require("remark-preset-lint-markdown-style-guide").plugins.filter(
31+
function(elem) {
32+
return elem != require("remark-lint-no-duplicate-headings");
33+
}
34+
)
35+
};
36+
37+
exports.plugins = [
38+
require("remark-preset-lint-consistent"),
39+
require("remark-preset-lint-recommended"),
40+
remarkPresetLintMarkdownStyleGuide,
41+
[require("remark-lint-no-dead-urls"), { skipOffline: true }],
42+
require("remark-lint-heading-whitespace"),
43+
[require("remark-lint-maximum-line-length"), 120],
44+
[require("remark-lint-maximum-heading-length"), 120],
45+
[require("remark-lint-list-item-indent"), "tab-size"],
46+
[require("remark-lint-list-item-spacing"), false],
47+
[require("remark-lint-strong-marker"), "*"],
48+
[require("remark-lint-emphasis-marker"), "_"],
49+
[require("remark-lint-unordered-list-marker-style"), "-"],
50+
[require("remark-lint-ordered-list-marker-style"), "."],
51+
[require("remark-lint-ordered-list-marker-value"), "ordered"],
52+
/*[
53+
require("remark-lint-write-good"),
54+
[
55+
"warn",
56+
{
57+
passive: false,
58+
illusion: true,
59+
so: true,
60+
thereIs: true,
61+
weasel: true,
62+
adverb: true,
63+
tooWordy: true,
64+
cliches: true,
65+
eprime: false
66+
}
67+
]
68+
],*/
69+
require("remark-validate-links"),
70+
require("remark-frontmatter"),
71+
/*[
72+
require("remark-retext"),
73+
require("unified")().use({
74+
plugins: [
75+
require("retext-english"),
76+
require("retext-syntax-urls"),
77+
[
78+
require("retext-spell"),
79+
{
80+
ignoreLiteral: true,
81+
dictionary: require("dictionary-en-us"),
82+
...personalDictionary
83+
}
84+
],
85+
[
86+
require("retext-sentence-spacing"),
87+
{
88+
preferred: 1
89+
}
90+
],
91+
require("retext-repeated-words"),
92+
require("retext-usage"),
93+
require("retext-indefinite-article"),
94+
require("retext-redundant-acronyms"),
95+
[
96+
require("retext-contractions"),
97+
{
98+
straight: true,
99+
allowLiteral: true
100+
}
101+
],
102+
require("retext-diacritics"),
103+
[
104+
require("retext-quotes"),
105+
{
106+
preferred: "straight"
107+
}
108+
],
109+
require("retext-equality"),
110+
require("retext-passive"),
111+
require("retext-profanities"),
112+
[
113+
require("retext-readability"),
114+
{
115+
age: 20
116+
}
117+
]
118+
]
119+
})
120+
]*/
121+
];

package.json

+44-10
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,57 @@
11
{
22
"devDependencies": {
33
"coffee-script": "^1.12.7",
4+
"dictionary-en-us": "^2.0.0",
5+
"gaze": "^1.1.2",
6+
"grunt": "^1.0.1",
7+
"grunt-exec": "^2.0.0",
48
"jasmine": "^2.6.0",
59
"jasmine-core": "^2.6.4",
10+
"jasmine-growl-reporter": "^1.0.1",
11+
"jasmine-node": "BrainDoctor/jasmine-node",
12+
"jasmine-reporters": "^2.2.1",
613
"karma": "^1.7.0",
714
"karma-chrome-launcher": "^2.2.0",
815
"karma-coverage": "^1.1.1",
916
"karma-firefox-launcher": "^1.0.1",
1017
"karma-jasmine": "^1.1.0",
11-
"walkdir": "^0.0.11",
12-
"underscore": "^1.8.3",
13-
"gaze": "^1.1.2",
14-
"mkdirp": "^0.5.1",
1518
"minimist": "^1.2.0",
16-
"jasmine-growl-reporter": "^1.0.1",
17-
"xml2js": "^0.4.17",
18-
"grunt": "^1.0.1",
19-
"grunt-exec": "^2.0.0",
20-
"jasmine-reporters": "^2.2.1",
21-
"jasmine-node": "BrainDoctor/jasmine-node"
19+
"mkdirp": "^0.5.1",
20+
"remark-cli": "^6.0.1",
21+
"remark-frontmatter": "^1.3.1",
22+
"remark-lint-heading-whitespace": "^1.0.0",
23+
"remark-lint-no-dead-urls": "^0.4.1",
24+
"remark-lint-unordered-list-marker-style": "^1.0.2",
25+
"remark-lint-write-good": "^1.1.0",
26+
"remark-preset-lint-consistent": "^2.0.2",
27+
"remark-preset-lint-markdown-style-guide": "^2.1.2",
28+
"remark-preset-lint-recommended": "^3.0.2",
29+
"remark-retext": "^3.1.2",
30+
"remark-stringify": "^6.0.4",
31+
"remark-validate-links": "^8.0.2",
32+
"retext-contractions": "^2.1.3",
33+
"retext-diacritics": "^1.2.2",
34+
"retext-english": "^3.0.2",
35+
"retext-equality": "^3.9.1",
36+
"retext-indefinite-article": "^1.1.6",
37+
"retext-overuse": "^1.1.1",
38+
"retext-passive": "^1.3.2",
39+
"retext-profanities": "^4.6.0",
40+
"retext-quotes": "^2.0.3",
41+
"retext-readability": "^4.2.1",
42+
"retext-redundant-acronyms": "^1.2.2",
43+
"retext-repeated-words": "^1.2.2",
44+
"retext-sentence-spacing": "^2.1.0",
45+
"retext-spell": "^2.4.0",
46+
"retext-syntax-urls": "^1.0.1",
47+
"retext-usage": "^0.5.0",
48+
"underscore": "^1.8.3",
49+
"walkdir": "^0.0.11",
50+
"xml2js": "^0.4.17"
51+
},
52+
"scripts": {
53+
"lint-md": "remark .",
54+
"lint-md-path": "remark",
55+
"fix-md": "remark collectors --output"
2256
}
2357
}

0 commit comments

Comments
 (0)