GeezerVison is showing github.com — tools: add support for mjs and cjs JS snippet linting · nodejs/node@07fc61b
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .eslintrc.js +13-8Lines changed: 13 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -53,12 +53,6 @@ module.exports = { | 53 | 53 | overrides: [ | 54 | 54 | { | 55 | 55 | files: [ | 56 | | - 'doc/api/esm.md/*.js', | 57 | | - 'doc/api/fs.md/*.js', | 58 | | - 'doc/api/module.md/*.js', | 59 | | - 'doc/api/modules.md/*.js', | 60 | | - 'doc/api/packages.md/*.js', | 61 | | - 'doc/api/wasi.md/*.js', | 62 | 56 | 'test/es-module/test-esm-type-flag.js', | 63 | 57 | 'test/es-module/test-esm-type-flag-alias.js', | 64 | 58 | '*.mjs', | @@ -71,10 +65,21 @@ module.exports = { | 71 | 65 | processor: 'markdown/markdown', | 72 | 66 | }, | 73 | 67 | { | 74 | | - files: ['**/*.md/*.js'], | 75 | | - parserOptions: { ecmaFeatures: { impliedStrict: true } }, | | 68 | + files: ['**/*.md/*.cjs', '**/*.md/*.js'], | | 69 | + parserOptions: { | | 70 | + sourceType: 'script', | | 71 | + ecmaFeatures: { impliedStrict: true } | | 72 | + }, | 76 | 73 | rules: { strict: 'off' }, | 77 | 74 | }, | | 75 | + { | | 76 | + files: [ | | 77 | + '**/*.md/*.mjs', | | 78 | + 'doc/api/esm.md/*.js', | | 79 | + 'doc/api/packages.md/*.js', | | 80 | + ], | | 81 | + parserOptions: { sourceType: 'module' }, | | 82 | + }, | 78 | 83 | ], | 79 | 84 | rules: { | 80 | 85 | // ESLint built-in rules | |
Collapse file Copy file name to clipboardExpand all lines: Makefile +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1220,6 +1220,7 @@ lint-js-fix: | 1220 | 1220 | .PHONY: lint-js-doc | 1221 | 1221 | # Note that on the CI `lint-js-ci` is run instead. | 1222 | 1222 | # Lints the JavaScript code with eslint. | | 1223 | +lint-js-doc: LINT_JS_TARGETS=doc | 1223 | 1224 | lint-js lint-js-doc: | 1224 | 1225 | @if [ "$(shell $(node_use_openssl))" != "true" ]; then \ | 1225 | 1226 | echo "Skipping $@ (no crypto)"; \ | |
Collapse file Copy file name to clipboardExpand all lines: doc/api/buffer.md -2Lines changed: 0 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2647,7 +2647,6 @@ buf.writeFloatBE(0xcafebabe, 0); | 2647 | 2647 |
| 2648 | 2648 | console.log(buf); | 2649 | 2649 | // Prints: <Buffer 4f 4a fe bb> | 2650 | | - | 2651 | 2650 | ``` | 2652 | 2651 |
| 2653 | 2652 | ### `buf.writeFloatLE(value[, offset])` | @@ -2856,7 +2855,6 @@ buf.writeIntBE(0x1234567890ab, 0, 6); | 2856 | 2855 |
| 2857 | 2856 | console.log(buf); | 2858 | 2857 | // Prints: <Buffer 12 34 56 78 90 ab> | 2859 | | - | 2860 | 2858 | ``` | 2861 | 2859 |
| 2862 | 2860 | ### `buf.writeIntLE(value, offset, byteLength)` | |
Collapse file Copy file name to clipboardExpand all lines: doc/api/module.md +5-5Lines changed: 5 additions & 5 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -29,13 +29,13 @@ if a module is maintained by a third party or not. | 29 | 29 | `module` in this context isn't the same object that's provided | 30 | 30 | by the [module wrapper][]. To access it, require the `Module` module: | 31 | 31 |
| 32 | | -```js | | 32 | +```mjs | 33 | 33 | // module.mjs | 34 | 34 | // In an ECMAScript module | 35 | 35 | import { builtinModules as builtin } from 'module'; | 36 | 36 | ``` | 37 | 37 |
| 38 | | -```js | | 38 | +```cjs | 39 | 39 | // module.cjs | 40 | 40 | // In a CommonJS module | 41 | 41 | const builtin = require('module').builtinModules; | @@ -51,7 +51,7 @@ added: v12.2.0 | 51 | 51 | string. | 52 | 52 | * Returns: {require} Require function | 53 | 53 |
| 54 | | -```js | | 54 | +```mjs | 55 | 55 | import { createRequire } from 'module'; | 56 | 56 | const require = createRequire(import.meta.url); | 57 | 57 |
| @@ -134,13 +134,13 @@ To enable source map parsing, Node.js must be run with the flag | 134 | 134 | [`--enable-source-maps`][], or with code coverage enabled by setting | 135 | 135 | [`NODE_V8_COVERAGE=dir`][]. | 136 | 136 |
| 137 | | -```js | | 137 | +```mjs | 138 | 138 | // module.mjs | 139 | 139 | // In an ECMAScript module | 140 | 140 | import { findSourceMap, SourceMap } from 'module'; | 141 | 141 | ``` | 142 | 142 |
| 143 | | -```js | | 143 | +```cjs | 144 | 144 | // module.cjs | 145 | 145 | // In a CommonJS module | 146 | 146 | const { findSourceMap, SourceMap } = require('module'); | |
Collapse file Copy file name to clipboardExpand all lines: doc/api/stream.md -1Lines changed: 0 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2090,7 +2090,6 @@ const myWritable = new Writable({ | 2090 | 2090 | }); | 2091 | 2091 | // Later, abort the operation closing the stream | 2092 | 2092 | controller.abort(); | 2093 | | - | 2094 | 2093 | ``` | 2095 | 2094 | #### `writable._construct(callback)` | 2096 | 2095 | <!-- YAML | |
Collapse file Copy file name to clipboardExpand all lines: doc/api/wasi.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -10,7 +10,7 @@ The WASI API provides an implementation of the [WebAssembly System Interface][] | 10 | 10 | specification. WASI gives sandboxed WebAssembly applications access to the | 11 | 11 | underlying operating system via a collection of POSIX-like functions. | 12 | 12 |
| 13 | | -```js | | 13 | +```mjs | 14 | 14 | import fs from 'fs'; | 15 | 15 | import { WASI } from 'wasi'; | 16 | 16 |
| |
Collapse file Copy file name to clipboardExpand all lines: doc/guides/writing-tests.md -1Lines changed: 0 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -221,7 +221,6 @@ const server = http.createServer(common.mustCall((req, res) => { | 221 | 221 | server.close(); | 222 | 222 | })); | 223 | 223 | })); | 224 | | - | 225 | 224 | ``` | 226 | 225 |
| 227 | 226 | **Note:** Many functions invoke their callback with an `err` value as the first | |
|