Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test case for custom rule that imports an ESM module (refs #477).
- Loading branch information
1 parent
b1aef98
commit 23d8ed7
Showing
5 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// @ts-check | ||
|
||
"use strict"; | ||
|
||
const { filterTokens } = require("markdownlint-rule-helpers"); | ||
|
||
module.exports = { | ||
"names": [ "validate-json" ], | ||
"description": "Rule that validates JSON code", | ||
"tags": [ "test", "validate", "json" ], | ||
"asynchronous": true, | ||
"function": async(params, onError) => { | ||
// eslint-disable-next-line max-len, node/no-unsupported-features/es-syntax | ||
const { "default": stripJsonComments } = await import("strip-json-comments"); | ||
filterTokens(params, "fence", (fence) => { | ||
if (/jsonc?/i.test(fence.info)) { | ||
try { | ||
JSON.parse(stripJsonComments(fence.content)); | ||
} catch (error) { | ||
onError({ | ||
"lineNumber": fence.lineNumber, | ||
"detail": error.message | ||
}); | ||
} | ||
} | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Validate JSON | ||
|
||
Text | ||
|
||
```json | ||
{ | ||
"property": "value" | ||
} | ||
``` | ||
|
||
Text | ||
|
||
```jsonc | ||
{ | ||
// Comment | ||
"property": "value" | ||
} | ||
``` | ||
|
||
Text | ||
|
||
```json | ||
{ | ||
"property": "value" | ||
``` | ||
|
||
Text |