Skip to content

Commit a196a48

Browse files
authored
fix: remark-lint, caches and preset-lint-node (#6006)
* fix: remark-lint, caches and preset-lint-node * chore: non persistent
1 parent 57401ec commit a196a48

File tree

11 files changed

+9553
-3143
lines changed

11 files changed

+9553
-3143
lines changed

.github/workflows/lint-and-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ jobs:
8282
node_modules/.cache
8383
.eslintmdcache
8484
.eslintjscache
85+
.stylelintcache
8586
.prettiercache
8687
# We want to restore Turborepo Cache and ESlint and Prettier Cache
8788
# The ESLint and Prettier cache's are useful to reduce the overall runtime of ESLint and Prettier
@@ -146,6 +147,7 @@ jobs:
146147
node_modules/.cache
147148
.eslintmdcache
148149
.eslintjscache
150+
.stylelintcache
149151
.prettiercache
150152
key: cache-lint-${{ hashFiles('package-lock.json') }}-${{ hashFiles('.turbo/cache/**') }}
151153

.gitignore

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ node_modules
33
npm-debug.log
44
.npm
55

6-
# OSX system files, the bane of our existence
7-
.DS_Store
8-
.AppleDouble
9-
.LSOverride
10-
116
# Next.js Build Output
127
.next
138
build
@@ -23,19 +18,18 @@ junit.xml
2318

2419
# Storybook
2520
storybook-static
26-
.nyc_output
2721
build-storybook.log
22+
.nyc_output
2823

2924
# Vercel Files
3025
.vercel
3126
.turbo
3227
cache
3328

34-
# ESlint Cache Files
35-
.eslintmdcache
29+
# Cache Files
3630
.eslintjscache
37-
38-
# Prettier Cache Files
31+
.eslintmdcache
32+
.stylelintcache
3933
.prettiercache
4034

4135
# TypeScript

.prettierignore

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
1+
# Commonly ignored Node.js files
12
node_modules
3+
npm-debug.log
4+
.npm
25

3-
# Next.js & Vercel Directories
6+
# Next.js Build Output
47
.next
5-
.turbo
6-
.swc
78
build
89

9-
# Files that should not be parsed
10-
CODEOWNERS
11-
12-
# Public Files
10+
# Next.js Generated Files
1311
public/static/documents
14-
public/node-releases-data.json
15-
public/blog-posts-data.json
12+
public/sitemap.xml
13+
public/en/feed/*.xml
1614

17-
# We don't want to lint/prettify the Coverage Results
15+
# Jest
1816
coverage
17+
.swc
1918
junit.xml
2019

20+
# Storybook
21+
storybook-static
22+
build-storybook.log
23+
.nyc_output
24+
25+
# Vercel Files
26+
.vercel
27+
.turbo
28+
cache
29+
30+
# Cache Files
31+
.eslintjscache
32+
.eslintmdcache
33+
.stylelintcache
34+
.prettiercache
35+
36+
# TypeScript
37+
tsconfig.tsbuildinfo
38+
39+
# Metadata Files
40+
CODEOWNERS
41+
2142
# Prettier's Handlebar parser is limited and chokes on some syntax features
2243
# https://github.com/prettier/prettier/issues/11834
2344
scripts/release-post/template.hbs
24-
25-
# We shouldn't lint statically generated Storybook files
26-
storybook-static

.remarkrc.json

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

COLLABORATOR_GUIDE.md

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -482,31 +482,6 @@ Defining a `.vscode` configuration like this also aides browser-only development
482482

483483
The npm ecosystem resolution and installation of `peerDependencies` installation [changed in recent versions](https://nodejs.org/en/blog/npm/peer-dependencies#using-peer-dependencies). The project documents what version of `Node.js` and `npm` to use via the [`.nvmrc` file](https://github.com/nodejs/nodejs.org/blob/main/.nvmrc). Not all contributors have tooling to automatically read this file and adhere to the correct version, however. To ensure all contributors install dependencies the same way, a local `.npmrc` file directly configures peerDependency installation behavior.
484484

485-
### Why we don't use [`remark-preset-lint-node`](https://github.com/nodejs/remark-preset-lint-node)?
486-
487-
The Node.js GitHub organisation owns an in-house remark preset (set of rules and plugins) that standardises the contents of Markdown files across the GitHub organisation.
488-
This package uses `remark` plugins such as `remark-gfm`, and it has rules such as forbidden words, maximum line-length of Markdown content, and many very specific rules.
489-
490-
This preset is used within Node.js Development tooling itself (within `make`) and it used as a one-off script to lint the Markdown files within the `nodejs/node` repository.
491-
(The same preset is also used within `nodejs/node` CI).
492-
493-
Whilst that preset has a lot of value, it is not suitable for the Node.js Website. One of the main reasons are that it inheritedly conflicts with `prettier` and with `mdx-js`,
494-
which causes issues from ensuring that Markdown and MDX files are correctly linted, formatted and parsed. Not to mention that these amount of rules, greatly increase the running time of ESLint.
495-
496-
Hence, we decided to not use this preset and instead use a more minimalistic approach to linting Markdown files. Which means that we follow the default recommended `remark-lint`, `mdx-js` and `commonmark`
497-
linting and formatting rules, plus the formatting rules enforced by prettier.
498-
499-
We also decided to not use `remark-gfm` as we want to support the basic CommonMark standard for Markdown files, and the default MDX standard for MDX files.
500-
Having that said, there's one exception, as we use [`autolink-literal`](mdast-util-gfm-autolink-literal) for transforming literal links (text) into anchor elements, which is part of the GitHub Flavoured Markdown specification.
501-
502-
Finally, as the Node.js Website grows, we have thousands of Markdown files, meaning the more rules we add, the more time it takes to lint and format the Markdown files. And the greater the chance is
503-
for the standard adopted on the `nodejs/node` repository to deviate from standard spec-compliant CommonMark. The Node.js Website uses a default recommended configuration that enforces our Markdown files to be spec-compliant.
504-
505-
It's important to mention that this repository is compatible with Markdown files from `nodejs/node` as our formatting is way less strict.
506-
We also have rules in-place (for example in the release blog post generation) that ensure that Markdown files that are "loaded" from `nodejs/node` are compatible when created.
507-
508-
Also note that our goal is to fully support any Markdown file incoming from `nodejs/node` and that originates from the `remark-preset-lint-node`. Our goal is to support our fellow collaborators and to ensure that the Node.js Website is fully compatible with the Node.js project.
509-
510485
## Seeking additional clarification
511486

512487
A lot of the current structure is due to retro-compatibility, keeping a simple and familiar file structure and keeping files that have historical reasons or needs.

0 commit comments

Comments
 (0)