markdownlint-cli2 0.12.0 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.12.1
4
+
5
+ - Update JSONC parsing to handle trailing commas
6
+ - Add documentation links to JSON schema
7
+ - Update dependencies
8
+
3
9
  ## 0.12.0
4
10
 
5
11
  - Remove deprecated `markdownlint-cli2-config` entry point
package/README.md CHANGED
@@ -147,7 +147,7 @@ A container image [`davidanson/markdownlint-cli2`][docker-hub-markdownlint-cli2]
147
147
  can also be used (e.g., as part of a CI pipeline):
148
148
 
149
149
  ```bash
150
- docker run -v $PWD:/workdir davidanson/markdownlint-cli2:v0.12.0 "**/*.md" "#node_modules"
150
+ docker run -v $PWD:/workdir davidanson/markdownlint-cli2:v0.12.1 "**/*.md" "#node_modules"
151
151
  ```
152
152
 
153
153
  Notes:
@@ -164,7 +164,7 @@ Notes:
164
164
  - A custom working directory can be specified with Docker's `-w` flag:
165
165
 
166
166
  ```bash
167
- docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:v0.12.0 "**/*.md" "#node_modules"
167
+ docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:v0.12.1 "**/*.md" "#node_modules"
168
168
  ```
169
169
 
170
170
  For convenience, the container image
@@ -396,7 +396,7 @@ reference to the `repos` list in that project's `.pre-commit-config.yaml` like:
396
396
 
397
397
  ```yaml
398
398
  - repo: https://github.com/DavidAnson/markdownlint-cli2
399
- rev: v0.12.0
399
+ rev: v0.12.1
400
400
  hooks:
401
401
  - id: markdownlint-cli2
402
402
  ```
@@ -26,7 +26,7 @@ const resolveAndRequire = require("./resolve-and-require");
26
26
 
27
27
  // Variables
28
28
  const packageName = "markdownlint-cli2";
29
- const packageVersion = "0.12.0";
29
+ const packageVersion = "0.12.1";
30
30
  const libraryName = "markdownlint";
31
31
  const libraryVersion = markdownlintLibrary.getVersion();
32
32
  const dotOnlySubstitute = "*.{md,markdown}";
@@ -35,12 +35,18 @@ const utf8 = "utf8";
35
35
  // No-op function
36
36
  const noop = () => null;
37
37
 
