markdownlint-cli2 0.11.0 → 0.12.0

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,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.12.0
4
+
5
+ - Remove deprecated `markdownlint-cli2-config` entry point
6
+ - Use `markdownlint-cli2 --config ...` instead
7
+ - Remove deprecated `markdownlint-cli2-fix` entry point
8
+ - Use `markdownlint-cli2 --fix ...` instead
9
+ - Add `--help` and `--no-globs` parameters
10
+ - Improve and document included JSON schemas
11
+ - Update dependencies (including `markdownlint`)
12
+
3
13
  ## 0.11.0
4
14
 
5
15
  - Add `modulePaths` configuration option
package/README.md CHANGED
@@ -67,7 +67,7 @@ As a [GitHub Action][github-action] via
67
67
  markdownlint-cli2 vX.Y.Z (markdownlint vX.Y.Z)
68
68
  https://github.com/DavidAnson/markdownlint-cli2
69
69
 
70
- Syntax: markdownlint-cli2 glob0 [glob1] [...] [globN] [--config file] [--fix]
70
+ Syntax: markdownlint-cli2 glob0 [glob1] [...] [globN] [--config file] [--fix] [--help]
71
71
 
72
72
  Glob expressions (from the globby library):
73
73
  - * matches any number of characters, but not /
@@ -83,8 +83,10 @@ Dot-only glob:
83
83
  - To lint every file in the current directory tree, the command "markdownlint-cli2 **" can be used instead
84
84
 
85
85
  Optional parameters:
86
- - --config specifies the path to a configuration file to define the base configuration
87
- - --fix updates files to resolve fixable issues (can be overridden in configuration)
86
+ - --config specifies the path to a configuration file to define the base configuration
87
+ - --fix updates files to resolve fixable issues (can be overridden in configuration)
88
+ - --help writes this message to the console and exits without doing anything else
89
+ - --no-globs ignores the "globs" property if present in the top-level options object
88
90
 
89
91
  Configuration via:
90
92
  - .markdownlint-cli2.jsonc
@@ -126,17 +128,6 @@ below) to `true` (though it can still be overridden by a configuration file):
126
128
  markdownlint-cli2 --fix "**/*.md" "#node_modules"
127
129
  ```
128
130
 
129
- > **Deprecated**
130
- >
131
- > The following command behaves similarly, defaulting the `fix` property to
132
- > `true`:
133
- >
134
- > ```bash
135
- > markdownlint-cli2-fix "**/*.md" "#node_modules"
136
- > ```
137
- >
138
- > Otherwise, `markdownlint-cli2-fix` behaves the same as `markdownlint-cli2`.
139
-
140
131
  In cases where it is not convenient to store a configuration file in the root
141
132
  of a project, the `--config` argument can be used to provide a path to any
142
133
  supported configuration file (except `package.json`):
@@ -150,24 +141,13 @@ above. For example, `.markdownlint.json` or `example.markdownlint-cli2.jsonc`.
150
141
  The specified configuration file will be loaded, parsed, and applied as a base
151
142
  configuration for the current directory - which will then be handled normally.
152
143
 
153
- > **Deprecated**
154
- >
155
- > The following command behaves similarly, accepting a base configuration file
156
- > path as its first parameter:
157
- >
158
- > ```bash
159
- > markdownlint-cli2-config "config/.markdownlint-cli2.jsonc" "**/*.md" "#node_modules"
160
- > ```
161
- >
162
- > Otherwise, `markdownlint-cli2-config` behaves the same as `markdownlint-cli2`.
163
-
164
144
  ### Container Image
165
145
 
166
146
  A container image [`davidanson/markdownlint-cli2`][docker-hub-markdownlint-cli2]
167
147
  can also be used (e.g., as part of a CI pipeline):
168
148
 
169
149
  ```bash
170
- docker run -v $PWD:/workdir davidanson/markdownlint-cli2:v0.11.0 "**/*.md" "#node_modules"
150
+ docker run -v $PWD:/workdir davidanson/markdownlint-cli2:v0.12.0 "**/*.md" "#node_modules"
171
151
  ```
172
152
 
173
153
  Notes:
@@ -184,18 +164,9 @@ Notes:
184
164
  - A custom working directory can be specified with Docker's `-w` flag:
185
165
 
186
166
  ```bash
