Skip to content

Commit 38a3a23

Browse files
authored
fix: export plugin meta data
1 parent 87e1883 commit 38a3a23

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

index.ts

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { ESLint, Linter, Rule } from 'eslint'
22

3+
import { version as packageVersion, name as packageName } from './package.json'
34
import sortVariableDeclarations from './rules/sort-variable-declarations'
45
import sortIntersectionTypes from './rules/sort-intersection-types'
56
import sortHeritageClauses from './rules/sort-heritage-clauses'
@@ -54,15 +55,18 @@ interface PluginConfig {
5455
'recommended-natural': Linter.Config
5556
'recommended-custom': Linter.Config
5657
}
57-
name: string
58+
meta: {
59+
version: string
60+
name: string
61+
}
5862
}
5963

6064
interface BaseOptions {
6165
type: 'alphabetical' | 'line-length' | 'natural' | 'custom'
6266
order: 'desc' | 'asc'
6367
}
6468

65-
let name = 'perfectionist'
69+
let pluginName = 'perfectionist'
6670

6771
let plugin = {
6872
rules: {
@@ -87,27 +91,30 @@ let plugin = {
8791
'sort-sets': sortSets,
8892
'sort-maps': sortMaps,
8993
},
90-
name,
94+
meta: {
95+
version: packageVersion,
96+
name: packageName,
97+
},
9198
} as unknown as ESLint.Plugin
9299

93100
let getRules = (options: BaseOptions): Linter.RulesRecord =>
94101
Object.fromEntries(
95102
Object.keys(plugin.rules!).map(ruleName => [
96-
`${name}/${ruleName}`,
103+
`${pluginName}/${ruleName}`,
97104
['error', options],
98105
]),
99106
)
100107

101108
let createConfig = (options: BaseOptions): Linter.Config => ({
102109
plugins: {
103-
[name]: plugin,
110+
[pluginName]: plugin,
104111
},
105112
rules: getRules(options),
106113
})
107114

108115
let createLegacyConfig = (options: BaseOptions): Linter.LegacyConfig => ({
109116
rules: getRules(options),
110-
plugins: [name],
117+
plugins: [pluginName],
111118
})
112119

113120
export default {

0 commit comments

Comments
 (0)