Skip to content

Commit 7298db7

Browse files
feat: check for unclosed code blocks (freeCodeCamp#56700)
1 parent 898b78c commit 7298db7

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

curriculum/challenges/english/21-a2-english-for-developers/learn-conversation-starters-in-the-break-room/657ddcd61f516cacdc7a04ca.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,4 @@ Rentals are usually stationary services, not something that stops.
9595
}
9696
]
9797
}
98+
```

curriculum/challenges/english/21-a2-english-for-developers/learn-introductions-in-an-online-team-meeting/657e4e3b02a2128049c344c8.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,4 @@ Refers to the act of being introduced to someone for the first time.
7878
}
7979
]
8080
}
81+
```
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
names: ['closed-code-blocks'],
3+
description: 'Code blocks must have closing triple backticks',
4+
tags: ['code'],
5+
function: function rule(params, onError) {
6+
params.parsers.micromark.tokens
7+
.filter(token => token.type === 'codeFenced')
8+
.forEach(token => {
9+
if (token.text.trim().slice(-3) !== '```') {
10+
onError({
11+
lineNumber: token.endLine,
12+
detail: `Code blocks must have closing triple backticks.`
13+
});
14+
}
15+
});
16+
}
17+
};

tools/scripts/lint/linter/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ const markdownlint = require('markdownlint');
22

33
const lintPrism = require('./markdown-prism');
44
const lintYAML = require('./markdown-yaml');
5+
const fencedCodeBlock = require('./fenced-code-block');
56

67
function linter(rules) {
78
const lint = (file, next) => {
89
const options = {
910
files: [file.path],
1011
config: rules,
11-
customRules: [lintYAML, lintPrism]
12+
customRules: [lintYAML, lintPrism, fencedCodeBlock]
1213
};
1314
markdownlint(options, function callback(err, result) {
1415
const resultString = (result || '').toString();

0 commit comments

Comments
 (0)