187
- docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:v0.11.0 "**/*.md" "#node_modules"
167
+ docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:v0.12.0 "**/*.md" "#node_modules"
188
168
  ```
189
169
 
190
- > **Deprecated**
191
- >
192
- > To invoke the `markdownlint-cli2-config` or `markdownlint-cli2-fix` commands
193
- > instead, use Docker's `--entrypoint` flag:
194
- >
195
- > ```bash
196
- > docker run -v $PWD:/workdir --entrypoint="markdownlint-cli2-fix" davidanson/markdownlint-cli2:v0.11.0 "**/*.md" "#node_modules"
197
- > ```
198
-
199
170
  For convenience, the container image
200
171
  [`davidanson/markdownlint-cli2-rules`][docker-hub-markdownlint-cli2-rules]
201
172
  includes the latest versions of custom rules published to npm with the tag
@@ -254,9 +225,12 @@ of the rules within.
254
225
  4. `.markdownlint.yml`
255
226
  5. `.markdownlint.cjs`
256
227
  6. `.markdownlint.mjs`
257
- - The VS Code extension `vscode-markdownlint` includes a schema definition for
258
- the `JSON(C)` configuration files described below. This adds auto-complete and
259
- can make it easier to define proper structure.
228
+ - The VS Code extension includes a [JSON Schema][json-schema] definition for the
229
+ `JSON(C)` configuration files described below. This adds auto-complete and can
230
+ make it easier to define proper structure.
231
+ - See [markdownlint-cli2-config-schema.json][markdownlint-cli2-config-schema]
232
+ for that schema and [ValidatingConfiguration.md][validating-configuration] for
233
+ ways to use it to validate configuration files.
260
234
 
261
235
  ### `.markdownlint-cli2.jsonc`
262
236
 
@@ -286,6 +260,8 @@ of the rules within.
286
260
  command-line arguments
287
261
  - This setting can be used instead of (or in addition to) passing globs on
288
262
  the command-line and offers identical performance
263
+ - This setting is ignored when the `--no-globs` parameter is passed on the
264
+ command-line
289
265
  - This top-level setting is valid **only** in the directory from which
290
266
  `markdownlint-cli2` is run
291
267
  - `ignores`: `Array` of `String`s defining glob expressions to ignore when
@@ -420,7 +396,7 @@ reference to the `repos` list in that project's `.pre-commit-config.yaml` like:
420
396
 
421
397
  ```yaml
422
398
  - repo: https://github.com/DavidAnson/markdownlint-cli2
423
- rev: v0.11.0
399
+ rev: v0.12.0
424
400
  hooks:
425
401
  - id: markdownlint-cli2
