Skip to content

Commit 91a19c0

Browse files
committed
feat(remark-lint): add
1 parent 8ab9cea commit 91a19c0

30 files changed

+1458
-148
lines changed

.github/workflows/publish-packages.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,25 @@ jobs:
7272
# If a specific package is requested via workflow_dispatch, just publish that one
7373
echo "matrix={\"package\":[\"$PACKAGE\"]}" >> $GITHUB_OUTPUT
7474
else
75-
# Otherwise, identify all packages with changes since the last commit
7675
CHANGED_PACKAGES=()
7776
for pkg in $(ls -d packages/*); do
7877
PKG_NAME=$(basename "$pkg")
79-
# For manual runs, include all packages. For automatic runs, only include packages with changes
78+
PKG_JSON="$pkg/package.json"
79+
80+
# Determine if the package has changed (or include all on manual trigger)
8081
if [ "$EVENT_NAME" == "workflow_dispatch" ] || ! git diff --quiet $COMMIT_SHA~1 $COMMIT_SHA -- "$pkg/"; then
81-
CHANGED_PACKAGES+=("$PKG_NAME")
82+
HAS_VERSION=$(jq 'has("version")' "$PKG_JSON")
83+
if [ "$HAS_VERSION" == "false" ]; then
84+
# Include packages without version field
85+
CHANGED_PACKAGES+=("$PKG_NAME")
86+
else
87+
# For packages with version field, include only if version changed
88+
OLD_VERSION=$(git show $COMMIT_SHA~1:$PKG_JSON | jq -r '.version')
89+
NEW_VERSION=$(jq -r '.version' "$PKG_JSON")
90+
if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then
91+
CHANGED_PACKAGES+=("$PKG_NAME")
92+
fi
93+
fi
8294
fi
8395
done
8496
@@ -120,8 +132,12 @@ jobs:
120132
run: |
121133
# Install deps
122134
pnpm install --frozen-lockfile
123-
# Create a unique version using the commit SHA as a prerelease identifier
124-
npm version --no-git-tag-version 1.0.1-$COMMIT_SHA
135+
136+
HAS_VERSION=$(jq 'has("version")' package.json)
137+
if [ "$HAS_VERSION" == "false" ]; then
138+
# Only bump version if package has no version field
139+
npm version --no-git-tag-version 1.0.1-$COMMIT_SHA
140+
fi
125141
126142
# Check if a custom publish script exists in package.json
127143
if jq -e '.scripts.publish' package.json > /dev/null; then

apps/site/.remarkrc.json

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
11
{
2-
"settings": {
3-
"bullet": "-",
4-
"resourceLink": true
5-
},
6-
"plugins": [
7-
"remark-frontmatter",
8-
"remark-preset-lint-node",
9-
["remark-gfm", false],
10-
["remark-lint-fenced-code-flag", false],
11-
["remark-lint-first-heading-level", false],
12-
["remark-lint-maximum-line-length", false],
13-
["remark-lint-no-file-name-articles", false],
14-
["remark-lint-no-literal-urls", false],
15-
["remark-lint-no-unused-definitions", false],
16-
["remark-lint-no-undefined-references", false],
17-
["remark-lint-prohibited-strings", false],
18-
["remark-lint-unordered-list-marker-style", "-"],
19-
["remark-preset-lint-node/remark-lint-nodejs-links.js", false]
20-
]
2+
"plugins": ["remark-frontmatter", "@node-core/remark-lint"]
213
}

apps/site/package.json

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"@eslint/eslintrc": "~3.3.1",
8383
"@flarelabs-net/wrangler-build-time-fs-assets-polyfilling": "^0.0.1",
8484
"@next/eslint-plugin-next": "15.4.4",
85+
"@node-core/remark-lint": "workspace:*",
8586
"@opennextjs/cloudflare": "^1.6.4",
8687
"@playwright/test": "^1.54.1",
8788
"@testing-library/user-event": "~14.6.1",
@@ -95,17 +96,7 @@
9596
"global-jsdom": "^26.0.0",
9697
"handlebars": "4.7.8",
9798
"jsdom": "^26.0.0",
98-
"remark-frontmatter": "5.0.0",
99-
"remark-lint-fenced-code-flag": "^4.2.0",
100-
"remark-lint-first-heading-level": "^4.0.1",
101-
"remark-lint-maximum-line-length": "^4.1.1",
102-
"remark-lint-no-file-name-articles": "^3.0.1",
103-
"remark-lint-no-literal-urls": "^4.0.1",
104-
"remark-lint-no-undefined-references": "^5.0.2",
105-
"remark-lint-no-unused-definitions": "^4.0.2",
106-
"remark-lint-prohibited-strings": "^4.0.0",
107-
"remark-lint-unordered-list-marker-style": "^4.0.1",
108-
"remark-preset-lint-node": "5.1.2",
99+
"remark-frontmatter": "^5.0.0",
109100
"stylelint": "16.23.0",
110101
"stylelint-config-standard": "39.0.0",
111102
"stylelint-order": "7.0.0",

apps/site/pages/en/learn/modules/how-to-use-streams.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,7 @@ This work is derived from content published by [Matteo Collina][] in [Platformat
815815
[`on('close')`]: https://nodejs.org/api/stream.html#event-close_1
816816
[`on('error')`]: https://nodejs.org/api/stream.html#event-error_1
817817
[`.read()`]: https://nodejs.org/docs/latest/api/stream.html#stream_readable_read_size
818+
[`_read()`]: https://nodejs.org/api/stream.html#readable_readsize
818819
[`.write()`]: https://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback
819820
[`_write`]: https://nodejs.org/api/stream.html#writable_writechunk-encoding-callback
820821
[`.end()`]: https://nodejs.org/api/stream.html#writableendchunk-encoding-callback

apps/site/pages/en/learn/modules/publishing-a-package.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors: JakobJingleheimer
66

77
# Publishing a package
88

9-
All the provided `package.json` configurations (not specifically marked “does not work”) work in Node.js 12.22.x (v12 latest, the oldest supported line) and 17.2.0 [current latest at the time][^1], and for grins, with webpack 5.53.0 and 5.63.0 respectively. These are available: [JakobJingleheimer/nodejs-module-config-examples](https://github.com/JakobJingleheimer/nodejs-module-config-examples).
9+
All the provided `package.json` configurations (not specifically marked “does not work”) work in Node.js 12.22.x (v12 latest, the oldest supported line) and 17.2.0 current latest at the time[^1], and for grins, with webpack 5.53.0 and 5.63.0 respectively. These are available: [JakobJingleheimer/nodejs-module-config-examples](https://github.com/JakobJingleheimer/nodejs-module-config-examples).
1010

1111
For curious cats, [How did we get here](#how-did-we-get-here) and [Down the rabbit-hole](#down-the-rabbit-hole) provide background and deeper explanations.
1212

@@ -337,7 +337,7 @@ We're not in Kansas anymore, Toto.
337337

338338
The configurations (there are 2 options) are nearly the same as [ESM source and both CJS & ESM distribution](#esm-source-and-both-cjs-amp-esm-distribution), just exclude `packageJson.exports.import`.
339339

340-
💡 Using [`"type": "module"`][^2] paired with the `.cjs` file extension (for commonjs files) yields best results. For more information on why, see [Down the rabbit-hole](#down-the-rabbit-hole) and [Gotchas](#gotchas) below.
340+
💡 Using `"type": "module"`[^2] paired with the `.cjs` file extension (for commonjs files) yields best results. For more information on why, see [Down the rabbit-hole](#down-the-rabbit-hole) and [Gotchas](#gotchas) below.
341341

342342
**Working example**: [esm-with-cjs-distro](https://github.com/JakobJingleheimer/nodejs-module-config-examples/tree/main/packages/esm/cjs-distro)
343343

@@ -386,7 +386,7 @@ If your files explicitly _all_ use `.cjs` and/or `.mjs` file extensions (none us
386386
}
387387
```
388388

389-
💡 Using [`"type": "module"`][^2] paired with the `.cjs` file extension (for commonjs files) yields best results. For more information on why, see [Down the rabbit-hole](#down-the-rabbit-hole) and [Gotchas](#gotchas) below.
389+
💡 Using `"type": "module"`[^2] paired with the `.cjs` file extension (for commonjs files) yields best results. For more information on why, see [Down the rabbit-hole](#down-the-rabbit-hole) and [Gotchas](#gotchas) below.
390390

391391
#### Publish a CJS distribution with an ESM wrapper
392392

@@ -426,7 +426,7 @@ This is also almost identical to the [CJS source and dual distribution using an
426426
}
427427
```
428428

429-
💡 Using [`"type": "module"`][^2] paired with the `.cjs` file extension (for commonjs files) yields best results. For more information on why, see [Down the rabbit-hole](#down-the-rabbit-hole) and [Gotchas](#gotchas) below.
429+
💡 Using \[`"type": "module"`][^2] paired with the `.cjs` file extension (for commonjs files) yields best results. For more information on why, see [Down the rabbit-hole](#down-the-rabbit-hole) and [Gotchas](#gotchas) below.
430430

431431
#### Publish both full CJS & ESM distributions
432432

@@ -498,7 +498,7 @@ Alternatively, you can use `"default"` and `"node"` keys, which are less counter
498498
}
499499
```
500500

501-
💡 Using [`"type": "module"`][^2] paired with the `.cjs` file extension (for commonjs files) yields best results. For more information on why, see [Down the rabbit-hole](#down-the-rabbit-hole) and [Gotchas](#gotchas) below.
501+
💡 Using `"type": "module"`[^2] paired with the `.cjs` file extension (for commonjs files) yields best results. For more information on why, see [Down the rabbit-hole](#down-the-rabbit-hole) and [Gotchas](#gotchas) below.
502502

503503
##### Use the `.mjs` (or equivalent) file extension for all source code files
504504

apps/site/pages/id/about/security-reporting.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Pemberitahuan keamanan akan didistribusikan melalui metode berikut.
4646

4747
## Komentar tentang kebijakan ini
4848

49-
Jika Anda memiliki saran tentang bagaimana proses ini dapat ditingkatkan, silakan kirimkan [permintaan penarikan](https://github.com/nodejs/nodejs.org) atau [ajukan masalah (https://github.com/nodejs/security -wg/issues/new) untuk didiskusikan.
49+
Jika Anda memiliki saran tentang bagaimana proses ini dapat ditingkatkan, silakan kirimkan [permintaan penarikan](https://github.com/nodejs/nodejs.org) atau [ajukan masalah](https://github.com/nodejs/security-wg/issues/new) untuk didiskusikan.
5050

5151
## Praktik Terbaik OpenSSF
5252

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"**/*.{js,mjs,ts,tsx,md,mdx}": ["prettier --check --write", "eslint --fix"],
3+
"**/*.{json,yml}": ["prettier --check --write"]
4+
}

