markdownlint-cli2
Advanced tools
Comparing version 0.12.0 to 0.12.1
# Changelog | ||
## 0.12.1 | ||
- Update JSONC parsing to handle trailing commas | ||
- Add documentation links to JSON schema | ||
- Update dependencies | ||
## 0.12.0 | ||
@@ -4,0 +10,0 @@ |
@@ -29,3 +29,3 @@ #!/usr/bin/env node | ||
const packageName = "markdownlint-cli2"; | ||
const packageVersion = "0.12.0"; | ||
const packageVersion = "0.12.1"; | ||
const libraryName = "markdownlint"; | ||
@@ -39,8 +39,14 @@ const libraryVersion = markdownlintLibrary.getVersion(); | ||
// Gets a synchronous function to parse JSONC text | ||
const getJsoncParse = async () => { | ||
const { "default": stripJsonComments } = | ||
// eslint-disable-next-line no-inline-comments | ||
await import(/* webpackMode: "eager" */ "strip-json-comments"); | ||
return (text) => JSON.parse(stripJsonComments(text)); | ||
// Synchronous function to parse JSONC text | ||
const jsoncParse = (text) => { | ||
const { parse, printParseErrorCode } = require("jsonc-parser"); | ||
const errors = []; | ||
const result = parse(text, errors, { "allowTrailingComma": true }); | ||
if (errors.length > 0) { | ||
const aggregate = errors.map( | ||
(err) => `${printParseErrorCode(err.error)} (offset ${err.offset}, length ${err.length})` | ||
).join(", "); | ||
throw new Error(`Unable to parse JSON(C) content, ${aggregate}`); | ||
} | ||
return result; | ||
}; | ||
@@ -72,8 +78,6 @@ | ||
then( | ||
() => getJsoncParse().then( | ||
(jsoncParse) => markdownlintReadConfig( | ||
file, | ||
[ jsoncParse, yamlParse ], | ||
fs | ||
) | ||
() => markdownlintReadConfig( | ||
file, | ||
[ jsoncParse, yamlParse ], | ||
fs | ||
), | ||
@@ -145,5 +149,4 @@ otherwise | ||
// Extend a config object if it has 'extends' property | ||
const getExtendedConfig = async (config, configPath, fs) => { | ||
const getExtendedConfig = (config, configPath, fs) => { | ||
if (config.extends) { | ||
const jsoncParse = await getJsoncParse(); | ||
return markdownlintExtendConfig( | ||
@@ -157,3 +160,3 @@ config, | ||
return config; | ||
return Promise.resolve(config); | ||
}; | ||
@@ -168,3 +171,2 @@ | ||
if (basename.endsWith(".markdownlint-cli2.jsonc")) { | ||
const jsoncParse = await getJsoncParse(); | ||
options = jsoncParse(await fs.promises.readFile(configPath, utf8)); | ||
@@ -186,3 +188,2 @@ } else if (basename.endsWith(".markdownlint-cli2.yaml")) { | ||
) { | ||
const jsoncParse = await getJsoncParse(); | ||
config = | ||
@@ -329,6 +330,3 @@ await markdownlintReadConfig(configPath, [ jsoncParse, yamlParse ], fs); | ||
readFile(markdownlintCli2Jsonc, utf8). | ||
then( | ||
(content) => getJsoncParse(). | ||
then((jsoncParse) => jsoncParse(content)) | ||
), | ||
then(jsoncParse), | ||
() => fs.promises.access(markdownlintCli2Yaml). | ||
@@ -357,7 +355,4 @@ then( | ||
readFile(packageJson, utf8). | ||
then( | ||
(content) => getJsoncParse(). | ||
then((jsoncParse) => jsoncParse(content)). | ||
then((obj) => obj[packageName]) | ||
), | ||
then(jsoncParse). | ||
then((obj) => obj[packageName]), | ||
noop | ||
@@ -755,4 +750,3 @@ ) | ||
// Lint files in groups by shared configuration | ||
const lintFiles = async (fs, dirInfos, fileContents) => { | ||
const jsoncParse = await getJsoncParse(); | ||
const lintFiles = (fs, dirInfos, fileContents) => { | ||
const tasks = []; | ||
@@ -759,0 +753,0 @@ // For each dirInfo |
{ | ||
"name": "markdownlint-cli2", | ||
"version": "0.12.0", | ||
"version": "0.12.1", | ||
"description": "A fast, flexible, configuration-based command-line interface for linting Markdown/CommonMark files with the `markdownlint` library", | ||
@@ -36,3 +36,3 @@ "author": { | ||
"test": "ava --timeout=1m test/append-to-array-test.js test/fs-mock-test.js test/markdownlint-cli2-test.js test/markdownlint-cli2-test-exec.js test/markdownlint-cli2-test-fs.js test/markdownlint-cli2-test-main.js test/merge-options-test.js test/resolve-and-require-test.js", | ||
"test-cover": "c8 --100 npm test -- --concurrency=1", | ||
"test-cover": "c8 --100 npm test", | ||
"test-docker-hub-image": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker image rm davidanson/markdownlint-cli2:v$VERSION davidanson/markdownlint-cli2:latest || true && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2:v$VERSION \"*.md\" && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2:latest \"*.md\"", | ||
@@ -67,6 +67,6 @@ "test-docker-hub-image-rules": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker image rm davidanson/markdownlint-cli2-rules:v$VERSION davidanson/markdownlint-cli2-rules:latest || true && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2-rules:v$VERSION \"*.md\" && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2-rules:latest \"*.md\"", | ||
"globby": "14.0.0", | ||
"jsonc-parser": "3.2.0", | ||
"markdownlint": "0.33.0", | ||
"markdownlint-cli2-formatter-default": "0.0.4", | ||
"micromatch": "4.0.5", | ||
"strip-json-comments": "5.0.1", | ||
"yaml": "2.3.4" | ||
@@ -78,3 +78,3 @@ }, | ||
"ava": "6.0.1", | ||
"c8": "9.0.0", | ||
"c8": "9.1.0", | ||
"cpy": "11.0.0", | ||
@@ -81,0 +81,0 @@ "cpy-cli": "5.0.0", |
@@ -150,3 +150,3 @@ # markdownlint-cli2 | ||
```bash | ||
docker run -v $PWD:/workdir davidanson/markdownlint-cli2:v0.12.0 "**/*.md" "#node_modules" | ||
docker run -v $PWD:/workdir davidanson/markdownlint-cli2:v0.12.1 "**/*.md" "#node_modules" | ||
``` | ||
@@ -168,3 +168,3 @@ | ||
```bash | ||
docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:v0.12.0 "**/*.md" "#node_modules" | ||
docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:v0.12.1 "**/*.md" "#node_modules" | ||
``` | ||
@@ -401,3 +401,3 @@ | ||
- repo: https://github.com/DavidAnson/markdownlint-cli2 | ||
rev: v0.12.0 | ||
rev: v0.12.1 | ||
hooks: | ||
@@ -404,0 +404,0 @@ - id: markdownlint-cli2 |
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.12.0/schema/markdownlint-cli2-config-schema.json", | ||
"$id": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.12.1/schema/markdownlint-cli2-config-schema.json", | ||
"title": "markdownlint-cli2 configuration schema", | ||
@@ -10,6 +10,6 @@ "type": "object", | ||
"type": "string", | ||
"default": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.12.0/schema/markdownlint-cli2-config-schema.json" | ||
"default": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.12.1/schema/markdownlint-cli2-config-schema.json" | ||
}, | ||
"config": { | ||
"description": "markdownlint-cli2 configuration schema", | ||
"description": "markdownlint configuration schema : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/schema/.markdownlint.jsonc", | ||
"$ref": "https://raw.githubusercontent.com/DavidAnson/markdownlint/v0.33.0/schema/markdownlint-config-schema.json", | ||
@@ -19,3 +19,3 @@ "default": {} | ||
"customRules": { | ||
"description": "Module names or paths of custom rules to load and use when linting", | ||
"description": "Module names or paths of custom rules to load and use when linting : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc", | ||
"type": "array", | ||
@@ -30,3 +30,3 @@ "default": [], | ||
"fix": { | ||
"description": "Whether to enable fixing of linting errors reported by rules that emit fix information", | ||
"description": "Whether to enable fixing of linting errors reported by rules that emit fix information : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc", | ||
"type": "boolean", | ||
@@ -36,3 +36,3 @@ "default": false | ||
"frontMatter": { | ||
"description": "Regular expression used to match and ignore any front matter at the beginning of a document", | ||
"description": "Regular expression used to match and ignore any front matter at the beginning of a document : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc", | ||
"type": "string", | ||
@@ -43,3 +43,3 @@ "minLength": 1, | ||
"globs": { | ||
"description": "Glob expressions to include when linting (only valid at the root)", | ||
"description": "Glob expressions to include when linting (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc", | ||
"type": "array", | ||
@@ -54,3 +54,3 @@ "default": [], | ||
"ignores": { | ||
"description": "Glob expressions to ignore when linting", | ||
"description": "Glob expressions to ignore when linting : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc", | ||
"type": "array", | ||
@@ -65,3 +65,3 @@ "default": [], | ||
"markdownItPlugins": { | ||
"description": "markdown-it plugins to load and use when linting", | ||
"description": "markdown-it plugins to load and use when linting : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc", | ||
"type": "array", | ||
@@ -86,3 +86,3 @@ "default": [], | ||
"modulePaths": { | ||
"description": "Additional paths to resolve module locations from", | ||
"description": "Additional paths to resolve module locations from : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc", | ||
"type": "array", | ||
@@ -97,3 +97,3 @@ "default": [], | ||
"noInlineConfig": { | ||
"description": "Whether to disable support of HTML comments within Markdown content", | ||
"description": "Whether to disable support of HTML comments within Markdown content : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc", | ||
"type": "boolean", | ||
@@ -103,3 +103,3 @@ "default": false | ||
"noProgress": { | ||
"description": "Whether to disable the display of progress on stdout (only valid at the root)", | ||
"description": "Whether to disable the display of progress on stdout (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc", | ||
"type": "boolean", | ||
@@ -109,3 +109,3 @@ "default": false | ||
"outputFormatters": { | ||
"description": "Output formatters to load and use to customize markdownlint-cli2 output (only valid at the root)", | ||
"description": "Output formatters to load and use to customize markdownlint-cli2 output (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc", | ||
"type": "array", | ||
@@ -130,3 +130,3 @@ "default": [], | ||
"showFound": { | ||
"description": "Whether to show the list of found files on stdout (only valid at the root)", | ||
"description": "Whether to show the list of found files on stdout (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc", | ||
"type": "boolean", | ||
@@ -133,0 +133,0 @@ "default": false |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
127584
3021
+ Addedjsonc-parser@3.2.0
+ Addedjsonc-parser@3.2.0(transitive)
- Removedstrip-json-comments@5.0.1
- Removedstrip-json-comments@5.0.1(transitive)