Skip to content

Commit

Permalink
Adding rule for open source for linting
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardLitt committed Feb 17, 2025
1 parent 8914f26 commit 31350e3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
26 changes: 26 additions & 0 deletions markdownlint-custom-rules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"use strict";

module.exports = {
names: ["no-hyphenated-open-source"],
description: "Ensure 'open source' is not written as 'open-source'.",
tags: ["wording", "consistency"],
function: function noHyphenatedOpenSource(params, onError) {
params.lines.forEach((line, index) => {
const lineNumber = index + 1;
const match = line.match(/\b open-source \b/); // Find "open-source"

if (match) {
onError({
lineNumber: lineNumber,
detail: "Use 'open source' instead of 'open-source'.",
context: line.trim(), // Provide surrounding text
fixInfo: {
editColumn: match.index + 1, // Position in the line
deleteCount: match[0].length,
insertText: " open source ",
},
});
}
});
},
};
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"build": "jupyter-book build --all .",
"publish": "./build.sh",
"lint": "markdownlint . -i _build/ -i node_modules",
"lint": "markdownlint . -i _build/ -i node_modules --rules markdownlint-custom-rules.js",
"lint-fix": "markdownlint --fix . -i _build/ -i node_modules",
"links": "markdown-link-check ./*.md -c mdlinkcheckconfig.json && markdown-link-check ./**/*.md -c mdlinkcheckconfig.json",
"links-ci": "markdown-link-check -q ./*.md -c mdlinkcheckconfig.json && markdown-link-check ./**/*.md -q -c mdlinkcheckconfig.json",
Expand Down

0 comments on commit 31350e3

Please sign in to comment.