Skip to content

Commit

Permalink
tools: add support for meta info in JS snippet linting
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Feb 10, 2021
1 parent e045dda commit 3cc74f8
Show file tree
Hide file tree
Showing 666 changed files with 38,988 additions and 18,456 deletions.
22 changes: 16 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ module.exports = {
overrides: [
{
files: [
'doc/api/esm.md',
'doc/api/module.md',
'doc/api/modules.md',
'doc/api/packages.md',
'doc/api/wasi.md',
'test/es-module/test-esm-type-flag.js',
'test/es-module/test-esm-type-flag-alias.js',
'*.mjs',
Expand All @@ -67,9 +62,24 @@ module.exports = {
},
{
files: ['**/*.md'],
parserOptions: { ecmaFeatures: { impliedStrict: true } },
processor: 'markdown/markdown',
},
{
files: ['**/*.md/*.js:cjs', '**/*.md/*.js'],
parserOptions: {
sourceType: 'script',
ecmaFeatures: { impliedStrict: true }
},
rules: { strict: 'off' },
},
{
files: [
'**/*.md/*.js:esm',
'doc/api/esm.md/*.js',
'doc/api/packages.md/*.js',
],
parserOptions: { sourceType: 'module' },
},
],
rules: {
// ESLint built-in rules
Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ lint-md: lint-js-doc | tools/.mdlintstamp
LINT_JS_TARGETS = .eslintrc.js benchmark doc lib test tools

run-lint-js = tools/node_modules/eslint/bin/eslint.js --cache \
--report-unused-disable-directives --ext=$(EXTENSIONS) $(LINT_JS_TARGETS)
--report-unused-disable-directives $(LINT_JS_TARGETS)
run-lint-js-fix = $(run-lint-js) --fix

.PHONY: lint-js-fix
Expand All @@ -1215,8 +1215,7 @@ lint-js-fix:
.PHONY: lint-js-doc
# Note that on the CI `lint-js-ci` is run instead.
# Lints the JavaScript code with eslint.
lint-js lint-js-fix: EXTENSIONS=.js,.mjs,.md
lint-js-doc: EXTENSIONS=.md
lint-js-doc: LINT_JS_TARGETS=doc
lint-js lint-js-doc:
@if [ "$(shell $(node_use_openssl))" != "true" ]; then \
echo "Skipping $@ (no crypto)"; \
Expand Down
2 changes: 0 additions & 2 deletions doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -2647,7 +2647,6 @@ buf.writeFloatBE(0xcafebabe, 0);

console.log(buf);
// Prints: <Buffer 4f 4a fe bb>

```

### `buf.writeFloatLE(value[, offset])`
Expand Down Expand Up @@ -2856,7 +2855,6 @@ buf.writeIntBE(0x1234567890ab, 0, 6);

console.log(buf);
// Prints: <Buffer 12 34 56 78 90 ab>

```

### `buf.writeIntLE(value, offset, byteLength)`
Expand Down
10 changes: 5 additions & 5 deletions doc/api/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ if a module is maintained by a third party or not.
`module` in this context isn't the same object that's provided
by the [module wrapper][]. To access it, require the `Module` module:

```js
```js esm
// module.mjs
// In an ECMAScript module
import { builtinModules as builtin } from 'module';
```

```js
```js cjs
// module.cjs
// In a CommonJS module
const builtin = require('module').builtinModules;
Expand All @@ -51,7 +51,7 @@ added: v12.2.0
string.
* Returns: {require} Require function

```js
```js esm
import { createRequire } from 'module';
const require = createRequire(import.meta.url);

Expand Down Expand Up @@ -134,13 +134,13 @@ To enable source map parsing, Node.js must be run with the flag
[`--enable-source-maps`][], or with code coverage enabled by setting
[`NODE_V8_COVERAGE=dir`][].
```js
```js esm
// module.mjs
// In an ECMAScript module
import { findSourceMap, SourceMap } from 'module';
```
```js
```js cjs
// module.cjs
// In a CommonJS module
const { findSourceMap, SourceMap } = require('module');
Expand Down
1 change: 0 additions & 1 deletion doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -2055,7 +2055,6 @@ const myWritable = new Writable({
});
// Later, abort the operation closing the stream
controller.abort();

```
#### `writable._construct(callback)`
<!-- YAML
Expand Down
2 changes: 1 addition & 1 deletion doc/api/wasi.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The WASI API provides an implementation of the [WebAssembly System Interface][]
specification. WASI gives sandboxed WebAssembly applications access to the
underlying operating system via a collection of POSIX-like functions.

```js
```js esm
import fs from 'fs';
import { WASI } from 'wasi';

Expand Down
1 change: 0 additions & 1 deletion doc/guides/writing-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ const server = http.createServer(common.mustCall((req, res) => {
server.close();
}));
}));

```

**Note:** Many functions invoke their callback with an `err` value as the first
Expand Down
97 changes: 97 additions & 0 deletions tools/node_modules/eslint-plugin-markdown/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3cc74f8

Please sign in to comment.