Skip to content

Commit fb7209b

Browse files
authored
chore: enable eslint-plugin-mdx for linting Markdown files (#241)
1 parent 9730916 commit fb7209b

20 files changed

+3512
-791
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ test/fixtures/typescript-d-ts/
99
# we want to ignore "test/fixtures" here, but unfortunately doing so would
1010
# interfere with unit test and fail it for some reason.
1111
# test/fixtures
12+
CHANGELOG.md

.eslintrc.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = {
1010
'plugin:eslint-plugin/recommended',
1111
'plugin:import-x/recommended',
1212
'plugin:json/recommended-legacy',
13+
'plugin:mdx/recommended',
1314
'plugin:n/recommended',
1415
'plugin:unicorn/recommended',
1516
'plugin:yml/standard',
@@ -45,6 +46,13 @@ module.exports = {
4546
'n/no-missing-import': 'off',
4647
'n/no-missing-require': 'off',
4748
'n/no-unsupported-features/es-syntax': 'off',
49+
'unicorn/filename-case': [
50+
'error',
51+
{
52+
case: 'kebabCase',
53+
ignore: [String.raw`^(CONTRIBUTING|README)\.md$`],
54+
},
55+
],
4856
'unicorn/no-array-callback-reference': 'off',
4957
'unicorn/no-array-reduce': 'off',
5058
'unicorn/no-null': 'off',
@@ -118,7 +126,14 @@ module.exports = {
118126
{
119127
files: 'global.d.ts',
120128
rules: {
121-
'import-x/no-extraneous-dependencies': 0,
129+
'import-x/no-extraneous-dependencies': 'off',
130+
},
131+
},
132+
{
133+
files: 'README.md',
134+
rules: {
135+
// https://github.com/bmish/eslint-doc-generator/issues/655
136+
'no-irregular-whitespace': 'off',
122137
},
123138
},
124139
],

.remarkrc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"plugins": [
3+
"@1stg/preset",
4+
[
5+
"lint-no-shortcut-reference-link",
6+
false
7+
],
8+
[
9+
"lint-no-undefined-references",
10+
{
11+
"allow": [
12+
"!NOTE",
13+
"!TIP",
14+
"!WARNING"
15+
]
16+
}
17+
]
18+
]
19+
}

README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,6 @@ settings:
160160
node: true
161161
```
162162
163-
[`@typescript-eslint/parser`]: https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser
164-
[`eslint-import-resolver-typescript`]: https://github.com/import-js/eslint-import-resolver-typescript
165-
166163
## Configuration (new: `eslint.config.js`)
167164

168165
From [`v8.21.0`](https://github.com/eslint/eslint/releases/tag/v8.21.0), ESLint announced a new config system.
@@ -337,11 +334,6 @@ the process's current working directory if no `package.json` is found.
337334

338335
If you are interesting in writing a resolver, see the [spec](./resolvers/README.md) for more details.
339336

340-
[`resolve`]: https://www.npmjs.com/package/resolve
341-
[`externals`]: https://webpack.github.io/docs/library-and-externals.html
342-
[Node]: https://www.npmjs.com/package/eslint-import-resolver-node
343-
[webpack]: https://www.npmjs.com/package/eslint-import-resolver-webpack
344-
345337
## Settings
346338

347339
You may set the following settings in your `.eslintrc`:
@@ -505,14 +497,11 @@ settings:
505497
lifetime: 5 # 30 is the default
506498
```
507499

508-
[`eslint_d`]: https://www.npmjs.com/package/eslint_d
509-
[`eslint-loader`]: https://www.npmjs.com/package/eslint-loader
510-
511500
### `import-x/internal-regex`
512501

513502
A regex for packages should be treated as internal. Useful when you are utilizing a monorepo setup or developing a set of packages that depend on each other.
514503

515-
By default, any package referenced from [`import-x/external-module-folders`](#importexternal-module-folders) will be considered as "external", including packages in a monorepo like yarn workspace or lerna environment. If you want to mark these packages as "internal" this will be useful.
504+
By default, any package referenced from [`import-x/external-module-folders`](#import-xexternal-module-folders) will be considered as "external", including packages in a monorepo like yarn workspace or lerna environment. If you want to mark these packages as "internal" this will be useful.
516505

517506
For example, if your packages in a monorepo are all in `@scope`, you can configure `import-x/internal-regex` like this
518507

@@ -593,3 +582,12 @@ In Package Settings / SublimeLinter / User Settings:
593582

594583
I believe this defaults to `3`, so you may not need to alter it depending on your
595584
project folder max depth.
585+
586+
[`@typescript-eslint/parser`]: https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser
587+
[`eslint-import-resolver-typescript`]: https://github.com/import-js/eslint-import-resolver-typescript
588+
[`resolve`]: https://www.npmjs.com/package/resolve
589+
[`externals`]: https://webpack.github.io/docs/library-and-externals.html
590+
[Node]: https://www.npmjs.com/package/eslint-import-resolver-node
591+
[webpack]: https://www.npmjs.com/package/eslint-import-resolver-webpack
592+
[`eslint_d`]: https://www.npmjs.com/package/eslint_d
593+
[`eslint-loader`]: https://www.npmjs.com/package/eslint-loader

docs/rules/consistent-type-specifier-style.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ This rule either enforces or bans the use of inline type-only markers for named
3131

3232
This rule includes a fixer that will automatically convert your specifiers to the correct form - however the fixer will not respect your preferences around de-duplicating imports. If this is important to you, consider using the [`import-x/no-duplicates`] rule.
3333

34-
[`import-x/no-duplicates`]: ./no-duplicates.md
35-
3634
## Options
3735

3836
The rule accepts a single string option which may be one of:
@@ -89,3 +87,5 @@ import {typeof Foo} from 'Foo';
8987
If you aren't using Flow or TypeScript 4.5+, then this rule does not apply and need not be used.
9088

9189
If you don't care about, and don't want to standardize how named specifiers are imported then you should not use this rule.
90+
91+
[`import-x/no-duplicates`]: ./no-duplicates.md

docs/rules/default.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ Redux's npm module includes this key, and thereby is lintable, for example.
1616

1717
A module path that is [ignored] or not [unambiguously an ES module] will not be reported when imported.
1818

19-
[ignored]: ../README.md#importignore
20-
[unambiguously an ES module]: https://github.com/bmeck/UnambiguousJavaScriptGrammar
21-
2219
## Rule Details
2320

2421
Given:
@@ -78,3 +75,5 @@ either, so such a situation will be reported in the importing module.
7875
[ES7]: https://github.com/leebyron/ecmascript-more-export-from
7976
[`import-x/ignore`]: ../../README.md#importignore
8077
[`jsnext:main`]: https://github.com/rollup/rollup/wiki/jsnext:main
78+
[ignored]: ../../README.md#importignore
79+
[unambiguously an ES module]: https://github.com/bmeck/UnambiguousJavaScriptGrammar

docs/rules/dynamic-import-chunkname.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ If you want to allow dynamic imports without a webpackChunkName, you can set `al
103103

104104
Given `{ "allowEmpty": true }`:
105105

106-
<!-- markdownlint-disable-next-line MD024 -- duplicate header -->
106+
<!-- lint disable no-duplicate-headings-in-section -->
107107

108108
### valid
109109

@@ -118,7 +118,7 @@ import(
118118
)
119119
```
120120

121-
<!-- markdownlint-disable-next-line MD024 -- duplicate header -->
121+
<!-- lint disable no-duplicate-headings-in-section -->
122122

123123
### invalid
124124

docs/rules/extensions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ By providing an object you can configure each extension separately.
2222
}]
2323
```
2424

25-
For example `{ "js": "always", "json": "never" }` would always enforce the use of the `.js` extension but never allow the use of the `.json` extension.
25+
For example `{ "js": "always", "json": "never" }` would always enforce the use of the `.js` extension but never allow the use of the `.json` extension.
2626

2727
By providing both a string and an object, the string will set the default setting for all extensions, and the object can be used to set granular overrides for specific extensions.
2828

@@ -66,8 +66,8 @@ For example, given the following folder structure:
6666

6767
```pt
6868
├── foo
69-
   ├── bar.js
70-
   ├── bar.json
69+
├── bar.js
70+
├── bar.json
7171
```
7272

7373
and this import statement:

docs/rules/max-dependencies.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Ignores `type` imports. Type imports are a feature released in TypeScript 3.8, y
4747

4848
Given `{"max": 2, "ignoreTypeImports": true}`:
4949

50-
<!-- markdownlint-disable-next-line MD024 -- duplicate header -->
50+
<!-- lint disable no-duplicate-headings-in-section -->
5151

5252
### Fail
5353

@@ -57,7 +57,7 @@ import b from './b'
5757
import c from './c'
5858
```
5959

60-
<!-- markdownlint-disable-next-line MD024 -- duplicate header -->
60+
<!-- lint disable no-duplicate-headings-in-section -->
6161

6262
### Pass
6363

docs/rules/named.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ Redux's npm module includes this key, and thereby is lintable, for example.
1414

1515
A module path that is [ignored] or not [unambiguously an ES module] will not be reported when imported. Note that type imports and exports, as used by [Flow], are always ignored.
1616

17-
[ignored]: ../../README.md#importignore
18-
[unambiguously an ES module]: https://github.com/bmeck/UnambiguousJavaScriptGrammar
19-
[Flow]: https://flow.org/
20-
2117
## Rule Details
2218

2319
Given:
@@ -100,3 +96,6 @@ runtime, you will likely see false positives with this rule.
10096
[`jsnext:main`]: https://github.com/jsforum/jsforum/issues/5
10197
[`pkg.module`]: https://github.com/rollup/rollup/wiki/pkg.module
10298
[`import-x/ignore`]: ../../README.md#importignore
99+
[ignored]: ../../README.md#importignore
100+
[unambiguously an ES module]: https://github.com/bmeck/UnambiguousJavaScriptGrammar
101+
[Flow]: https://flow.org/

0 commit comments

Comments
 (0)