Skip to content

Commit 795fd1c

Browse files
authored
chore: add markdownlint (typescript-eslint#1889)
1 parent 7021f21 commit 795fd1c

15 files changed

+259
-32
lines changed

.github/workflows/ci.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,13 @@ jobs:
9393
- name: Check code formatting
9494
run: yarn format-check
9595

96-
- name: Run linting
96+
- name: Lint code
9797
run: yarn lint
9898

99-
- name: Validate spelling
99+
- name: Lint markdown
100+
run: yarn lint:markdown
101+
102+
- name: Check spelling
100103
run: yarn check:spelling
101104

102105
integration_tests:

.markdownlint.json

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
{
2+
"default": false,
3+
4+
// MD001/heading-increment/header-increment - Heading levels should only increment by one level at a time
5+
"MD001": true,
6+
// MD002/first-heading-h1/first-header-h1 - First heading should be a top level heading
7+
"MD002": false,
8+
// MD003/heading-style/header-style - Heading style
9+
"MD003": false,
10+
// MD004/ul-style - Unordered list style
11+
"MD004": false,
12+
// MD005/list-indent - Inconsistent indentation for list items at the same level
13+
"MD005": false,
14+
// MD006/ul-start-left - Consider starting bulleted lists at the beginning of the line
15+
"MD006": false,
16+
// MD007/ul-indent - Unordered list indentation
17+
"MD007": false,
18+
// MD009/no-trailing-spaces - Trailing spaces
19+
"MD009": false,
20+
// MD010/no-hard-tabs - Hard tabs
21+
"MD010": false,
22+
// MD011/no-reversed-links - Reversed link syntax
23+
"MD011": true,
24+
// MD012/no-multiple-blanks - Multiple consecutive blank lines
25+
"MD012": false,
26+
// MD013/line-length - Line length
27+
"MD013": { "line_length": 99999 }, // no line length
28+
// MD014/commands-show-output - Dollar signs used before commands without showing output
29+
"MD014": false,
30+
// MD018/no-missing-space-atx - No space after hash on atx style heading
31+
"MD018": true,
32+
// MD019/no-multiple-space-atx - Multiple spaces after hash on atx style heading
33+
"MD019": false,
34+
// MD020/no-missing-space-closed-atx - No space inside hashes on closed atx style heading
35+
"MD020": false,
36+
// MD021/no-multiple-space-closed-atx - Multiple spaces inside hashes on closed atx style heading
37+
"MD021": false,
38+
// MD022/blanks-around-headings/blanks-around-headers - Headings should be surrounded by blank lines
39+
"MD022": true,
40+
// MD023/heading-start-left/header-start-left - Headings must start at the beginning of the line
41+
"MD023": false,
42+
// MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the same content
43+
"MD024": false,
44+
// MD025/single-title/single-h1 - Multiple top level headings in the same document
45+
"MD025": true,
46+
// MD026/no-trailing-punctuation - Trailing punctuation in heading
47+
"MD026": { "punctuation": ".,;:!。,;:!?" }, // specifically allow "?"
48+
// MD027/no-multiple-space-blockquote - Multiple spaces after blockquote symbol
49+
"MD027": false,
50+
// MD028/no-blanks-blockquote - Blank line inside blockquote
51+
"MD028": true,
52+
// MD029/ol-prefix - Ordered list item prefix
53+
"MD029": false,
54+
// MD030/list-marker-space - Spaces after list markers
55+
"MD030": true,
56+
// MD031/blanks-around-fences - Fenced code blocks should be surrounded by blank lines
57+
"MD031": false,
58+
// MD032/blanks-around-lists - Lists should be surrounded by blank lines
59+
"MD032": false,
60+
// MD033/no-inline-html - Inline HTML
61+
"MD033": { "allowed_elements": ["a", "img", "br", "sup", "h1", "p"] },
62+
// MD034/no-bare-urls - Bare URL used
63+
"MD034": false,
64+
// MD035/hr-style - Horizontal rule style
65+
"MD035": false,
66+
// MD036/no-emphasis-as-heading/no-emphasis-as-header - Emphasis used instead of a heading
67+
"MD036": true,
68+
// MD037/no-space-in-emphasis - Spaces inside emphasis markers
69+
"MD037": true,
70+
// MD038/no-space-in-code - Spaces inside code span elements
71+
"MD038": true,
72+
// MD039/no-space-in-links - Spaces inside link text
73+
"MD039": true,
74+
// MD040/fenced-code-language - Fenced code blocks should have a language specified
75+
"MD040": true,
76+
// MD041/first-line-heading/first-line-h1 - First line in file should be a top level heading
77+
"MD041": false, // would love to do this, but our README files use `<h1 center>` as their heading
78+
// MD042/no-empty-links - No empty links
79+
"MD042": true,
80+
// MD043/required-headings/required-headers - Required heading structure
81+
"MD043": false,
82+
// MD044/proper-names - Proper names should have the correct capitalization
83+
"MD044": {
84+
"names": ["JavaScript", "TypeScript", "TSLint", "ESLint"],
85+
"code_blocks": false
86+
},
87+
// MD045/no-alt-text - Images should have alternate text (alt text)
88+
"MD045": true,
89+
// MD046/code-block-style - Code block style
90+
"MD046": { "style": "fenced" },
91+
// MD047/single-trailing-newline - Files should end with a single newline character
92+
"MD047": false,
93+
// MD048/code-fence-style - Code fence style
94+
"MD048": { "style": "backtick" }
95+
}

.markdownlintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
CHANGELOG.md
3+
tests/integration/fixtures/markdown

.vscode/extensions.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"esbenp.prettier-vscode",
44
"dbaeumer.vscode-eslint",
55
"editorconfig.editorconfig",
6-
"streetsidesoftware.code-spell-checker"
6+
"streetsidesoftware.code-spell-checker",
7+
"davidanson.vscode-markdownlint"
78
],
89
"unwantedRecommendations": ["hookyqr.beautify", "dbaeumer.jshint"]
910
}

.vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
"typescript.preferences.importModuleSpecifier": "auto",
1818
"javascript.preferences.quoteStyle": "single",
1919
"typescript.preferences.quoteStyle": "single",
20-
"editor.defaultFormatter": "esbenp.prettier-vscode"
20+
"editor.defaultFormatter": "esbenp.prettier-vscode",
2121
}

CONTRIBUTING.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ We have a sophisticated CI process setup which gets run on every PR. You must pa
5050
- Coverage reports should automatically be generated locally, and the `codecov` bot should also comment on your PR with the percentage, as well as links to the line-by-line coverage of each file touched by your PR.
5151
- Ensure you have no lint errors.
5252
- You can run `yarn lint` in any package or in the root.
53+
- You can run `yarn lint:markdown` in the root.
5354
- If you have made changes to any markdown documentation, ensure there are no spelling errors
5455
- You can run `yarn check:spelling` in the root.
5556
- Or if you are using vscode, you can use [`Code Spell Checker`](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) plugin.
@@ -60,7 +61,7 @@ We have a sophisticated CI process setup which gets run on every PR. You must pa
6061

6162
Once your changes are ready, you can raise a PR. The title of your PR should match the following format:
6263

63-
```
64+
```text
6465
<tag>(<package>): <short description>
6566
```
6667

docs/getting-started/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ The goal of these docs are to give you a quick overview of the project and all o
66

77
The docs are broken down into the following categories:
88

9-
### [I want to lint my TypeScript codebase.](./linting/README.md)
9+
## [I want to lint my TypeScript codebase.](./linting/README.md)
1010

11-
### [(TODO) I want to write an ESLint plugin in TypeScript.](./plugin-development/README.md)
11+
## [(TODO) I want to write an ESLint plugin in TypeScript.](./plugin-development/README.md)

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
"kill-integration-test-containers": "docker-compose -f tests/integration/docker-compose.yml down -v --rmi local",
3131
"lint": "eslint . --ext .js,.ts",
3232
"lint-fix": "eslint . --ext .js,.ts --fix",
33+
"lint:markdown": "markdownlint '**/*.md' --config=.markdownlint.json --ignore-path=.markdownlintignore",
34+
"lint:markdown:fix": "lint:markdown --fix",
3335
"pre-commit": "yarn lint-staged",
3436
"pre-push": "yarn format-check",
3537
"postinstall": "lerna bootstrap && yarn build && lerna link",
@@ -70,6 +72,7 @@
7072
"jest": "^25.1.0",
7173
"lerna": "^3.20.2",
7274
"lint-staged": "^9.4.3",
75+
"markdownlint-cli": "^0.22.0",
7376
"prettier": "^1.19.1",
7477
"ts-jest": "^25.0.0",
7578
"ts-node": "^8.5.0",

packages/eslint-plugin/ROADMAP.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ It lists all TSLint rules along side rules from the ESLint ecosystem that are th
202202
<sup>[1]</sup> Recommended config: `["error", { blankLine: "always", prev: "*", next: "return" }]`<br>
203203
<sup>[2]</sup> Doesn't check other control flow statements, such as `break` or `continue`.
204204

205-
## tslint-microsoft-contrib rules
205+
## `tslint-microsoft-contrib` rules
206206

207207
Rule listing is [here](https://github.com/Microsoft/tslint-microsoft-contrib#supported-rules).
208208
Deprecated rules are excluded (`missing-jsdoc`, `missing-optional-annotation`, `no-duplicate-case`, `no-duplicate-parameter-names`, `no-function-constructor-with-string-args`, `no-increment-decrement`, `no-empty-interfaces`, `no-missing-visibility-modifiers`, `no-multiple-var-decl`, `no-reserved-keywords`, `no-stateless-class`, `no-var-self`, `no-unnecessary-bind`, and `valid-typeof`). See the docs in the link above to find out what to use instead.
@@ -211,7 +211,7 @@ Deprecated rules are excluded (`missing-jsdoc`, `missing-optional-annotation`, `
211211

