markdownlint-cli 0.31.1 → 0.32.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/README.md CHANGED
@@ -102,10 +102,11 @@ A sample configuration file:
102
102
  For more examples, see [.markdownlint.jsonc][markdownlint-jsonc], [.markdownlint.yaml][markdownlint-yaml], or the [style folder][style-folder].
103
103
 
104
104
  The CLI argument `--config` is not required.
105
- 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.
106
106
  The algorithm is described in detail on the [`rc` package page][rc-standards].
107
107
  If the `--config` argument is provided, the file must be valid JSON, JSONC, JS, or YAML.
108
- 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**.
109
110
  A JS configuration file may internally `require` one or more npm packages as a way of reusing configuration across projects.
110
111
 
111
112
  `--enable` and `--disable` override configuration files; if a configuration file disables `MD002` and you pass `--enable MD002`, it will be enabled.
@@ -129,7 +130,7 @@ To run `markdownlint-cli` as part of a [pre-commit][pre-commit] workflow, add so
129
130
 
130
131
  ```yaml
131
132
  - repo: https://github.com/igorshubovych/markdownlint-cli
132
- rev: v0.31.1
133
+ rev: v0.32.0
133
134
  hooks:
134
135
  - id: markdownlint
135
136
  ```
@@ -161,3 +162,4 @@ MIT © Igor Shubovych
161
162
  [gitignore]: https://git-scm.com/docs/gitignore
162
163
  [pre-commit]: https://pre-commit.com/
163
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.1",
3
+ "version": "0.32.0",
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.5",
49
- "run-con": "~1.2.10"
45
+ "jsonc-parser": "~3.1.0",
46
+ "markdownlint": "~0.26.0",
47
+ "markdownlint-rule-helpers": "~0.17.0",
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.50.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
  }