markdownlint-cli 0.43.0 → 0.44.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 +24 -21
  2. package/markdownlint.js +28 -33
  3. package/package.json +15 -10
package/README.md CHANGED
@@ -21,26 +21,29 @@ brew install markdownlint-cli
21
21
  ```bash
22
22
  markdownlint --help
23
23
 
24
- Usage: markdownlint [options] <files|directories|globs>
25
-
26
- MarkdownLint Command Line Interface
27
-
28
- Options:
29
- -V, --version output the version number
30
- -c, --config <configFile> configuration file (JSON, JSONC, JS, YAML, or TOML)
31
- --configPointer <pointer> JSON Pointer to object within configuration file (default: "")
32
- -d, --dot include files/folders with a dot (for example `.github`)
33
- -f, --fix fix basic errors (does not work with STDIN)
34
- -i, --ignore <file|directory|glob> file(s) to ignore/exclude (default: [])
35
- -j, --json write issues in json format
36
- -o, --output <outputFile> write issues to file (no console)
37
- -p, --ignore-path <file> path to file with ignore pattern(s)
38
- -q, --quiet do not write issues to STDOUT
39
- -r, --rules <file|directory|glob|package> include custom rule files (default: [])
40
- -s, --stdin read from STDIN (does not work with files)
41
- --enable <rules...> Enable certain rules, e.g. --enable MD013 MD041 --
42
- --disable <rules...> Disable certain rules, e.g. --disable MD013 MD041 --
43
- -h, --help display help for command
24
+ Usage: markdownlint [options] [files|directories|globs...]
25
+
26
+ MarkdownLint Command Line Interface
27
+
28
+ Arguments:
29
+ files|directories|globs files, directories, and/or globs to lint
30
+
31
+ Options:
32
+ -V, --version output the version number
33
+ -c, --config <configFile> configuration file (JSON, JSONC, JS, YAML, or TOML)
34
+ --configPointer <pointer> JSON Pointer to object within configuration file (default: "")
35
+ -d, --dot include files/folders with a dot (for example `.github`)
36
+ -f, --fix fix basic errors (does not work with STDIN)
37
+ -i, --ignore <file|directory|glob> file(s) to ignore/exclude (default: [])
38
+ -j, --json write issues in json format
39
+ -o, --output <outputFile> write issues to file (no console)
40
+ -p, --ignore-path <file> path to file with ignore pattern(s)
41
+ -q, --quiet do not write issues to STDOUT
42
+ -r, --rules <file|directory|glob|package> include custom rule files (default: [])
43
+ -s, --stdin read from STDIN (does not work with files)
44
+ --enable <rules...> Enable certain rules, e.g. --enable MD013 MD041 --
45
+ --disable <rules...> Disable certain rules, e.g. --disable MD013 MD041 --
46
+ -h, --help display help for command
44
47
  ```
45
48
 
