markdownlint-cli 0.31.0 → 0.32.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/README.md CHANGED
@@ -42,6 +42,12 @@ markdownlint --help
42
42
  -h, --help display help for command
43
43
  ```
44
44
 
45
+ Or run using [Docker](https://www.docker.com) and [GitHub Packages](https://github.com/features/packages):
46
+
47
+ ```bash
48
+ docker run -v $PWD:/workdir ghcr.io/igorshubovych/markdownlint-cli:latest "*.md"
49
+ ```
50
+
45
51
  ### Globbing
46
52
 
47
53
  `markdownlint-cli` supports advanced globbing patterns like `**/*.md` ([more information][globprimer]).
@@ -96,10 +102,11 @@ A sample configuration file:
96
102
  For more examples, see [.markdownlint.jsonc][markdownlint-jsonc], [.markdownlint.yaml][markdownlint-yaml], or the [style folder][style-folder].
97
103
 
98
104
  The CLI argument `--config` is not required.
99
- If it is not provided, `markdownlint-cli` looks for the file `.markdownlint.json`/`.markdownlint.yaml`/`.markdownlint.yml` in current folder, or for the file `.markdownlintrc` in the current or all parent folders.
105
+ 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.
100
106
  The algorithm is described in detail on the [`rc` package page][rc-standards].
101
107
  If the `--config` argument is provided, the file must be valid JSON, JSONC, JS, or YAML.
102
- JS configuration files contain JavaScript code, must have the `.js` extension, and must export (via `module.exports = ...`) a configuration object of the form shown above.
108
+ 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
+ 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**.
103
110
  A JS configuration file may internally `require` one or more npm packages as a way of reusing configuration across projects.
104
111
 
105
112
  `--enable` and `--disable` override configuration files; if a configuration file disables `MD002` and you pass `--enable MD002`, it will be enabled.
@@ -123,7 +130,7 @@ To run `markdownlint-cli` as part of a [pre-commit][pre-commit] workflow, add so
123
130
 
124
131
  ```yaml
125
132
  - repo: https://github.com/igorshubovych/markdownlint-cli
126
- rev: v0.31.0
133
+ rev: v0.32.1
127
134
  hooks:
128
135
  - id: markdownlint
129
136
  ```
@@ -155,3 +162,4 @@ MIT © Igor Shubovych
155
162
  [gitignore]: https://git-scm.com/docs/gitignore
156
163
  [pre-commit]: https://pre-commit.com/
157
164
  [pre-commit-version]: https://pre-commit.com/#overriding-language-version
165
+ [ESM-only]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
package/markdownlint.js CHANGED
@@ -16,6 +16,10 @@ const rc = require('run-con');
16
16
  const minimatch = require('minimatch');
17
17
  const pkg = require('./package.json');
18
18
 
19
+ function posixPath(p) {
20
+ return p.split(path.sep).join(path.posix.sep);
21
+ }
22
+
19
23
  function jsoncParse(text) {
20
24
  return JSON.parse(require('jsonc-parser').stripComments(text));
21
25
  }
@@ -31,13 +35,13 @@ const exitCodes = {
31
35
  unexpectedError: 4
32
36
  };
33
37
 
34
- const projectConfigFiles = ['.markdownlint.json', '.markdownlint.yaml', '.markdownlint.yml'];
38
+ const projectConfigFiles = ['.markdownlint.jsonc', '.markdownlint.json', '.markdownlint.yaml', '.markdownlint.yml'];
35
39
  const configFileParsers = [jsoncParse, jsYamlSafeLoad];
36
40
  const fsOptions = {encoding: 'utf8'};
37
41
  const processCwd = process.cwd();
38
42
 
39
43
  function readConfiguration(userConfigFile) {
40
- const jsConfigFile = /\.js$/i.test(userConfigFile);
44
+ const jsConfigFile = /\.c?js$/i.test(userConfigFile);
41
45
 
42
46
  // Load from well-known config files
43
47
  let config = rc('markdownlint', {});
@@ -85,16 +89,16 @@ function prepareFileList(files, fileExtensions, previousResults) {
85
89
  if (fs.lstatSync(file).isDirectory()) {
86
90
  // Directory (file falls through to below)
87
91
  if (previousResults) {
88
- const matcher = new minimatch.Minimatch(path.resolve(processCwd, path.join(file, '**', extensionGlobPart)), globOptions);
92
+ const matcher = new minimatch.Minimatch(posixPath(path.resolve(processCwd, path.join(file, '**', extensionGlobPart))), globOptions);
89
93
  return previousResults.filter(fileInfo => matcher.match(fileInfo.absolute)).map(fileInfo => fileInfo.original);
90
94
  }
91
95
 
92
- return glob.sync(path.join(file, '**', extensionGlobPart), globOptions);
96
+ return glob.sync(posixPath(path.join(file, '**', extensionGlobPart)), globOptions);
93
97
  }
94
98
  } catch {
95
99
  // Not a directory, not a file, may be a glob
96
100
  if (previousResults) {
97
- const matcher = new minimatch.Minimatch(path.resolve(processCwd, file), globOptions);
101
+ const matcher = new minimatch.Minimatch(posixPath(path.resolve(processCwd, file)), globOptions);
98
102
  return previousResults.filter(fileInfo => matcher.match(fileInfo.absolute)).map(fileInfo => fileInfo.original);
99
103
  }
100
104
 
@@ -311,7 +315,6 @@ try {
311
315
  if (files.length > 0 && !options.stdin) {
312
316
  lintAndPrint(null, diff);
313
317
  } else if (files.length === 0 && options.stdin && !options.fix) {
314
- // eslint-disable-next-line node/no-unsupported-features/es-syntax
315
318
  import('get-stdin')
316
319
  .then(module => module.default())
317
320
  .then(lintAndPrint);
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "markdownlint-cli",
3
- "version": "0.31.0",
3
+ "version": "0.32.1",
4
4
  "description": "MarkdownLint Command Line Interface",
5
5
  "main": "markdownlint.js",
6
6
  "bin": {
7
7
  "markdownlint": "markdownlint.js"
8
8
  },
9
9
  "engines": {
10
- "node": ">=12"
10
+ "node": ">=14"
11
11
  },
12
12
  "scripts": {
13
13
  "invalid": "node ./markdownlint.js --config test/test-config.json -- test/incorrect.md",
@@ -37,22 +37,22 @@
37
37
  },
38
38
  "homepage": "https://github.com/igorshubovych/markdownlint-cli#readme",
39
39
  "dependencies": {
40
- "commander": "~9.0.0",
40
+ "commander": "~9.4.0",
41
41
  "get-stdin": "~9.0.0",
42
- "glob": "~7.2.0",
42
+ "glob": "~8.0.3",
43
43
  "ignore": "~5.2.0",
44
44
  "js-yaml": "^4.1.0",
45
- "jsonc-parser": "~3.0.0",
46
- "markdownlint": "~0.25.1",
47
- "markdownlint-rule-helpers": "~0.16.0",
48
- "minimatch": "~3.0.4",
49
- "run-con": "~1.2.10"
45
+ "jsonc-parser": "~3.1.0",
46
+ "markdownlint": "~0.26.1",
47
+ "markdownlint-rule-helpers": "~0.17.1",
48
+ "minimatch": "~5.1.0",
49
+ "run-con": "~1.2.11"
50
50
  },
51
51
  "devDependencies": {
52
- "ava": "^4.0.1",
53
- "execa": "^6.0.0",
52
+ "ava": "^4.3.1",
53
+ "execa": "^6.1.0",
54
54
  "test-rule-package": "./test/custom-rules/test-rule-package",
55
- "xo": "^0.47.0"
55
+ "xo": "^0.51.0"
56
56
  },
57
57
  "xo": {
58
58
  "prettier": true,
@@ -83,6 +83,7 @@
83
83
  "!test/md043-config.js"
84
84
  ],
85
85
  "failFast": true,
86
+ "timeout": "1m",
86
87
  "workerThreads": false
87
88
  }
88
89
  }