@ivuorinen/markdownlint-config 1.3.11 → 2.0.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
@@ -24,7 +24,7 @@ npm install @ivuorinen/markdownlint-config --save-dev
24
24
  yarn add @ivuorinen/markdownlint-config --dev
25
25
  ```
26
26
 
27
- After installing it, a _`.markdownlint.json`_ file will be created automatically in the project's root folder with the following configuration:
27
+ Create a _`.markdownlint.json`_ in the project's root folder with the following configuration:
28
28
 
29
29
  ```json
30
30
  {
@@ -32,13 +32,20 @@ After installing it, a _`.markdownlint.json`_ file will be created automatically
32
32
  }
33
33
  ```
34
34
 
35
+ With npm, a `postinstall` script writes exactly this file when the project has no markdownlint config yet (npm 11
36
+ warns that the script is not covered by `allowScripts`). Yarn 4 does not run dependency install scripts, so no file is
37
+ written. pnpm refuses unapproved install scripts and fails the install until you allow this package with
38
+ `pnpm approve-builds`. In both cases create the file by hand as above.
39
+
40
+ Requires Node.js `^22.22.2 || ^24.15.0 || >=26`, the floor of the bundled `markdownlint-cli`.
41
+
35
42
  ## Documentation
36
43
 
37
44
  Read the [MarkdownLint docs][markdownlint-docs-link] for more information.
38
45
 
39
46
  ## Contributing
40
47
 
41
- If you are interested in helping contribute, please take a look at our [contribution guidelines][contributing-link] and open an [issue][issue-link] or [pull request][pull-request-link].
48
+ If you are interested in helping contribute, please open an [issue][issue-link] or [pull request][pull-request-link].
42
49
 
43
50
  ## Changelog
44
51
 
@@ -51,7 +58,6 @@ Distributed under the MIT License. See [LICENSE][license-link] for more informat
51
58
  [changelog-link]: https://github.com/ivuorinen/base-configs-markdownlint/releases
52
59
  [markdownlint-docs-link]: https://github.com/DavidAnson/markdownlint
53
60
  [markdownlint-link]: https://github.com/DavidAnson/markdownlint
54
- [contributing-link]: https://github.com/ivuorinen/.github/blob/main/CONTRIBUTING.md
55
61
  [issue-link]: https://github.com/ivuorinen/base-configs-markdownlint/issues
56
62
  [license-badge]: https://img.shields.io/github/license/ivuorinen/base-configs-markdownlint?style=flat-square&labelColor=292a44&color=663399
57
63
  [license-link]: ./LICENSE.md
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ivuorinen/markdownlint-config",
3
- "version": "1.3.11",
3
+ "version": "2.0.0",
4
4
  "type": "module",
5
5
  "description": "ivuorinen's shareable configuration for markdownlint.",
6
6
  "author": {
@@ -11,7 +11,7 @@
11
11
  "url": "https://github.com/ivuorinen/base-configs-markdownlint/issues"
12
12
  },
13
13
  "engines": {
14
- "node": ">=20"
14
+ "node": "^22.22.2 || ^24.15.0 || >=26"
15
15
  },
16
16
  "files": [
17
17
  "index.json",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "scripts": {
40
40
  "postinstall": "node scripts/postinstall.cjs",
41
- "test": "node -e \"JSON.parse(require('fs').readFileSync('./index.json', 'utf8')); console.log('index.json is valid JSON');\""
41
+ "test": "node -e \"JSON.parse(require('fs').readFileSync('./index.json', 'utf8')); console.log('index.json is valid JSON');\" && node --test"
42
42
  },
43
43
  "dependencies": {
44
44
  "@ivuorinen/config-checker": "^2.6.7",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "packageManager": "yarn@4.18.0",
48
48
  "devDependencies": {
49
- "@ivuorinen/semantic-release-config": "^2.0.7"
49
+ "@ivuorinen/semantic-release-config": "^3.0.0"
50
50
  },
51
51
  "resolutions": {
52
52
  "minimatch": "^10.2.4",
@@ -7,7 +7,14 @@ const path = require("node:path");
7
7
  // noinspection NpmUsedModulesInstalled
8
8
  const process = require("node:process");
9
9
  const checkConfig = require("@ivuorinen/config-checker");
10
- const foundConfig = checkConfig("markdownlint");
10
+
11
+ // This runs on every consumer install, and a non-zero exit fails that whole
12
+ // install. The starter config is a convenience, so every step below degrades to
13
+ // a message instead of throwing.
14
+
15
+ // INIT_CWD is an npm/yarn convention, not a guarantee.
16
+ const cwd = process.env.INIT_CWD || process.cwd();
17
+ const foundConfig = checkConfig("markdownlint", cwd);
11
18
 
12
19
  if (foundConfig.length > 0) {
13
20
  console.log("markdownlint-config: Found existing markdownlint config file, skipping creation.");
@@ -16,11 +23,18 @@ if (foundConfig.length > 0) {
16
23
  process.exit(0);
17
24
  }
18
25
 
19
- const filePath = path.join(process.env.INIT_CWD, ".markdownlint.json");
26
+ const filePath = path.join(cwd, ".markdownlint.json");
20
27
  const fileConfigObject = {
21
28
  extends: "@ivuorinen/markdownlint-config",
22
29
  };
23
30
 
24
- if (!fs.existsSync(filePath)) {
25
- fs.writeFileSync(filePath, JSON.stringify(fileConfigObject, undefined, 2));
31
+ // "wx" makes "does it exist?" and "write it" one atomic step, so a concurrent
32
+ // install cannot create the file in between and have it overwritten.
33
+ try {
34
+ fs.writeFileSync(filePath, JSON.stringify(fileConfigObject, undefined, 2), { flag: "wx" });
35
+ } catch (error) {
36
+ if (error.code !== "EEXIST") {
37
+ console.log(`markdownlint-config: could not write ${filePath} (${error.code || error.message}).`);
38
+ console.log(`markdownlint-config: create it manually with ${JSON.stringify(fileConfigObject)}`);
39
+ }
26
40
  }