doc, tools: use eslint-plugin-markdown#12563
doc, tools: use eslint-plugin-markdown#12563vsemozhetbyt wants to merge 4 commits intonodejs:masterfrom vsemozhetbyt:eslint-md-no-parsing-errors
Conversation
|
In terms of keeping a clean git commit history, I think it might be better to fix style/syntax in the docs in one commit (without adding directives like |
|
@not-an-aardvark I've reverted |
|
@not-an-aardvark I've checked the whole |
doc/api/dns.md
Outdated
There was a problem hiding this comment.
ESLint parses this as a code block with statements and breaks with parsing errors. With () it is parsed as an expression with an object literal.
There was a problem hiding this comment.
This doesn't feel right to me... If everybody else is okay with this, then fine.
There was a problem hiding this comment.
In some places, I've added something like const defaults = { };, but it seems to me this does not fit everywhere. Maybe, somebody can think up a better approach.
There was a problem hiding this comment.
I think readability should be our main concern in the docs. If a code block which isn't technically valid JS communicates more clearly than the valid-JS alternative, then we should keep using invalid JS and put a disable comment above it. In this case, I don't have a strong opinion on whether the parentheses increase readability.
|
@not-an-aardvark, @thefourtheye
ESLint utput after the second commit: |
|
@not-an-aardvark What are the steps for the proceeding? Are these right?
|
|
Yes, I think those are the right steps. If |
|
@not-an-aardvark What should I add in build configs so that doc are checked in build and CI? |
|
We also should ignore |
|
cc @Trott: I'm not sure about the best place to put |
|
To add this to the build process, I think you would need to replace these lines with: $(NODE) tools/eslint/bin/eslint.js --cache --rulesdir=tools/eslint-rules --ext=.js,.md \
benchmark lib test tools docsIn other words, add To ignore files like |
Dismissing my review for now because a few new commits have been added.
|
Hopefully, make all |
@not-an-aardvark I'm not sure either. If we were starting from scratch, I'd probably say put everything (including eslint itself) in As is, I'm OK with putting |
doc/api/cluster.md
Outdated
There was a problem hiding this comment.
I'd prefer the older more concise style, if possible.
doc/api/console.md
Outdated
There was a problem hiding this comment.
Would
for (let i = 0; i < 100; i++) {}work?
Some people may be unfamiliar with the syntax of an empty statement.
doc/api/crypto.md
Outdated
There was a problem hiding this comment.
4-space indent, and break the string into multiple lines using + if needed.
doc/api/fs.md
Outdated
There was a problem hiding this comment.
You can just remove the language.
doc/api/modules.md
Outdated
There was a problem hiding this comment.
I feel in this case the code block should just be inlined, as
... directly by testing
require.main === module.
doc/api/console.md
Outdated
There was a problem hiding this comment.
This will result in myConsole.assert.name === 'value', which may not be desirable. I'd add an exclusion for func-name-matching.
doc/api/process.md
Outdated
There was a problem hiding this comment.
Ditto about txt language. Or, disabling ESLint for this block and keep js also works for me.
doc/api/readline.md
Outdated
There was a problem hiding this comment.
Can this instead be:
const hits = completions.filter((c) => c.indexOf(line) === 0);
doc/api/zlib.md
Outdated
There was a problem hiding this comment.
The semicolon looks out of place here as well.
doc/api/zlib.md
Outdated
There was a problem hiding this comment.
Ditto. This should be short enough to make it inlined.
|
|
doc/api/stream.md
Outdated
|
@TimothyGu @abouthiroppy Thank you. Comments hopefully addressed. |
doc/api/zlib.md
Outdated
There was a problem hiding this comment.
This empty line can now be removed.
So maybe no need to filter any more files: all Trying to settle build configs... |
|
LGTM. Great work! Thank you, @vsemozhetbyt 🍻 |
|
|
|
Let's start with Linter CI: https://ci.nodejs.org/job/node-test-linter/8451/ |
|
I think this should bake for another release first, but after the next v6.x release comes out @vsemozhetbyt would you be willing to backport to v6.x? Guide is here. If it shouldn't be landed let me know and we can add the |
|
In addition, I am not sure if we should wait for eslint/markdown#69 fixed. |
|
@vsemozhetbyt sounds good, I'll ask again in a month! |
|
Looks like eslint/markdown#69 is really close to landing. Once it does and you're comfortable with it (I guess we need to pull in the fix too) feel free to raise the backport PR. |
The 2 week wait doesn't normally apply to build tools, and I don't think updating the dependency is a particularly dangerous thing to do, so I'd say raise it now if you'd like. |
This is an initial step to eliminate most of parsing errors. Backport-PR-URL: #14067 PR-URL: #12563 Refs: #12557 (comment) Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Backport-PR-URL: #14067 PR-URL: #12563 Refs: #12557 (comment) Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
* Install eslint-plugin-markdown@1.0.0-beta.7 * Add doc/.eslintrc.yaml * Add `plugins: [markdown]` to the main .eslintrc.yaml * .js files in doc folder added to .eslintignore * Update Makefile, vcbuild.bat, and tools/jslint.js Refs: #12563 Refs: #12640 Refs: #14047 PR-URL: #14067 Reviewed-By: James Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
This is an initial step to eliminate most of parsing errors. Backport-PR-URL: #14067 PR-URL: #12563 Refs: #12557 (comment) Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Backport-PR-URL: #14067 PR-URL: #12563 Refs: #12557 (comment) Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
* Install eslint-plugin-markdown@1.0.0-beta.7 * Add doc/.eslintrc.yaml * Add `plugins: [markdown]` to the main .eslintrc.yaml * .js files in doc folder added to .eslintignore * Update Makefile, vcbuild.bat, and tools/jslint.js Refs: #12563 Refs: #12640 Refs: #14047 PR-URL: #14067 Reviewed-By: James Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
This is an initial step to eliminate most of parsing errors. Backport-PR-URL: #14067 PR-URL: #12563 Refs: #12557 (comment) Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Backport-PR-URL: #14067 PR-URL: #12563 Refs: #12557 (comment) Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
* Install eslint-plugin-markdown@1.0.0-beta.7 * Add doc/.eslintrc.yaml * Add `plugins: [markdown]` to the main .eslintrc.yaml * .js files in doc folder added to .eslintignore * Update Makefile, vcbuild.bat, and tools/jslint.js Refs: #12563 Refs: #12640 Refs: #14047 PR-URL: #14067 Reviewed-By: James Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
Checklist
Affected core subsystem(s)
doc, tools
Refs: #12557 (comment)
Commit 1: an initial step to eliminate parsing errors. Fixing strategies:
const defaults =orconst options =wrap in(See doc, tools: use eslint-plugin-markdown #12563 (comment))()repl.md:add(see doc, tools: use eslint-plugin-markdown #12563 (comment))<!-- eslint-disable -->to disable linting + preserve syntax highlighting.``` ```instead of```js ```.Commit 2: conform most of the problematic code to the rules.
Code is checked with this
doc/.eslintrc.yaml(see https://gist.github.com/not-an-aardvark/f3cb021e854414128d197dde8d0f62b2)Commit 3: add eslint-plugin-markdown stuff
npm install eslint-plugin-markdown.doc/.eslintrc.yaml; addplugins: [markdown]to the main.eslintrc.yaml.<!-- eslint-disable rule -->or<!-- eslint-disable -->for the rest problematic code..jsfiles indocfolder added to.eslintignore.Makefileandvcbuild.bat.Commit 4: make doc linting a bit more specific (as we do for tests code)
no-var: 2andprefer-const: 2indoc/.eslintrc.yaml.