426
402
  ```
@@ -447,6 +423,7 @@ See [CHANGELOG.md][changelog].
447
423
  [homebrew]: https://brew.sh
448
424
  [html-comment]: https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/Getting_started
449
425
  [json]: https://wikipedia.org/wiki/JSON
426
+ [json-schema]: https://json-schema.org
450
427
  [jsonc]: https://code.visualstudio.com/Docs/languages/json#_json-with-comments
451
428
  [license-image]: https://img.shields.io/npm/l/markdownlint-cli2.svg
452
429
  [license-url]: https://opensource.org/licenses/MIT
@@ -455,26 +432,27 @@ See [CHANGELOG.md][changelog].
455
432
  [markdown-it-plugins]: https://www.npmjs.com/search?q=keywords:markdown-it-plugin
456
433
  [markdown-it-syntax-extensions]: https://github.com/markdown-it/markdown-it#syntax-extensions
457
434
  [markdownlint]: https://github.com/DavidAnson/markdownlint
458
- [markdownlint-config]: https://github.com/DavidAnson/markdownlint/blob/main/README.md#optionsconfig
459
- [markdownlint-configuration]: https://github.com/DavidAnson/markdownlint/blob/main/README.md#configuration
460
- [markdownlint-custom-rules]: https://github.com/DavidAnson/markdownlint/blob/main/doc/CustomRules.md
461
- [markdownlint-options]: https://github.com/DavidAnson/markdownlint/blob/main/README.md#options
462
- [markdownlint-rules-aliases]: https://github.com/DavidAnson/markdownlint/blob/main/README.md#rules--aliases
463
- [markdownlint-rules-tags]: https://github.com/DavidAnson/markdownlint/blob/main/README.md#tags
435
+ [markdownlint-config]: https://github.com/DavidAnson/markdownlint/blob/v0.32.1/README.md#optionsconfig
436
+ [markdownlint-configuration]: https://github.com/DavidAnson/markdownlint/blob/v0.32.1/README.md#configuration
437
+ [markdownlint-custom-rules]: https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/CustomRules.md
438
+ [markdownlint-options]: https://github.com/DavidAnson/markdownlint/blob/v0.32.1/README.md#options
439
+ [markdownlint-rules-aliases]: https://github.com/DavidAnson/markdownlint/blob/v0.32.1/README.md#rules--aliases
440
+ [markdownlint-rules-tags]: https://github.com/DavidAnson/markdownlint/blob/v0.32.1/README.md#tags
464
441
  [markdownlint-cli]: https://github.com/igorshubovych/markdownlint-cli
465
442
  [markdownlint-cli2]: https://github.com/DavidAnson/markdownlint-cli2
466
443
  [markdownlint-cli2-action]: https://github.com/marketplace/actions/markdownlint-cli2-action
467
444
  [markdownlint-cli2-blog]: https://dlaa.me/blog/post/markdownlintcli2
468
- [markdownlint-cli2-formatter]: https://www.npmjs.com/search?q=keywords:markdownlint-cli2-formatter
469
445
  [markdownlint-cli2-cjs]: test/markdownlint-cli2-cjs/.markdownlint-cli2.cjs
446
+ [markdownlint-cli2-config-schema]: schema/markdownlint-cli2-config-schema.json
447
+ [markdownlint-cli2-formatter]: https://www.npmjs.com/search?q=keywords:markdownlint-cli2-formatter
470
448
  [markdownlint-cli2-jsonc]: test/markdownlint-cli2-jsonc-example/.markdownlint-cli2.jsonc
471
449
  [markdownlint-cli2-mjs]: test/markdownlint-cli2-mjs/.markdownlint-cli2.mjs
472
450
  [markdownlint-cli2-yaml]: test/markdownlint-cli2-yaml-example/.markdownlint-cli2.yaml
473
451
  [markdownlint-cjs]: test/markdownlint-cjs/.markdownlint.cjs
474
- [markdownlint-jsonc]: https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.jsonc
452
+ [markdownlint-jsonc]: https://github.com/DavidAnson/markdownlint/blob/v0.32.1/schema/.markdownlint.jsonc
475
453
  [markdownlint-mjs]: test/markdownlint-mjs/.markdownlint.mjs
476
454
  [markdownlint-rule]: https://www.npmjs.com/search?q=keywords:markdownlint-rule
477
- [markdownlint-yaml]: https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml
455
+ [markdownlint-yaml]: https://github.com/DavidAnson/markdownlint/blob/v0.32.1/schema/.markdownlint.yaml
478
456
  [nodejs]: https://nodejs.org/
479
457
  [nodejs-docker]: https://github.com/nodejs/docker-node
480
458
  [nodejs-docker-non-root]: https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#non-root-user
@@ -490,6 +468,7 @@ See [CHANGELOG.md][changelog].
490
468
  [pre-commit-version]: https://pre-commit.com/#overriding-language-version
491
469
  [regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
492
470
  [regexp-constructor]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp
471
+ [validating-configuration]: schema/ValidatingConfiguration.md
493
472
  [vscode]: https://code.visualstudio.com/
494
473
  [vscode-markdownlint]: https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint
495
474
  [yaml]: https://wikipedia.org/wiki/YAML
@@ -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.11.0";
29
+ const packageVersion = "0.12.0";
30
30
  const libraryName = "markdownlint";
31
31
  const libraryVersion = markdownlintLibrary.getVersion();
32
32
  const dotOnlySubstitute = "*.{md,markdown}";
@@ -243,7 +243,7 @@ const processArgv = (argv) => {
243
243
  const showHelp = (logMessage) => {
244
244
  logMessage(`https://github.com/DavidAnson/markdownlint-cli2
245
245
 
246
- Syntax: markdownlint-cli2 glob0 [glob1] [...] [globN] [--config file] [--fix]
246
+ Syntax: markdownlint-cli2 glob0 [glob1] [...] [globN] [--config file] [--fix] [--help]
247
247
 
248
248
  Glob expressions (from the globby library):
249
249
  - * matches any number of characters, but not /
@@ -259,8 +259,10 @@ Dot-only glob:
259
259
  - To lint every file in the current directory tree, the command "markdownlint-cli2 **" can be used instead
260
260
 
261
261
  Optional parameters:
262
- - --config specifies the path to a configuration file to define the base configuration
263
- - --fix updates files to resolve fixable issues (can be overridden in configuration)
262
+ - --config specifies the path to a configuration file to define the base configuration
263
+ - --fix updates files to resolve fixable issues (can be overridden in configuration)
264
+ - --help writes this message to the console and exits without doing anything else
265
+ - --no-globs ignores the "globs" property if present in the top-level options object
264
266
 
265
267
  Configuration via:
266
268
  - .markdownlint-cli2.jsonc
@@ -281,6 +283,7 @@ Cross-platform compatibility:
281
283
  The most compatible syntax for cross-platform support:
282
284
  $ markdownlint-cli2 "**/*.md" "#node_modules"`
283
285
  );
286
+ return 2;
284
287
  };
285
288
 
286
289
  // Get (creating if necessary) and process a directory's info object
@@ -893,9 +896,10 @@ const main = async (params) => {
893
896
  optionsOverride,
894
897
  fileContents,
895
898
  nonFileContents,
896
- noGlobs,
897
- noRequire,
898
- name
899
+ noRequire
900
+ } = params;
901
+ let {
902
+ noGlobs
899
903
  } = params;
900
904
  const logMessage = params.logMessage || noop;
901
905
  const logError = params.logError || noop;
@@ -906,25 +910,36 @@ const main = async (params) => {
906
910
  const baseDir = posixPath(baseDirSystem);
907
911
  // Output banner
908
912
  logMessage(
909
- `${name || packageName} v${packageVersion} (${libraryName} v${libraryVersion})`
913
+ `${packageName} v${packageVersion} (${libraryName} v${libraryVersion})`
910
914
  );
911
915
  // Merge and process args/argv
912
916
  let fixDefault = false;
913
917
  // eslint-disable-next-line unicorn/no-useless-undefined
914
918
  let configPath = undefined;
919
+ let shouldShowHelp = false;
915
920
  const argvFiltered = (argv || []).filter((arg) => {
916
921
  if (configPath === null) {
917
922
  configPath = arg;
918
923
  return false;
924
+ // eslint-disable-next-line unicorn/prefer-switch
919
925
  } else if (arg === "--config") {
920
926
  configPath = null;
921
927
  return false;
922
928
  } else if (arg === "--fix") {
923
929
  fixDefault = true;
924
930
  return false;
931
+ } else if (arg === "--help") {
932
+ shouldShowHelp = true;
933
+ return false;
934
+ } else if (arg === "--no-globs") {
935
+ noGlobs = true;
936
+ return false;
925
937
  }
926
938
  return true;
927
939
  });
940
+ if (shouldShowHelp) {
941
+ return showHelp(logMessage);
942
+ }
928
943
  // Read argv configuration file (if relevant and present)
929
944
  let optionsArgv = null;
930
945
  let relativeDir = null;
@@ -952,8 +967,7 @@ const main = async (params) => {
952
967
  ((globPatterns.length === 0) && !nonFileContents) ||
953
968
  (configPath === null)
954
969
  ) {
955
- showHelp(logMessage);
956
- return 2;
970
+ return showHelp(logMessage);
957
971
  }
958
972
  // Include any file overrides or non-file content
959
973
  const resolvedFileContents = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdownlint-cli2",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
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",
@@ -15,9 +15,7 @@
15
15
  "./markdownlint/helpers": "./export-markdownlint-helpers.js"
16
16
  },
17
17
  "bin": {
18
- "markdownlint-cli2": "markdownlint-cli2.js",
19
- "markdownlint-cli2-config": "markdownlint-cli2-config.js",
20
- "markdownlint-cli2-fix": "markdownlint-cli2-fix.js"
18
+ "markdownlint-cli2": "markdownlint-cli2.js"
21
19
  },
22
20
  "homepage": "https://github.com/DavidAnson/markdownlint-cli2",
23
21
  "repository": {
@@ -29,7 +27,7 @@
29
27
  "scripts": {
30
28
  "build-docker-image": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker build -t davidanson/markdownlint-cli2:v$VERSION -f docker/Dockerfile --label org.opencontainers.image.version=v$VERSION .",
31
29
  "build-docker-image-rules": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker build -t davidanson/markdownlint-cli2-rules:v$VERSION -f docker/Dockerfile-rules --build-arg VERSION=v$VERSION --label org.opencontainers.image.version=v$VERSION .",
32
- "ci": "npm-run-all --continue-on-error --parallel test-cover lint schema",
30
+ "ci": "npm-run-all --continue-on-error --parallel test-cover lint schema && git diff --exit-code",
33
31
  "lint": "eslint --max-warnings 0 --no-eslintrc --config .eslintrc.json .",
34
32
  "lint-dockerfile": "docker run --rm -i hadolint/hadolint:latest-alpine < docker/Dockerfile",
35
33
  "lint-watch": "git ls-files | entr npm run lint",
@@ -56,17 +54,16 @@
56
54
  "export-markdownlint-helpers.js",
57
55
  "LICENSE",
58
56
  "markdownlint-cli2.js",
59
- "markdownlint-cli2-config.js",
60
- "markdownlint-cli2-fix.js",
61
57
  "merge-options.js",
62
58
  "README.md",
63
59
  "resolve-and-require.js",
64
60
  "schema/markdownlint-cli2-config-schema.json",
65
- "schema/markdownlint-config-schema.json"
61
+ "schema/markdownlint-config-schema.json",
62
+ "schema/ValidatingConfiguration.md"
66
63
  ],
67
64
  "dependencies": {
68
65
  "globby": "14.0.0",
69
- "markdownlint": "0.32.1",
66
+ "markdownlint": "0.33.0",
70
67
  "markdownlint-cli2-formatter-default": "0.0.4",
71
68
  "micromatch": "4.0.5",
72
69
  "strip-json-comments": "5.0.1",
@@ -74,18 +71,18 @@
74
71
  },
75
72
  "devDependencies": {
76
73
  "@iktakahiro/markdown-it-katex": "4.0.1",
77
- "ava": "5.3.1",
78
- "c8": "8.0.1",
74
+ "ajv": "8.12.0",
75
+ "ava": "6.0.1",
76
+ "c8": "9.0.0",
79
77
  "cpy": "11.0.0",
80
78
  "cpy-cli": "5.0.0",
81
79
  "del": "7.1.0",
82
- "eslint": "8.54.0",
83
- "eslint-plugin-n": "16.3.1",
84
- "eslint-plugin-unicorn": "49.0.0",
80
+ "eslint": "8.56.0",
81
+ "eslint-plugin-n": "16.6.2",
82
+ "eslint-plugin-unicorn": "50.0.1",
85
83
  "execa": "8.0.1",
86
- "@hyperjump/json-schema": "1.6.5",
87
- "markdown-it-emoji": "2.0.2",
88
- "markdown-it-for-inline": "0.1.1",
84
+ "markdown-it-emoji": "3.0.0",
85
+ "markdown-it-for-inline": "2.0.1",
89
86
  "markdownlint-cli2-formatter-codequality": "0.0.4",
90
87
  "markdownlint-cli2-formatter-json": "0.0.7",
91
88
  "markdownlint-cli2-formatter-junit": "0.0.8",
@@ -0,0 +1,24 @@
1
+ # Validating Configuration
2
+
3
+ A [JSON Schema][json-schema] is provided to enable validating options objects:
4
+ [`markdownlint-cli2-config-schema.json`][markdownlint-cli2-config-schema]
5
+
6
+ Some editors automatically use a JSON Schema with files that reference it. For
7
+ example, a `.markdownlint-cli2.jsonc` file with:
8
+
9
+ ```json
10
+ "$schema": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/main/schema/markdownlint-cli2-config-schema.json"
11
+ ```
12
+
13
+ A JSON Schema validator can be used to check configuration files like so:
14
+
15
+ ```bash
16
+ npx ajv-cli validate -s ./markdownlint-cli2/schema/markdownlint-cli2-config-schema.json -r ./markdownlint-cli2/schema/markdownlint-config-schema.json -d "**/.markdownlint-cli2.{jsonc,yaml}" --strict=false
17
+ ```
18
+
19
+ A similar process is documented for validating `markdownlint` configuration
20
+ objects: [Validating Configuration][validating-configuration].
21
+
22
+ [json-schema]: https://json-schema.org
23
+ [markdownlint-cli2-config-schema]: markdownlint-cli2-config-schema.json
24
+ [validating-configuration]: https://github.com/DavidAnson/markdownlint/blob/main/schema/ValidatingConfiguration.md
@@ -1,16 +1,17 @@
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
4
  "title": "markdownlint-cli2 configuration schema",
4
5
  "type": "object",
5
6
  "properties": {
6
7
  "$schema": {
7
- "description": "JSON Schema URI (used by some editors)",
8
+ "description": "JSON Schema URI (expected by some editors)",
8
9
  "type": "string",
9
- "default": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/main/schema/markdownlint-cli2-config-schema.json"
10
+ "default": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.12.0/schema/markdownlint-cli2-config-schema.json"
10
11
  },
11
12
  "config": {
12
13
  "description": "markdownlint-cli2 configuration schema",
13
- "$ref": "./markdownlint-config-schema.json",
14
+ "$ref": "https://raw.githubusercontent.com/DavidAnson/markdownlint/v0.33.0/schema/markdownlint-config-schema.json",
14
15
  "default": {}
15
16
  },
16
17
  "customRules": {