38
- // Gets a synchronous function to parse JSONC text
39
- const getJsoncParse = async () => {
40
- const { "default": stripJsonComments } =
41
- // eslint-disable-next-line no-inline-comments
42
- await import(/* webpackMode: "eager" */ "strip-json-comments");
43
- return (text) => JSON.parse(stripJsonComments(text));
38
+ // Synchronous function to parse JSONC text
39
+ const jsoncParse = (text) => {
40
+ const { parse, printParseErrorCode } = require("jsonc-parser");
41
+ const errors = [];
42
+ const result = parse(text, errors, { "allowTrailingComma": true });
43
+ if (errors.length > 0) {
44
+ const aggregate = errors.map(
45
+ (err) => `${printParseErrorCode(err.error)} (offset ${err.offset}, length ${err.length})`
46
+ ).join(", ");
47
+ throw new Error(`Unable to parse JSON(C) content, ${aggregate}`);
48
+ }
49
+ return result;
44
50
  };
45
51
 
46
52
  // Synchronous function to parse YAML text
@@ -67,12 +73,10 @@ const readConfig = (fs, dir, name, otherwise) => {
67
73
  const file = pathPosix.join(dir, name);
68
74
  return () => fs.promises.access(file).
69
75
  then(
70
- () => getJsoncParse().then(
71
- (jsoncParse) => markdownlintReadConfig(
72
- file,
73
- [ jsoncParse, yamlParse ],
74
- fs
75
- )
76
+ () => markdownlintReadConfig(
77
+ file,
78
+ [ jsoncParse, yamlParse ],
79
+ fs
76
80
  ),
77
81
  otherwise
78
82
  );
@@ -139,9 +143,8 @@ const importOrRequireConfig = (fs, dir, name, noRequire, otherwise) => {
139
143
  };
140
144
 
141
145
  // Extend a config object if it has 'extends' property
142
- const getExtendedConfig = async (config, configPath, fs) => {
146
+ const getExtendedConfig = (config, configPath, fs) => {
143
147
  if (config.extends) {
144
- const jsoncParse = await getJsoncParse();
145
148
  return markdownlintExtendConfig(
146
149
  config,
147
150
  configPath,
@@ -150,7 +153,7 @@ const getExtendedConfig = async (config, configPath, fs) => {
150
153
  );
151
154
  }
152
155
 
153
- return config;
156
+ return Promise.resolve(config);
154
157
  };
155
158
 
156
159
  // Read an options or config file in any format and return the object
@@ -160,7 +163,6 @@ const readOptionsOrConfig = async (configPath, fs, noRequire) => {
160
163
  let options = null;
161
164
  let config = null;
162
165
  if (basename.endsWith(".markdownlint-cli2.jsonc")) {
163
- const jsoncParse = await getJsoncParse();
164
166
  options = jsoncParse(await fs.promises.readFile(configPath, utf8));
165
167
  } else if (basename.endsWith(".markdownlint-cli2.yaml")) {
166
168
  options = yamlParse(await fs.promises.readFile(configPath, utf8));
@@ -177,7 +179,6 @@ const readOptionsOrConfig = async (configPath, fs, noRequire) => {
177
179
  basename.endsWith(".markdownlint.yaml") ||
178
180
  basename.endsWith(".markdownlint.yml")
179
181
  ) {
180
- const jsoncParse = await getJsoncParse();
181
182
  config =
182
183
  await markdownlintReadConfig(configPath, [ jsoncParse, yamlParse ], fs);
183
184
  } else if (
@@ -319,10 +320,7 @@ const getAndProcessDirInfo = (
319
320
  then(
320
321
  () => fs.promises.
321
322
  readFile(markdownlintCli2Jsonc, utf8).
322
- then(
323
- (content) => getJsoncParse().
324
- then((jsoncParse) => jsoncParse(content))
325
- ),
323
+ then(jsoncParse),
326
324
  () => fs.promises.access(markdownlintCli2Yaml).
327
325
  then(
328
326
  () => fs.promises.
@@ -346,11 +344,8 @@ const getAndProcessDirInfo = (
346
344
  then(
347
345
  () => fs.promises.
348
346
  readFile(packageJson, utf8).
349
- then(
350
- (content) => getJsoncParse().
351
- then((jsoncParse) => jsoncParse(content)).
352
- then((obj) => obj[packageName])
353
- ),
347
+ then(jsoncParse).
348
+ then((obj) => obj[packageName]),
354
349
  noop
355
350
  )
356
351
  )
@@ -743,8 +738,7 @@ const createDirInfos = async (
743
738
  };
744
739
 
745
740
  // Lint files in groups by shared configuration
746
- const lintFiles = async (fs, dirInfos, fileContents) => {
747
- const jsoncParse = await getJsoncParse();
741
+ const lintFiles = (fs, dirInfos, fileContents) => {
748
742
  const tasks = [];
749
743
  // For each dirInfo
750
744
  for (const dirInfo of dirInfos) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdownlint-cli2",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "A fast, flexible, configuration-based command-line interface for linting Markdown/CommonMark files with the `markdownlint` library",
5
5
  "author": {
6
6
  "name": "David Anson",
@@ -33,7 +33,7 @@
33
33
  "lint-watch": "git ls-files | entr npm run lint",
34
34
  "schema": "cpy ./node_modules/markdownlint/schema/markdownlint-config-schema.json ./schema --flat",
35
35
  "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",
36
- "test-cover": "c8 --100 npm test -- --concurrency=1",
36
+ "test-cover": "c8 --100 npm test",
37
37
  "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\"",
38
38
  "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\"",
39
39
  "test-docker-image": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2:v$VERSION \"*.md\"",
@@ -63,17 +63,17 @@
63
63
  ],
64
64
  "dependencies": {
65
65
  "globby": "14.0.0",
66
+ "jsonc-parser": "3.2.0",
66
67
  "markdownlint": "0.33.0",
67
68
  "markdownlint-cli2-formatter-default": "0.0.4",
68
69
  "micromatch": "4.0.5",
69
- "strip-json-comments": "5.0.1",
70
70
  "yaml": "2.3.4"
71
71
  },
72
72
  "devDependencies": {
73
73
  "@iktakahiro/markdown-it-katex": "4.0.1",
74
74
  "ajv": "8.12.0",
75
75
  "ava": "6.0.1",
76
- "c8": "9.0.0",
76
+ "c8": "9.1.0",
77
77
  "cpy": "11.0.0",
78
78
  "cpy-cli": "5.0.0",
79
79
  "del": "7.1.0",
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.12.0/schema/markdownlint-cli2-config-schema.json",
3
+ "$id": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.12.1/schema/markdownlint-cli2-config-schema.json",
4
4
  "title": "markdownlint-cli2 configuration schema",
5
5
  "type": "object",
6
6
  "properties": {
7
7
  "$schema": {
8
8
  "description": "JSON Schema URI (expected by some editors)",
9
9
  "type": "string",
10
- "default": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.12.0/schema/markdownlint-cli2-config-schema.json"
10
+ "default": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.12.1/schema/markdownlint-cli2-config-schema.json"
11
11
  },
12
12
  "config": {
13
- "description": "markdownlint-cli2 configuration schema",
13
+ "description": "markdownlint configuration schema : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/schema/.markdownlint.jsonc",
14
14
  "$ref": "https://raw.githubusercontent.com/DavidAnson/markdownlint/v0.33.0/schema/markdownlint-config-schema.json",
15
15
  "default": {}
16
16
  },
17
17
  "customRules": {
18
- "description": "Module names or paths of custom rules to load and use when linting",
18
+ "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",
19
19
  "type": "array",
20
20
  "default": [],
21
21
  "items": {
@@ -25,18 +25,18 @@
25
25
  }
26
26
  },
27
27
  "fix": {
28
- "description": "Whether to enable fixing of linting errors reported by rules that emit fix information",
28
+ "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",
29
29
  "type": "boolean",
30
30
  "default": false
31
31
  },
32
32
  "frontMatter": {
33
- "description": "Regular expression used to match and ignore any front matter at the beginning of a document",
33
+ "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",
34
34
  "type": "string",
35
35
  "minLength": 1,
36
36
  "default": ""
37
37
  },
38
38
  "globs": {
39
- "description": "Glob expressions to include when linting (only valid at the root)",
39
+ "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",
40
40
  "type": "array",
41
41
  "default": [],
42
42
  "items": {
@@ -46,7 +46,7 @@
46
46
  }
47
47
  },
48
48
  "ignores": {
49
- "description": "Glob expressions to ignore when linting",
49
+ "description": "Glob expressions to ignore when linting : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc",
50
50
  "type": "array",
51
51
  "default": [],
52
52
  "items": {
@@ -56,7 +56,7 @@
56
56
  }
57
57
  },
58
58
  "markdownItPlugins": {
59
- "description": "markdown-it plugins to load and use when linting",
59
+ "description": "markdown-it plugins to load and use when linting : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc",
60
60
  "type": "array",
61
61
  "default": [],
62
62
  "items": {
@@ -76,7 +76,7 @@
76
76
  }
77
77
  },
78
78
  "modulePaths": {
79
- "description": "Additional paths to resolve module locations from",
79
+ "description": "Additional paths to resolve module locations from : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc",
80
80
  "type": "array",
81
81
  "default": [],
82
82
  "items": {
@@ -86,17 +86,17 @@
86
86
  }
87
87
  },
88
88
  "noInlineConfig": {
89
- "description": "Whether to disable support of HTML comments within Markdown content",
89
+ "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",
90
90
  "type": "boolean",
91
91
  "default": false
92
92
  },
93
93
  "noProgress": {
94
- "description": "Whether to disable the display of progress on stdout (only valid at the root)",
94
+ "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",
95
95
  "type": "boolean",
96
96
  "default": false
97
97
  },
98
98
  "outputFormatters": {
99
- "description": "Output formatters to load and use to customize markdownlint-cli2 output (only valid at the root)",
99
+ "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",
100
100
  "type": "array",
101
101
  "default": [],
102
102
  "items": {
@@ -116,7 +116,7 @@
116
116
  }
117
117
  },
118
118
  "showFound": {
119
- "description": "Whether to show the list of found files on stdout (only valid at the root)",
119
+ "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",
120
120
  "type": "boolean",
121
121
  "default": false
122
122
  }