packages/remark-lint/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# `@node-core/remark-lint`
2+
3+
A [`remark-lint`](https://github.com/remarkjs/remark-lint) plugin with configurations tailored to the documentation and contribution standards of the [Node.js GitHub Organization](https://github.com/nodejs).
4+
5+
## Installation
6+
7+
```bash
8+
npm install --save-dev @node-core/remark-lint
9+
```
10+
11+
## Usage
12+
13+
Add the plugin to your `.remarkrc` or `remark.config.js`:
14+
15+
```json
16+
{
17+
"plugins": ["@node-core/remark-lint"]
18+
}
19+
```
20+
21+
You can then run `remark` over your markdown files:
22+
23+
```bash
24+
npx remark . --frail
25+
```
26+
27+
## Settings
28+
29+
### `NODE_RELEASED_VERSIONS`
30+
31+
Some lint rules (such as `node-core:yaml-comments`) require knowledge of released Node.js versions to validate version references.
32+
33+
You can provide these using the `NODE_RELEASED_VERSIONS` environment variable:
34+
35+
```bash
36+
NODE_RELEASED_VERSIONS=20.12.0,18.19.1,16.20.2 npx remark .
37+
```
38+
39+
If not set, version-related rules will accept any valid SemVer.

packages/remark-lint/eslint.config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import globals from 'globals';
2+
3+
import baseConfig from '../../eslint.config.js';
4+
5+
export default [
6+
...baseConfig,
7+
{
8+
languageOptions: {
9+
globals: globals.nodeBuiltin,
10+
parserOptions: {
11+
// Allow nullish syntax (i.e. "?." or "??"),
12+
// and top-level await
13+
ecmaVersion: 'latest',
14+
},
15+
},
16+
},
17+
];

packages/remark-lint/package.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"name": "@node-core/remark-lint",
3+
"type": "module",
4+
"version": "1.0.0",
5+
"exports": {
6+
".": "./src/index.mjs",
7+
"./api": "./src/api.mjs"
8+
},
9+
"scripts": {
10+
"lint": "node --run lint:js",
11+
"lint:fix": "node --run lint:js:fix",
12+
"lint:js": "eslint \"**/*.mjs\"",
13+
"lint:js:fix": "node --run lint:js -- --fix",
14+
"test": "node --run test:unit",
15+
"test:unit": "cross-env NODE_NO_WARNINGS=1 node --experimental-test-coverage --test \"**/*.test.mjs\""
16+
},
17+
"dependencies": {
18+
"remark-gfm": "~4.0.1",
19+
"remark-lint-blockquote-indentation": "^4.0.1",
20+
"remark-lint-checkbox-character-style": "^5.0.1",
21+
"remark-lint-checkbox-content-indent": "^5.0.1",
22+
"remark-lint-code-block-style": "^4.0.1",
23+
"remark-lint-definition-spacing": "^4.0.1",
24+
"remark-lint-fenced-code-flag": "^4.2.0",
25+
"remark-lint-fenced-code-marker": "^4.0.1",
26+
"remark-lint-final-definition": "^4.0.2",
27+
"remark-lint-heading-style": "^4.0.1",
28+
"remark-lint-maximum-line-length": "^4.1.1",
29+
"remark-lint-no-consecutive-blank-lines": "^5.0.1",
30+
"remark-lint-no-file-name-consecutive-dashes": "^3.0.1",
31+
"remark-lint-no-file-name-outer-dashes": "^3.0.1",
32+
"remark-lint-no-heading-indent": "^5.0.1",
33+
"remark-lint-no-literal-urls": "^4.0.1",
34+
"remark-lint-no-multiple-toplevel-headings": "^4.0.1",
35+
"remark-lint-no-shell-dollars": "^4.0.1",
36+
"remark-lint-no-table-indentation": "^5.0.1",
37+
"remark-lint-no-tabs": "^4.0.1",
38+
"remark-lint-no-trailing-spaces": "^3.0.2",
39+
"remark-lint-no-unused-definitions": "^4.0.2",
40+
"remark-lint-prohibited-strings": "^4.0.0",
41+
"remark-lint-rule-style": "^4.0.1",
42+
"remark-lint-strong-marker": "^4.0.1",
43+
"remark-lint-table-cell-padding": "^5.1.1",
44+
"remark-lint-table-pipes": "^5.0.1",
45+
"remark-lint-unordered-list-marker-style": "^4.0.1",
46+
"remark-preset-lint-recommended": "^7.0.1",
47+
"semver": "~7.7.2",
48+
"unified-lint-rule": "^3.0.1",
49+
"unist-util-visit": "^5.0.0",
50+
"yaml": "^2.8.1"
51+
},
52+
"devDependencies": {
53+
"cross-env": "catalog:",
54+
"dedent": "^1.6.0",
55+
"globals": "^16.3.0",
56+
"remark-parse": "^11.0.0",
57+
"unified": "^11.0.5"
58+
}
59+
}

0 commit comments

Comments
 (0)