remark-lint-code-block-syntax
Advanced tools
Comparing version 0.10.0 to 0.11.0
19
index.js
@@ -7,2 +7,3 @@ import { lintRule } from "unified-lint-rule"; | ||
import { default as jsonc } from "jsonc-parser"; | ||
import { default as JSON5 } from "json5"; | ||
@@ -13,3 +14,3 @@ const remarkLintCodeBlockSyntax = lintRule("remark-lint:code-block-syntax", codeSyntax); | ||
function codeSyntax(tree, file) { | ||
const supportedLangs = ["js", "javascript", "json", "jsonc", "yaml", "yml", "css"]; | ||
const supportedLangs = ["js", "javascript", "json", "jsonc", "json5", "yaml", "yml", "css"]; | ||
const test = supportedLangs.map((lang) => ({ type: "code", lang })); | ||
@@ -49,2 +50,9 @@ | ||
} | ||
case "json5": { | ||
const reason = checkJson5(value); | ||
if (reason) { | ||
report(reason, "JSON5"); | ||
} | ||
break; | ||
} | ||
case "yaml": | ||
@@ -107,2 +115,11 @@ case "yml": { | ||
function checkJson5(code) { | ||
try { | ||
JSON5.parse(code); | ||
return null; | ||
} catch (e) { | ||
return e.message; | ||
} | ||
} | ||
function checkYaml(code) { | ||
@@ -109,0 +126,0 @@ try { |
{ | ||
"name": "remark-lint-code-block-syntax", | ||
"version": "0.10.0", | ||
"version": "0.11.0", | ||
"description": "A remark-lint rule to check language syntax in a code block.", | ||
@@ -40,2 +40,3 @@ "author": "Masafumi Koba", | ||
"js-yaml": "^4.1.0", | ||
"json5": "^2.2.3", | ||
"jsonc-parser": "^3.3.1", | ||
@@ -42,0 +43,0 @@ "postcss": "^8.4.43", |
@@ -13,2 +13,3 @@ [![npm](https://img.shields.io/npm/v/remark-lint-code-block-syntax?style=flat-square)](https://www.npmjs.com/package/remark-lint-code-block-syntax) | ||
- JSONC | ||
- JSON5 | ||
- YAML | ||
@@ -15,0 +16,0 @@ - CSS |
7385
126
77
7
+ Addedjson5@^2.2.3
+ Addedjson5@2.2.3(transitive)