markdownlint-cli 0.32.1 → 0.33.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.
Files changed (3) hide show
  1. package/README.md +10 -3
  2. package/markdownlint.js +12 -11
  3. package/package.json +10 -10
package/README.md CHANGED
@@ -37,8 +37,8 @@ markdownlint --help
37
37
  -q, --quiet do not write issues to STDOUT
38
38
  -r, --rules [file|directory|glob|package] include custom rule files (default: [])
39
39
  -s, --stdin read from STDIN (does not work with files)
40
- --enable [rules...] Enable certain rules, e.g. --enable MD013 MD041
41
- --disable [rules...] Disable certain rules, e.g. --disable MD013 MD041
40
+ --enable [rules...] Enable certain rules, e.g. --enable MD013 MD041 --
41
+ --disable [rules...] Disable certain rules, e.g. --disable MD013 MD041 --
42
42
  -h, --help display help for command
43
43
  ```
44
44
 
@@ -48,6 +48,9 @@ Or run using [Docker](https://www.docker.com) and [GitHub Packages](https://gith
48
48
  docker run -v $PWD:/workdir ghcr.io/igorshubovych/markdownlint-cli:latest "*.md"
49
49
  ```
50
50
 
51
+ > **Note**
52
+ > Because `--enable` and `--disable` are [variadic arguments that accept multiple values][commander-variadic], it is necessary to end the list by passing `--` before the `<files|directories|globs>` argument like so: `markdownlint --disable MD013 -- README.md`.
53
+
51
54
  ### Globbing
52
55
 
53
56
  `markdownlint-cli` supports advanced globbing patterns like `**/*.md` ([more information][globprimer]).
