1
1
import type { ESLint , Linter , Rule } from 'eslint'
2
2
3
+ import { version as packageVersion , name as packageName } from './package.json'
3
4
import sortVariableDeclarations from './rules/sort-variable-declarations'
4
5
import sortIntersectionTypes from './rules/sort-intersection-types'
5
6
import sortHeritageClauses from './rules/sort-heritage-clauses'
@@ -54,15 +55,18 @@ interface PluginConfig {
54
55
'recommended-natural' : Linter . Config
55
56
'recommended-custom' : Linter . Config
56
57
}
57
- name : string
58
+ meta : {
59
+ version : string
60
+ name : string
61
+ }
58
62
}
59
63
60
64
interface BaseOptions {
61
65
type : 'alphabetical' | 'line-length' | 'natural' | 'custom'
62
66
order : 'desc' | 'asc'
63
67
}
64
68
65
- let name = 'perfectionist'
69
+ let pluginName = 'perfectionist'
66
70
67
71
let plugin = {
68
72
rules : {
@@ -87,27 +91,30 @@ let plugin = {
87
91
'sort-sets' : sortSets ,
88
92
'sort-maps' : sortMaps ,
89
93
} ,
90
- name,
94
+ meta : {
95
+ version : packageVersion ,
96
+ name : packageName ,
97
+ } ,
91
98
} as unknown as ESLint . Plugin
92
99
93
100
let getRules = ( options : BaseOptions ) : Linter . RulesRecord =>
94
101
Object . fromEntries (
95
102
Object . keys ( plugin . rules ! ) . map ( ruleName => [
96
- `${ name } /${ ruleName } ` ,
103
+ `${ pluginName } /${ ruleName } ` ,
97
104
[ 'error' , options ] ,
98
105
] ) ,
99
106
)
100
107
101
108
let createConfig = ( options : BaseOptions ) : Linter . Config => ( {
102
109
plugins : {
103
- [ name ] : plugin ,
110
+ [ pluginName ] : plugin ,
104
111
} ,
105
112
rules : getRules ( options ) ,
106
113
} )
107
114
108
115
let createLegacyConfig = ( options : BaseOptions ) : Linter . LegacyConfig => ( {
109
116
rules : getRules ( options ) ,
110
- plugins : [ name ] ,
117
+ plugins : [ pluginName ] ,
111
118
} )
112
119
113
120
export default {
0 commit comments