Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add markdownlint #1597

Merged
merged 6 commits into from Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions .markdownlint.json
@@ -0,0 +1,8 @@
{
"line-length": false,
"no-duplicate-heading": false,
"no-hard-tabs": false,
"ul-style": {
"style": "dash"
}
}
2 changes: 2 additions & 0 deletions .markdownlintignore
@@ -0,0 +1,2 @@
node_modules
test/snapshots
2 changes: 0 additions & 2 deletions docs/rules/consistent-function-scoping.md
Expand Up @@ -4,7 +4,6 @@

A function definition should be placed as close to the top-level scope as possible without breaking its captured values. This improves readability, [directly improves performance](https://stackoverflow.com/a/81329/207247) and allows JavaScript engines to [better optimize performance](https://ponyfoo.com/articles/javascript-performance-pitfalls-v8#optimization-limit).


## Fail

```js
Expand All @@ -24,7 +23,6 @@ function doFoo(foo) {
}
```


## Pass

```js
Expand Down
7 changes: 0 additions & 7 deletions docs/rules/custom-error-definition.md
Expand Up @@ -6,7 +6,6 @@

Enforces the only valid way of `Error` subclassing. It works with any super class that ends in `Error`.


## Fail

```js
Expand All @@ -21,7 +20,6 @@ class CustomError extends Error {

The `this.message` assignment is useless as it's already set via the `super()` call.


```js
class CustomError extends Error {
constructor(message) {
Expand All @@ -34,7 +32,6 @@ class CustomError extends Error {

Pass the error message to `super()` instead of setting `this.message`.


```js
class CustomError extends Error {
constructor(message) {
Expand All @@ -45,7 +42,6 @@ class CustomError extends Error {

No `name` property set. The name property is needed so the error shows up as `[CustomError: foo]` and not `[Error: foo]`.


```js
class CustomError extends Error {
constructor(message) {
Expand All @@ -57,7 +53,6 @@ class CustomError extends Error {

Use a string literal to set the `name` property as it will not change after minifying.


```js
class CustomError extends Error {
constructor(message) {
Expand All @@ -69,7 +64,6 @@ class CustomError extends Error {

The `name` property should be set to the class name.


```js
class foo extends Error {
constructor(message) {
Expand All @@ -81,7 +75,6 @@ class foo extends Error {

The class name is invalid. It should be capitalized and end with `Error`. In this case it should be `FooError`.


## Pass

```js
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/error-message.md
Expand Up @@ -4,7 +4,6 @@

This rule enforces a `message` value to be passed in when creating an instance of a built-in [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object, which leads to more readable and debuggable code.


## Fail

```js
Expand All @@ -23,7 +22,6 @@ throw new TypeError();
const error = new AggregateError(errors);
```


## Pass

```js
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/escape-case.md
Expand Up @@ -6,7 +6,6 @@

Enforces defining escape sequence values with uppercase characters rather than lowercase ones. This promotes readability by making the escaped value more distinguishable from the identifier.


## Fail

```js
Expand All @@ -16,7 +15,6 @@ const foo = '\u{1d306}';
const foo = '\ca';
```


## Pass

```js
Expand Down
4 changes: 2 additions & 2 deletions docs/rules/explicit-length-check.md
Expand Up @@ -156,9 +156,9 @@ You can define your preferred way of checking non-zero length by providing a `no
The `non-zero` option can be configured with one of the following:

- `greater-than` (default)
- Enforces non-zero to be checked with: `foo.length > 0`
- Enforces non-zero to be checked with: `foo.length > 0`
- `not-equal`
- Enforces non-zero to be checked with: `foo.length !== 0`
- Enforces non-zero to be checked with: `foo.length !== 0`

## Unsafe to fix case

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/filename-case.md
Expand Up @@ -8,6 +8,8 @@ Files named `index.js`, `index.mjs`, `index.cjs`, `index.ts`, `index.tsx`, `inde

Characters in the filename except `a-z`, `A-Z`, `0-9`, `-`, `_` and `$` are ignored.

## Cases

### `kebabCase`

- `foo-bar.js`
Expand All @@ -32,7 +34,6 @@ Characters in the filename except `a-z`, `A-Z`, `0-9`, `-`, `_` and `$` are igno
- `FooBar.Test.js`
- `FooBar.TestUtils.js`


## Options

### case
Expand Down Expand Up @@ -80,6 +81,7 @@ When a string is given, it's interpreted as a regular expressions inside a strin
Sometimes you may have non-standard filenames in a project. This option lets you ignore those files.

For example:

- Vendor packages that are not published and was copy-pasted.
- Ignore some files when you use [eslint-plugin-markdown](https://github.com/eslint/eslint-plugin-markdown), for example `README.md`.
- Some tools may require special names for some files.
Expand Down
3 changes: 0 additions & 3 deletions docs/rules/import-index.md
Expand Up @@ -6,7 +6,6 @@

Enforces importing index file with `.` instead of `./`, `./index` or `./index.js`.


## Fail

```js
Expand Down Expand Up @@ -41,7 +40,6 @@ import m from './';
import m from './index';
```


## Pass

```js
Expand All @@ -64,7 +62,6 @@ const m = require('@foo/bar');
import m from '.';
```


## Options

### ignoreImports
Expand Down
3 changes: 3 additions & 0 deletions docs/rules/import-style.md
Expand Up @@ -5,6 +5,7 @@
Sometimes a module contains unrelated functions, like `util`, thus it is a good practice to enforce destructuring or named imports here. Other times, in modules like `path`, it is good to use default import as they have similar functions, all likely to be utilized.

This rule defines 4 import styles:

- `unassigned` - `import 'foo'` or `require('foo')`
- `default` - `import path from 'path'` or `const path = require('path')`
- `namespace` - `import * as path from 'path'` or `const path = require('path')`
Expand Down Expand Up @@ -37,11 +38,13 @@ Type: `object`
You can extend default import styles per module by passing the `styles` option.

Default options per module are:

- `util` - `named` only
- `path` - `default` only
- `chalk` - `default` only

The example below:

- Disables any restrictions on the `util` module imports.
- Allows `named` import (leaving `default` allowed too) from the `path` module (by default only `default` import of `path` is allowed).

Expand Down
2 changes: 0 additions & 2 deletions docs/rules/no-abusive-eslint-disable.md
Expand Up @@ -33,7 +33,6 @@ console.log(message); // `message` is not defined, but it won't be reported

This rule enforces specifying the rules to disable. If you want to disable ESLint on a file altogether, you should ignore it through [`.eslintignore`](https://eslint.org/docs/user-guide/configuring#ignoring-files-and-directories) for ESLint or through the [`ignores` property](https://github.com/xojs/xo#ignores) in `package.json` for `XO`.


## Fail

```js
Expand All @@ -46,7 +45,6 @@ console.log(message); // eslint-disable-line
console.log(message);
```


## Pass

```js
Expand Down
1 change: 1 addition & 0 deletions docs/rules/no-array-reduce.md
Expand Up @@ -54,6 +54,7 @@ for (const element of array) {
result += element;
}
```

## Options

### allowSimpleOperations
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/no-console-spaces.md
Expand Up @@ -6,7 +6,6 @@

The [`console.log()` method](https://developer.mozilla.org/en-US/docs/Web/API/Console/log) and similar methods joins the parameters with a space, so adding a leading/trailing space to a parameter, results in two spaces being added.


## Fail

```js
Expand All @@ -22,7 +21,6 @@ console.warn('abc ', 'def');
console.error('abc ', 'def');
```


## Pass

```js
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/no-for-loop.md
Expand Up @@ -10,7 +10,6 @@ Off-by-one errors are one of the most common bugs in software. [Swift actually r

This rule is fixable unless index or element variables were used outside of the loop.


## Fail

```js
Expand All @@ -20,7 +19,6 @@ for (let index = 0; index < array.length; index++) {
}
```


## Pass

```js
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/no-hex-escape.md
Expand Up @@ -6,15 +6,13 @@

Enforces a convention of using [Unicode escapes](https://mathiasbynens.be/notes/javascript-escapes#unicode) instead of [hexadecimal escapes](https://mathiasbynens.be/notes/javascript-escapes#hexadecimal) for consistency and clarity.


## Fail

```js
const foo = '\x1B';
const foo = `\x1B${bar}`;
```


## Pass

```js
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/no-instanceof-array.md
Expand Up @@ -6,15 +6,13 @@

The `instanceof Array` check doesn't work across realms/contexts, for example, frames/windows in browsers or the `vm` module in Node.js.


## Fail

```js
array instanceof Array;
[1,2,3] instanceof Array;
```


## Pass

```js
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/no-keyword-prefix.md
Expand Up @@ -11,7 +11,6 @@ const newFoo = 'foo';
const classFoo = 'foo';
```


## Pass

```js
Expand All @@ -21,7 +20,6 @@ const new_foo = 'foo';
const fooNew = 'foo';
```


## Options

### `disallowedPrefixes`
Expand Down
4 changes: 0 additions & 4 deletions docs/rules/no-nested-ternary.md
Expand Up @@ -6,23 +6,20 @@

Improved version of the [`no-nested-ternary`](https://eslint.org/docs/rules/no-nested-ternary) ESLint rule, which allows cases where the nested ternary is only one level and wrapped in parens.


## Fail

```js
const foo = i > 5 ? i < 100 ? true : false : true;
const foo = i > 5 ? true : (i < 100 ? true : (i < 1000 ? true : false));
```


## Pass

```js
const foo = i > 5 ? (i < 100 ? true : false) : true;
const foo = i > 5 ? (i < 100 ? true : false) : (i < 100 ? true : false);
```


## Partly fixable

This rule is only fixable when the nesting is up to one level. The rule will wrap the nested ternary in parens:
Expand All @@ -37,7 +34,6 @@ will get fixed to
const foo = i > 5 ? (i < 100 ? true : false) : true
```


## Disabling ESLint `no-nested-ternary`

We recommend disabling the ESLint `no-nested-ternary` rule in favor of this one:
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-new-buffer.md
Expand Up @@ -12,7 +12,7 @@ Enforces the use of [Buffer.from](https://nodejs.org/api/buffer.html#buffer_clas
const buffer = new Buffer('7468697320697320612074c3a97374', 'hex');
```

```
```js
const buffer = new Buffer([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
```

Expand Down
1 change: 0 additions & 1 deletion docs/rules/no-object-as-default-parameter.md
Expand Up @@ -18,7 +18,6 @@ function foo({a} = {a: false}) {}
const abc = (foo = {a: false, b: 123}) => {};
```


## Pass

```js
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/no-process-exit.md
Expand Up @@ -4,14 +4,12 @@

This rule is an extension to ESLint's [`no-process-exit` rule](https://eslint.org/docs/rules/no-process-exit), that allows `process.exit()` to be called in files that start with a [hashbang](https://en.wikipedia.org/wiki/Shebang_(Unix))`#!/usr/bin/env node`. It also allows `process.exit()` to be called in `process.on('<event>', func)` event handlers and in files that imports `worker_threads`.


## Fail

```js
process.exit(0);
```


## Pass

```js
Expand Down
1 change: 0 additions & 1 deletion docs/rules/no-unreadable-array-destructuring.md
Expand Up @@ -24,7 +24,6 @@ const [,,,, foo] = parts;
const [,,...rest] = parts;
```


## Pass

```js
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/no-unsafe-regex.md
Expand Up @@ -4,7 +4,6 @@

Uses [safe-regex](https://github.com/substack/safe-regex) to disallow potentially [catastrophic](https://regular-expressions.mobi/catastrophic.html) [exponential-time](https://perlgeek.de/blog-en/perl-tips/in-search-of-an-exponetial-regexp.html) regular expressions.


## Fail

```js
Expand All @@ -17,7 +16,6 @@ const regex = /(a+){2}y/;
const regex = /(.*){1,32000}[bc]/;
```


## Pass

```js
Expand Down