@@ -104,6 +107,7 @@ For more examples, see [.markdownlint.jsonc][markdownlint-jsonc], [.markdownlint
104
107
  The CLI argument `--config` is not required.
105
108
  If it is not provided, `markdownlint-cli` looks for the file `.markdownlint.jsonc`/`.markdownlint.json`/`.markdownlint.yaml`/`.markdownlint.yml` in current folder, or for the file `.markdownlintrc` in the current or all parent folders.
106
109
  The algorithm is described in detail on the [`rc` package page][rc-standards].
110
+ Note that when relying on the lookup of a file named `.markdownlintrc` in the current or parent folders, the only syntaxes accepted are INI and JSON, and the file cannot have an extension.
107
111
  If the `--config` argument is provided, the file must be valid JSON, JSONC, JS, or YAML.
108
112
  JS configuration files contain JavaScript code, must have the `.js` or `.cjs` file extension, and must export (via `module.exports = ...`) a configuration object of the form shown above.
109
113
  If your workspace _(project)_ is [ESM-only] _(`"type": "module"` set in the root `package.json` file)_, then the configuration file **should end with `.cjs` file extension**.
@@ -130,7 +134,7 @@ To run `markdownlint-cli` as part of a [pre-commit][pre-commit] workflow, add so
130
134
 
131
135
  ```yaml
132
136
  - repo: https://github.com/igorshubovych/markdownlint-cli
133
- rev: v0.32.1
137
+ rev: v0.33.0
134
138
  hooks:
135
139
  - id: markdownlint
136
140
  ```
@@ -140,6 +144,7 @@ To run `markdownlint-cli` as part of a [pre-commit][pre-commit] workflow, add so
140
144
  ## Related
141
145
 
142
146
  - [markdownlint][markdownlint] - API for this module
147
+ - [markdownlint-cli2][markdownlint-cli2] - Alternate CLI implementation
143
148
  - [glob][glob] - Pattern matching implementation
144
149
  - [ignore][ignore] - `.markdownlintignore` implementation
145
150
 
@@ -149,7 +154,9 @@ MIT © Igor Shubovych
149
154
 
150
155
  [actions-badge]: https://github.com/igorshubovych/markdownlint-cli/workflows/CI/badge.svg?branch=master
151
156
  [actions-url]: https://github.com/igorshubovych/markdownlint-cli/actions?query=workflow%3ACI
157
+ [commander-variadic]: https://github.com/tj/commander.js#variadic-option
152
158
  [markdownlint]: https://github.com/DavidAnson/markdownlint
159
+ [markdownlint-cli2]: https://github.com/DavidAnson/markdownlint-cli2
153
160
  [markdownlint-jsonc]: https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.jsonc
154
161
  [markdownlint-yaml]: https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml
155
162
  [rules]: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
package/markdownlint.js CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  'use strict';
4
4
 
5
- const fs = require('fs');
6
- const path = require('path');
7
- const Module = require('module');
8
- const os = require('os');
9
- const process = require('process');
5
+ const fs = require('node:fs');
6
+ const path = require('node:path');
7
+ const Module = require('node:module');
8
+ const os = require('node:os');
9
+ const process = require('node:process');
10
10
  const program = require('commander');
11
11
 
12
12
  const options = program.opts();
@@ -36,7 +36,7 @@ const exitCodes = {
36
36
  };
37
37
 
38
38
  const projectConfigFiles = ['.markdownlint.jsonc', '.markdownlint.json', '.markdownlint.yaml', '.markdownlint.yml'];
39
- const configFileParsers = [jsoncParse, jsYamlSafeLoad];
39
+ const configParsers = [jsoncParse, jsYamlSafeLoad];
40
40
  const fsOptions = {encoding: 'utf8'};
41
41
  const processCwd = process.cwd();
42
42
 
@@ -48,7 +48,7 @@ function readConfiguration(userConfigFile) {
48
48
  for (const projectConfigFile of projectConfigFiles) {
49
49
  try {
50
50
  fs.accessSync(projectConfigFile, fs.R_OK);
51
- const projectConfig = markdownlint.readConfigSync(projectConfigFile, configFileParsers);
51
+ const projectConfig = markdownlint.readConfigSync(projectConfigFile, configParsers);
52
52
  config = {...config, ...projectConfig};
53
53
  break;
54
54
  } catch {
@@ -60,7 +60,7 @@ function readConfiguration(userConfigFile) {
60
60
  // However I have to do it to overwrite configuration from .markdownlint.{json,yaml,yml}.
61
61
  if (userConfigFile) {
62
62
  try {
63
- const userConfig = jsConfigFile ? require(path.resolve(processCwd, userConfigFile)) : markdownlint.readConfigSync(userConfigFile, configFileParsers);
63
+ const userConfig = jsConfigFile ? require(path.resolve(processCwd, userConfigFile)) : markdownlint.readConfigSync(userConfigFile, configParsers);
64
64
  config = require('deep-extend')(config, userConfig);
65
65
  } catch (error) {
66
66
  console.error(`Cannot read or parse config file '${userConfigFile}': ${error.message}`);
@@ -192,8 +192,8 @@ program
192
192
  .option('-q, --quiet', 'do not write issues to STDOUT')
193
193
  .option('-r, --rules [file|directory|glob|package]', 'include custom rule files', concatArray, [])
194
194
  .option('-s, --stdin', 'read from STDIN (does not work with files)')
195
- .option('--enable [rules...]', 'Enable certain rules, e.g. --enable MD013 MD041')
196
- .option('--disable [rules...]', 'Disable certain rules, e.g. --disable MD013 MD041');
195
+ .option('--enable [rules...]', 'Enable certain rules, e.g. --enable MD013 MD041 --')
196
+ .option('--disable [rules...]', 'Disable certain rules, e.g. --disable MD013 MD041 --');
197
197
 
198
198
  program.parse(process.argv);
199
199
 
@@ -274,6 +274,7 @@ function lintAndPrint(stdin, files) {
274
274
 
275
275
  const lintOptions = {
276
276
  config,
277
+ configParsers,
277
278
  customRules,
278
279
  files
279
280
  };
@@ -292,7 +293,7 @@ function lintAndPrint(stdin, files) {
292
293
  ...lintOptions,
293
294
  resultVersion: 3
294
295
  };
295
- const markdownlintRuleHelpers = require('markdownlint-rule-helpers');
296
+ const markdownlintRuleHelpers = require('markdownlint/helpers');
296
297
  for (const file of files) {
297
298
  fixOptions.files = [file];
298
299
  const fixResult = markdownlint.sync(fixOptions);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdownlint-cli",
3
- "version": "0.32.1",
3
+ "version": "0.33.0",
4
4
  "description": "MarkdownLint Command Line Interface",
5
5
  "main": "markdownlint.js",
6
6
  "bin": {
@@ -37,22 +37,21 @@
37
37
  },
38
38
  "homepage": "https://github.com/igorshubovych/markdownlint-cli#readme",
39
39
  "dependencies": {
40
- "commander": "~9.4.0",
40
+ "commander": "~9.4.1",
41
41
  "get-stdin": "~9.0.0",
42
42
  "glob": "~8.0.3",
43
- "ignore": "~5.2.0",
43
+ "ignore": "~5.2.4",
44
44
  "js-yaml": "^4.1.0",
45
- "jsonc-parser": "~3.1.0",
46
- "markdownlint": "~0.26.1",
47
- "markdownlint-rule-helpers": "~0.17.1",
48
- "minimatch": "~5.1.0",
45
+ "jsonc-parser": "~3.2.0",
46
+ "markdownlint": "~0.27.0",
47
+ "minimatch": "~5.1.2",
49
48
  "run-con": "~1.2.11"
50
49
  },
51
50
  "devDependencies": {
52
- "ava": "^4.3.1",
51
+ "ava": "^5.1.0",
53
52
  "execa": "^6.1.0",
54
53
  "test-rule-package": "./test/custom-rules/test-rule-package",
55
- "xo": "^0.51.0"
54
+ "xo": "^0.53.1"
56
55
  },
57
56
  "xo": {
58
57
  "prettier": true,
@@ -65,7 +64,8 @@
65
64
  "promise/prefer-await-to-then": 0,
66
65
  "object-shorthand": 0,
67
66
  "unicorn/prefer-module": 0,
68
- "unicorn/prefer-ternary": 0
67
+ "unicorn/prefer-ternary": 0,
68
+ "unicorn/prefer-top-level-await": 0
69
69
  }
70
70
  },
71
71
  "prettier": {