46
49
  Or run using [Docker](https://www.docker.com) and [GitHub Packages](https://github.com/features/packages):
@@ -139,7 +142,7 @@ To run `markdownlint-cli` as part of a [pre-commit][pre-commit] workflow, add so
139
142
 
140
143
  ```yaml
141
144
  - repo: https://github.com/igorshubovych/markdownlint-cli
142
- rev: v0.43.0
145
+ rev: v0.44.0
143
146
  hooks:
144
147
  - id: markdownlint
145
148
  ```
package/markdownlint.js CHANGED
@@ -1,21 +1,23 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- 'use strict';
4
-
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
- const {program} = require('commander');
11
- const glob = require('glob');
12
- const markdownlint = require('markdownlint');
13
- const rc = require('run-con');
14
- const minimatch = require('minimatch');
15
- const jsonpointer = require('jsonpointer');
16
- const pkg = require('./package.json');
17
-
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ import Module from 'node:module';
6
+ import os from 'node:os';
7
+ import process from 'node:process';
8
+ import {program} from 'commander';
9
+ import {glob} from 'glob';
10
+ import {applyFixes} from 'markdownlint';
11
+ import {lint, readConfig} from 'markdownlint/sync';
12
+ import rc from 'run-con';
13
+ import {minimatch} from 'minimatch';
14
+ import jsonpointer from 'jsonpointer';
15
+
16
+ const require = Module.createRequire(import.meta.url);
18
17
  const options = program.opts();
18
+ // The following two values are copied from package.json (and validated by tests)
19
+ const version = '0.44.0';
20
+ const description = 'MarkdownLint Command Line Interface';
19
21
 
20
22
  function posixPath(p) {
21
23
  return p.split(path.sep).join(path.posix.sep);
@@ -60,7 +62,7 @@ function readConfiguration(userConfigFile) {
60
62
  for (const projectConfigFile of projectConfigFiles) {
61
63
  try {
62
64
  fs.accessSync(projectConfigFile, fs.R_OK);
63
- const projectConfig = markdownlint.readConfigSync(projectConfigFile, configParsers);
65
+ const projectConfig = readConfig(projectConfigFile, configParsers);
64
66
  config = {...config, ...projectConfig};
65
67
  break;
66
68
  } catch {
@@ -73,7 +75,7 @@ function readConfiguration(userConfigFile) {
73
75
  if (userConfigFile) {
74
76
  try {
75
77
  const jsConfigFile = /\.c?js$/i.test(userConfigFile);
76
- const userConfig = jsConfigFile ? require(path.resolve(processCwd, userConfigFile)) : markdownlint.readConfigSync(userConfigFile, configParsers);
78
+ const userConfig = jsConfigFile ? require(path.resolve(processCwd, userConfigFile)) : readConfig(userConfigFile, configParsers);
77
79
  config = require('deep-extend')(config, userConfig);
78
80
  } catch (error) {
79
81
  console.error(`Cannot read or parse config file '${userConfigFile}': ${error.message}`);
@@ -195,9 +197,8 @@ function concatArray(item, array) {
195
197
  }
196
198
 
197
199
  program
198
- .version(pkg.version)
199
- .description(pkg.description)
200
- .usage('[options] <files|directories|globs>')
200
+ .version(version)
201
+ .description(description)
201
202
  .option('-c, --config <configFile>', 'configuration file (JSON, JSONC, JS, YAML, or TOML)')
202
203
  .option('--configPointer <pointer>', 'JSON Pointer to object within configuration file', '')
203
204
  .option('-d, --dot', 'include files/folders with a dot (for example `.github`)')
@@ -210,7 +211,8 @@ program
210
211
  .option('-r, --rules <file|directory|glob|package>', 'include custom rule files', concatArray, [])
211
212
  .option('-s, --stdin', 'read from STDIN (does not work with files)')
212
213
  .option('--enable <rules...>', 'Enable certain rules, e.g. --enable MD013 MD041 --')
213
- .option('--disable <rules...>', 'Disable certain rules, e.g. --disable MD013 MD041 --');
214
+ .option('--disable <rules...>', 'Disable certain rules, e.g. --disable MD013 MD041 --')
215
+ .argument('[files|directories|globs...]', 'files, directories, and/or globs to lint');
214
216
 
215
217
  program.parse(process.argv);
216
218
 
@@ -241,7 +243,7 @@ function loadCustomRules(rules) {
241
243
  return rules.flatMap(rule => {
242
244
  try {
243
245
  const resolvedPath = [tryResolvePath(rule)];
244
- const fileList = prepareFileList(resolvedPath, ['js']).flatMap(filepath => require(filepath.absolute));
246
+ const fileList = prepareFileList(resolvedPath, ['js', 'cjs', 'mjs']).flatMap(filepath => require(filepath.absolute));
245
247
  if (fileList.length === 0) {
246
248
  throw new Error('No such rule');
247
249
  }
@@ -300,22 +302,15 @@ function lintAndPrint(stdin, files) {
300
302
  };
301
303
  }
302
304
 
303
- if (options.json) {
304
- lintOptions.resultVersion = 3;
305
- }
306
-
307
305
  if (options.fix) {
308
- const fixOptions = {
309
- ...lintOptions,
310
- resultVersion: 3
311
- };
306
+ const fixOptions = {...lintOptions};
312
307
  for (const file of files) {
313
308
  fixOptions.files = [file];
314
- const fixResult = markdownlint.sync(fixOptions);
309
+ const fixResult = lint(fixOptions);
315
310
  const fixes = fixResult[file].filter(error => error.fixInfo);
316
311
  if (fixes.length > 0) {
317
312
  const originalText = fs.readFileSync(file, fsOptions);
318
- const fixedText = markdownlint.applyFixes(originalText, fixes);
313
+ const fixedText = applyFixes(originalText, fixes);
319
314
  if (originalText !== fixedText) {
320
315
  fs.writeFileSync(file, fixedText, fsOptions);
321
316
  }
@@ -323,7 +318,7 @@ function lintAndPrint(stdin, files) {
323
318
  }
324
319
  }
325
320
 
326
- const lintResult = markdownlint.sync(lintOptions);
321
+ const lintResult = lint(lintOptions);
327
322
  printResult(lintResult);
328
323
  }
329
324
 
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "markdownlint-cli",
3
- "version": "0.43.0",
3
+ "version": "0.44.0",
4
4
  "description": "MarkdownLint Command Line Interface",
5
+ "type": "module",
5
6
  "main": "markdownlint.js",
6
7
  "bin": {
7
8
  "markdownlint": "markdownlint.js"
@@ -37,14 +38,14 @@
37
38
  },
38
39
  "homepage": "https://github.com/igorshubovych/markdownlint-cli#readme",
39
40
  "dependencies": {
40
- "commander": "~12.1.0",
41
- "glob": "~11.0.0",
42
- "ignore": "~6.0.2",
43
- "js-yaml": "^4.1.0",
41
+ "commander": "~13.1.0",
42
+ "glob": "~10.4.5",
43
+ "ignore": "~7.0.3",
44
+ "js-yaml": "~4.1.0",
44
45
  "jsonc-parser": "~3.3.1",
45
- "jsonpointer": "5.0.1",
46
- "markdownlint": "~0.36.1",
47
- "minimatch": "~10.0.1",
46
+ "jsonpointer": "~5.0.1",
47
+ "markdownlint": "~0.37.4",
48
+ "minimatch": "~9.0.5",
48
49
  "run-con": "~1.3.2",
49
50
  "smol-toml": "~1.3.1"
50
51
  },
@@ -52,7 +53,7 @@
52
53
  "ava": "^6.2.0",
53
54
  "markdownlint-cli-local-test-rule": "./test/custom-rules/markdownlint-cli-local-test-rule",
54
55
  "nano-spawn": "^0.2.0",
55
- "xo": "^0.59.3"
56
+ "xo": "^0.60.0"
56
57
  },
57
58
  "xo": {
58
59
  "prettier": true,
@@ -80,8 +81,12 @@
80
81
  "ava": {
81
82
  "files": [
82
83
  "test/**/*.js",
84
+ "test/**/*.cjs",
85
+ "test/**/*.mjs",
83
86
  "!test/custom-rules/**/*.js",
84
- "!test/md043-config.js"
87
+ "!test/custom-rules/**/*.cjs",
88
+ "!test/custom-rules/**/*.mjs",
89
+ "!test/md043-config.cjs"
85
90
  ],
86
91
  "failFast": true,
87
92
  "timeout": "1m",