-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.ts
More file actions
53 lines (46 loc) · 1.22 KB
/
index.ts
File metadata and controls
53 lines (46 loc) · 1.22 KB
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
import type { ESLint, Linter } from 'eslint'
import markdown, { MarkdownLanguage } from '@eslint/markdown'
import { rules } from './rules'
export const plugin: ESLint.Plugin = {
rules,
processors: markdown.processors,
languages: {
gfm: new MarkdownLanguage({ mode: 'gfm' }),
},
}
const recommendedRules: Partial<Linter.RulesRecord> = {
'md-style/valid-heading-anchor': 'error',
'md-style/space-around-inline-element': 'error',
}
const allRules: Partial<Linter.RulesRecord>
= Object.fromEntries(Object.keys(rules)
.map(ruleName => [`md-style/${ruleName}`, 'error']))
interface PluginConfigMap {
recommended: Linter.Config
all: Linter.Config
}
export const configs: PluginConfigMap = {
recommended: {
name: 'md-style/recommended',
files: ['**/*.md'],
plugins: {
'md-style': plugin,
},
language: 'md-style/gfm',
rules: recommendedRules,
},
all: {
name: 'md-style/all',
files: ['**/*.md'],
plugins: {
'md-style': plugin,
},
language: 'md-style/gfm',
rules: allRules,
},
}
export type MdStylePlugin = ESLint.Plugin & {
configs: PluginConfigMap
}
const mdStylePlugin: MdStylePlugin = Object.assign(plugin, { configs })
export default mdStylePlugin