Skip to content

Commit 43af767

Browse files
authored
[cleanup] Remove unused template validation rule. (#326)
[cleanup] Remove unused rule. Improve documentation. Rename ATTERN-TEMPLATE-RULE-003 to ATTERN-TEMPLATE-RULE-002.
1 parent 8bee0a6 commit 43af767

File tree

2 files changed

+7
-34
lines changed

2 files changed

+7
-34
lines changed

lint/pattern-template.js

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,12 @@ module.exports = [
2121
},
2222
{
2323
names: ["PATTERN-TEMPLATE-RULE-002"],
24-
description: "Standard Headlines",
25-
tags: ["headings", "headers", "pattern-template"],
26-
function: (params, onError) => {
27-
var allowedHeadlines = "Title|Patlet|Problem|Story|Context|Forces|Solutions|Resulting Context|Known Instances|Status|Author(s)|Acknowledgements";
28-
var re = new RegExp(`^## (${allowedHeadlines.replace(/(?=[\(\)])/g, '\\')})\\s*$`,"m");
29-
// console.log(re);
30-
31-
params.tokens.filter(function filterToken(token) {
32-
return token.type === "heading_open";
33-
}).forEach(function forToken(token) {
34-
if (token.tag === "h2") {
35-
if (re.test(token.line)) {
36-
return;
37-
}
38-
// if (/^## ()$/m.test(token.line)) {
39-
// return;
40-
// }
41-
42-
return onError({
43-
lineNumber: token.lineNumber,
44-
detail: "Allowed types are: " + allowedHeadlines.replace(/\|/g, ', '),
45-
context: token.line
46-
});
47-
}
48-
});
49-
}
50-
},
51-
{
52-
names: ["PATTERN-TEMPLATE-RULE-003"],
5324
description: "Mandatory template sections",
25+
information: new URL("https://github.com/InnerSourceCommons/InnerSourcePatterns/blob/main/meta/pattern-template.md"),
5426
tags: ["headings", "headers", "pattern-template"],
5527
function: (params, onError) => {
28+
// A list of all mandatory headlines.
29+
// headline name (from template): regexp of all permitted headline spellings
5630
var mandatoryHeadlines = {
5731
"Title": "Title",
5832
"Patlet": "Patlet",
@@ -68,8 +42,8 @@ module.exports = [
6842

6943
var collectedHeadlines = ""
7044

71-
// collect all h2 headlines
72-
// (only the headline text itself, removing markdown sytnax and whitespace)
45+
// Collect all h2 (##) headlines.
46+
// Only the headline text, removing markdown and whitespaces.
7347
params.tokens.filter(function filterToken(token) {
7448
return token.type === "heading_open";
7549
}).forEach(function forToken(token) {
@@ -83,7 +57,7 @@ module.exports = [
8357
}
8458
});
8559

86-
// confirm if all `mandatoryHeadlines` exist exactly once in the `collectedHeadlines`
60+
// confirm if all `mandatoryHeadlines` exist and exist exactly once in the `collectedHeadlines`
8761
var errorsFound = [];
8862

8963
let headline;

lint/pattern-template.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ default: false # excludes all default markdownlint rules
22

33
# Custom rules:
44
PATTERN-TEMPLATE-RULE-001: true
5-
# PATTERN-TEMPLATE-RULE-002: true # will likely stop using this in favor of rule 003
6-
PATTERN-TEMPLATE-RULE-003: true
5+
PATTERN-TEMPLATE-RULE-002: true

0 commit comments

Comments
 (0)