212212
Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint-plugin-chai-expect-keywords), [`chai-expect`](https://github.com/Turbo87/eslint-plugin-chai-expect), [`chai-friendly`](https://github.com/ihordiachenko/eslint-plugin-chai-friendly), [`mocha`](https://github.com/lo1tuma/eslint-plugin-mocha), and [`jest`](https://github.com/jest-community/eslint-plugin-jest)
213213

214-
| tslint-microsoft-contrib rule | | ESLint rule |
214+
| `tslint-microsoft-contrib` rule | | ESLint rule |
215215
| ---------------------------------- | :-: | ------------------------- |
216216
| `chai-prefer-contains-to-index-of` | 🛑 | N/A |
217217
| `chai-vague-errors` | 🛑 | N/A |
@@ -220,16 +220,16 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint-
220220

221221
### TypeScript
222222

223-
| tslint-microsoft-contrib rule | | ESLint rule |
224-
| ----------------------------- | :-: | ---------------------------------------------------------- |
225-
| `prefer-array-literal` | 🌓 | [`@typescript-eslint/no-array-constructor`] <sup>[1]</sup> |
226-
| `prefer-type-cast` | 🛑 | N/A |
223+
| `tslint-microsoft-contrib` rule | | ESLint rule |
224+
| ------------------------------- | :-: | ---------------------------------------------------------- |
225+
| `prefer-array-literal` | 🌓 | [`@typescript-eslint/no-array-constructor`] <sup>[1]</sup> |
226+
| `prefer-type-cast` | 🛑 | N/A |
227227

228228
<sup>[1]</sup> ESLint rule is slightly less strict, allowing `new Array<Foo>()` and `Array(2)`.
229229

230230
### Miscellaneous
231231

232-
| tslint-microsoft-contrib rule | | ESLint rule |
232+
| `tslint-microsoft-contrib` rule | | ESLint rule |
233233
| ------------------------------------- | :-: | ---------------------------------------------------------------------- |
234234
| `export-name` | 🛑 | N/A ([relevant plugin][plugin:import]) |
235235
| `function-name` | 🛑 | N/A |
@@ -274,7 +274,7 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint-
274274

275275
### Security
276276

277-
| tslint-microsoft-contrib rule | | ESLint rule |
277+
| `tslint-microsoft-contrib` rule | | ESLint rule |
278278
| ------------------------------- | :-: | -------------------------------------------------- |
279279
| `no-disable-auto-sanitization` | 🛑 | N/A |
280280
| `no-document-domain` | 🌓 | Use [`no-restricted-syntax`][no-restricted-syntax] |
@@ -291,7 +291,7 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint-
291291

292292
### Browser
293293

294-
| tslint-microsoft-contrib rule | | ESLint rule |
294+
| `tslint-microsoft-contrib` rule | | ESLint rule |
295295
| ----------------------------------- | :-: | -------------------------------------------------- |
296296
| `jquery-deferred-must-complete` | 🛑 | N/A |
297297
| `no-backbone-get-set-outside-model` | 🛑 | N/A |
@@ -306,7 +306,7 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint-
306306

307307
### React A11y
308308

309-
| tslint-microsoft-contrib rule | | ESLint rule |
309+
| `tslint-microsoft-contrib` rule | | ESLint rule |
310310
| ----------------------------------------- | :-: | ---------------------------------------------------------- |
311311
| `react-a11y-accessible-headings` | 🌓 | [`jsx-a11y/heading-has-content`] <sup>[1]</sup> |
312312
| `react-a11y-anchors` | 🔌 | [`jsx-a11y/anchor-is-valid`] |

packages/eslint-plugin/docs/rules/ban-ts-comment.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Using these to suppress TypeScript Compiler Errors reduces the effectiveness of
55

66
The directive comments supported by TypeScript are:
77

8-
```
8+
```ts
99
// @ts-expect-error
1010
// @ts-ignore
1111
// @ts-nocheck
@@ -19,7 +19,7 @@ By default, only `@ts-check` is allowed, as it enables rather than suppresses er
1919

2020
The configuration looks like this:
2121

22-
```
22+
```ts
2323
interface Options {
2424
'ts-expect-error'?: boolean;
2525
'ts-ignore'?: boolean;
@@ -31,8 +31,8 @@ const defaultOptions: Options = {
3131
'ts-expect-error': true,
3232
'ts-ignore': true,
3333
'ts-nocheck': true,
34-
'ts-check': false
35-
}
34+
'ts-check': false,
35+
};
3636
```
3737

3838
A value of `true` for a particular directive means that this rule will report if it finds any usage of said directive.

packages/eslint-plugin/docs/rules/class-literal-property-style.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Ensures that literals on classes are exposed in a consistent style (`class-literal-property-style`)
22

33
When writing TypeScript applications, it's typically safe to store literal values on classes using fields with the `readonly` modifier to prevent them from being reassigned.
4-
When writing TypeScript libraries that could be used by Javascript users however, it's typically safer to expose these literals using `getter`s, since the `readonly` modifier is enforced at compile type.
4+
When writing TypeScript libraries that could be used by JavaScript users however, it's typically safer to expose these literals using `getter`s, since the `readonly` modifier is enforced at compile type.
55

66
## Rule Details
77

@@ -11,7 +11,7 @@ By default this rule prefers the `fields` style as it means JS doesn't have to s
1111
Note that this rule only checks for constant _literal_ values (string, template string, number, bigint, boolean, regexp, null). It does not check objects or arrays, because a readonly field behaves differently to a getter in those cases. It also does not check functions, as it is a common pattern to use readonly fields with arrow function values as auto-bound methods.
1212
This is because these types can be mutated and carry with them more complex implications about their usage.
1313

14-
#### The `fields` style
14+
### The `fields` style
1515

1616
This style checks for any getter methods that return literal values, and requires them to be defined using fields with the `readonly` modifier instead.
1717

@@ -50,7 +50,7 @@ class Mx {
5050
}
5151
```
5252

53-
#### The `getters` style
53+
### The `getters` style
5454

5555
This style checks for any `readonly` fields that are assigned literal values, and requires them to be defined as getters instead.
5656
This style pairs well with the [`@typescript-eslint/prefer-readonly`](prefer-readonly.md) rule,

packages/eslint-plugin/docs/rules/no-base-to-string.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Requires that `.toString()` is only called on objects which provide useful information when stringified (`no-base-to-string`)
22

3-
JavaScript will call `toString()` on an object when it is converted to a string, such as when `+` adding to a string or in <code>`${}`</code> template literals.
3+
JavaScript will call `toString()` on an object when it is converted to a string, such as when `+` adding to a string or in `${}` template literals.
44

55
The default Object `.toString()` returns `"[object Object]"`, so this rule requires stringified objects define a more useful `.toString()` method.
66

packages/eslint-plugin/docs/rules/prefer-as-const.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ let foo = { bar: 'baz' };
2525

2626
## When Not To Use It
2727

28-
If you are using typescript < 3.4
28+
If you are using TypeScript < 3.4

packages/parser/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Default `false`.
6767

6868
Enable parsing JSX when `true`. More details can be found [here](https://www.typescriptlang.org/docs/handbook/jsx.html).
6969

70-
**NOTE:** this setting does not affect known file types (`.js`, `.jsx`, `.ts`, `.tsx`, `.json`) because the typescript compiler has its own internal handling for known file extensions. The exact behavior is as follows:
70+
**NOTE:** this setting does not affect known file types (`.js`, `.jsx`, `.ts`, `.tsx`, `.json`) because the TypeScript compiler has its own internal handling for known file extensions. The exact behavior is as follows:
7171

7272
- if `parserOptions.project` is _not_ provided:
7373
- `.js`, `.jsx`, `.tsx` files are parsed as if this is true.

0 commit comments

Comments
 (0)