Skip to content

Commit 31350e3

Browse files
committed
Adding rule for open source for linting
1 parent 8914f26 commit 31350e3

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

markdownlint-custom-rules.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"use strict";
2+
3+
module.exports = {
4+
names: ["no-hyphenated-open-source"],
5+
description: "Ensure 'open source' is not written as 'open-source'.",
6+
tags: ["wording", "consistency"],
7+
function: function noHyphenatedOpenSource(params, onError) {
8+
params.lines.forEach((line, index) => {
9+
const lineNumber = index + 1;
10+
const match = line.match(/\b open-source \b/); // Find "open-source"
11+
12+
if (match) {
13+
onError({
14+
lineNumber: lineNumber,
15+
detail: "Use 'open source' instead of 'open-source'.",
16+
context: line.trim(), // Provide surrounding text
17+
fixInfo: {
18+
editColumn: match.index + 1, // Position in the line
19+
deleteCount: match[0].length,
20+
insertText: " open source ",
21+
},
22+
});
23+
}
24+
});
25+
},
26+
};

package-lock.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"build": "jupyter-book build --all .",
88
"publish": "./build.sh",
9-
"lint": "markdownlint . -i _build/ -i node_modules",
9+
"lint": "markdownlint . -i _build/ -i node_modules --rules markdownlint-custom-rules.js",
1010
"lint-fix": "markdownlint --fix . -i _build/ -i node_modules",
1111
"links": "markdown-link-check ./*.md -c mdlinkcheckconfig.json && markdown-link-check ./**/*.md -c mdlinkcheckconfig.json",
1212
"links-ci": "markdown-link-check -q ./*.md -c mdlinkcheckconfig.json && markdown-link-check ./**/*.md -q -c mdlinkcheckconfig.json",

0 commit comments

Comments
 (0)