NEW: local remark-lint checks and autofix support (#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
This commit is contained in:
Andrey Galkin 2019-06-03 15:46:36 +03:00 committed by Chris Akritidis
parent 526f46e987
commit 4c8f928f99
2 changed files with 165 additions and 10 deletions

121
.remarkrc.js Normal file
View File

@ -0,0 +1,121 @@
// Source: https://github.com/codacy/codacy-remark-lint/raw/master/.remarkrc.js
const fs = require("fs");
const path = require("path");
exports.settings = {
gfm: true,
commonmark: true,
looseTable: false,
spacedTable: false,
paddedTable: false,
fences: true,
rule: '-',
ruleRepetition: 3,
emphasis: "*",
strong: "*",
bullet: "-",
listItemIndent: 'tab',
incrementListMarker: true
};
const personalDictionaryPath = path.join(__dirname, ".dictionary");
const personalDictionary = fs.existsSync(personalDictionaryPath)
? {
personal: fs.readFileSync(personalDictionaryPath, "utf8")
}
: {};
const remarkPresetLintMarkdownStyleGuide = {
plugins: require("remark-preset-lint-markdown-style-guide").plugins.filter(
function(elem) {
return elem != require("remark-lint-no-duplicate-headings");
}
)
};
exports.plugins = [
require("remark-preset-lint-consistent"),
require("remark-preset-lint-recommended"),
remarkPresetLintMarkdownStyleGuide,
[require("remark-lint-no-dead-urls"), { skipOffline: true }],
require("remark-lint-heading-whitespace"),
[require("remark-lint-maximum-line-length"), 120],
[require("remark-lint-maximum-heading-length"), 120],
[require("remark-lint-list-item-indent"), "tab-size"],
[require("remark-lint-list-item-spacing"), false],
[require("remark-lint-strong-marker"), "*"],
[require("remark-lint-emphasis-marker"), "_"],
[require("remark-lint-unordered-list-marker-style"), "-"],
[require("remark-lint-ordered-list-marker-style"), "."],
[require("remark-lint-ordered-list-marker-value"), "ordered"],
/*[
require("remark-lint-write-good"),
[
"warn",
{
passive: false,
illusion: true,
so: true,
thereIs: true,
weasel: true,
adverb: true,
tooWordy: true,
cliches: true,
eprime: false
}
]
],*/
require("remark-validate-links"),
require("remark-frontmatter"),
/*[
require("remark-retext"),
require("unified")().use({
plugins: [
require("retext-english"),
require("retext-syntax-urls"),
[
require("retext-spell"),
{
ignoreLiteral: true,
dictionary: require("dictionary-en-us"),
...personalDictionary
}
],
[
require("retext-sentence-spacing"),
{
preferred: 1
}
],
require("retext-repeated-words"),
require("retext-usage"),
require("retext-indefinite-article"),
require("retext-redundant-acronyms"),
[
require("retext-contractions"),
{
straight: true,
allowLiteral: true
}
],
require("retext-diacritics"),
[
require("retext-quotes"),
{
preferred: "straight"
}
],
require("retext-equality"),
require("retext-passive"),
require("retext-profanities"),
[
require("retext-readability"),
{
age: 20
}
]
]
})
]*/
];

View File

@ -1,23 +1,57 @@
{
"devDependencies": {
"coffee-script": "^1.12.7",
"dictionary-en-us": "^2.0.0",
"gaze": "^1.1.2",
"grunt": "^1.0.1",
"grunt-exec": "^2.0.0",
"jasmine": "^2.6.0",
"jasmine-core": "^2.6.4",
"jasmine-growl-reporter": "^1.0.1",
"jasmine-node": "BrainDoctor/jasmine-node",
"jasmine-reporters": "^2.2.1",
"karma": "^1.7.0",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.1",
"karma-firefox-launcher": "^1.0.1",
"karma-jasmine": "^1.1.0",
"walkdir": "^0.0.11",
"underscore": "^1.8.3",
"gaze": "^1.1.2",
"mkdirp": "^0.5.1",
"minimist": "^1.2.0",
"jasmine-growl-reporter": "^1.0.1",
"xml2js": "^0.4.17",
"grunt": "^1.0.1",
"grunt-exec": "^2.0.0",
"jasmine-reporters": "^2.2.1",
"jasmine-node": "BrainDoctor/jasmine-node"
"mkdirp": "^0.5.1",
"remark-cli": "^6.0.1",
"remark-frontmatter": "^1.3.1",
"remark-lint-heading-whitespace": "^1.0.0",
"remark-lint-no-dead-urls": "^0.4.1",
"remark-lint-unordered-list-marker-style": "^1.0.2",
"remark-lint-write-good": "^1.1.0",
"remark-preset-lint-consistent": "^2.0.2",
"remark-preset-lint-markdown-style-guide": "^2.1.2",
"remark-preset-lint-recommended": "^3.0.2",
"remark-retext": "^3.1.2",
"remark-stringify": "^6.0.4",
"remark-validate-links": "^8.0.2",
"retext-contractions": "^2.1.3",
"retext-diacritics": "^1.2.2",
"retext-english": "^3.0.2",
"retext-equality": "^3.9.1",
"retext-indefinite-article": "^1.1.6",
"retext-overuse": "^1.1.1",
"retext-passive": "^1.3.2",
"retext-profanities": "^4.6.0",
"retext-quotes": "^2.0.3",
"retext-readability": "^4.2.1",
"retext-redundant-acronyms": "^1.2.2",
"retext-repeated-words": "^1.2.2",
"retext-sentence-spacing": "^2.1.0",
"retext-spell": "^2.4.0",
"retext-syntax-urls": "^1.0.1",
"retext-usage": "^0.5.0",
"underscore": "^1.8.3",
"walkdir": "^0.0.11",
"xml2js": "^0.4.17"
},
"scripts": {
"lint-md": "remark .",
"lint-md-path": "remark",
"fix-md": "remark collectors --output"
}
}