forked from antfu/eslint-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarkdown.ts
90 lines (82 loc) · 2.52 KB
/
markdown.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { mergeProcessors, processorPassThrough } from 'eslint-merge-processors'
import type { OptionsComponentExts, OptionsFiles, OptionsOverrides, TypedFlatConfigItem } from '../types'
import { GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN } from '../globs'
import { interopDefault, parserPlain } from '../utils'
export async function markdown(
options: OptionsFiles & OptionsComponentExts & OptionsOverrides = {},
): Promise<TypedFlatConfigItem[]> {
const {
componentExts = [],
files = [GLOB_MARKDOWN],
overrides = {},
} = options
// @ts-expect-error missing types
const markdown = await interopDefault(import('eslint-plugin-markdown'))
return [
{
name: 'antfu/markdown/setup',
plugins: {
markdown,
},
},
{
files,
ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
name: 'antfu/markdown/processor',
// `eslint-plugin-markdown` only creates virtual files for code blocks,
// but not the markdown file itself. We use `eslint-merge-processors` to
// add a pass-through processor for the markdown file itself.
processor: mergeProcessors([
markdown.processors.markdown,
processorPassThrough,
]),
},
{
files,
languageOptions: {
parser: parserPlain,
},
name: 'antfu/markdown/parser',
},
{
files: [
GLOB_MARKDOWN_CODE,
...componentExts.map(ext => `${GLOB_MARKDOWN}/**/*.${ext}`),
],
languageOptions: {
parserOptions: {
ecmaFeatures: {
impliedStrict: true,
},
},
},
name: 'antfu/markdown/disables',
rules: {
'import/newline-after-import': 'off',
'no-alert': 'off',
'no-console': 'off',
'no-labels': 'off',
'no-lone-blocks': 'off',
'no-restricted-syntax': 'off',
'no-undef': 'off',
'no-unused-expressions': 'off',
'no-unused-labels': 'off',
'no-unused-vars': 'off',
'node/prefer-global/process': 'off',
'style/comma-dangle': 'off',
'style/eol-last': 'off',
'ts/consistent-type-imports': 'off',
'ts/no-namespace': 'off',
'ts/no-redeclare': 'off',
'ts/no-require-imports': 'off',
'ts/no-unused-vars': 'off',
'ts/no-use-before-define': 'off',
'ts/no-var-requires': 'off',
'unicode-bom': 'off',
'unused-imports/no-unused-imports': 'off',
'unused-imports/no-unused-vars': 'off',
...overrides,
},
},
]
}