11import process from 'node:process'
22import { fileURLToPath } from 'node:url'
33import { getPackageInfoSync , isPackageExists } from 'local-pkg'
4+ import type { Linter } from 'eslint'
45import type {
56 Awaitable ,
67 OptionsConfig ,
78 ResolvedOptions ,
89 TypedFlatConfigItem ,
910} from '../types'
11+ import type { RuleOptions } from '../types/typegen'
1012
1113const scopeUrl = fileURLToPath ( new URL ( '.' , import . meta. url ) )
1214const isCwdInScope = isPackageExists ( '@coderwyd/eslint-config' )
1315
14- export const parserPlain = {
15- meta : {
16- name : 'parser-plain' ,
17- } ,
18- parseForESLint : ( code : string ) => ( {
19- ast : {
20- body : [ ] ,
21- comments : [ ] ,
22- loc : { end : code . length , start : 0 } ,
23- range : [ 0 , code . length ] ,
24- tokens : [ ] ,
25- type : 'Program' ,
26- } ,
27- scopeManager : null ,
28- services : { isPlain : true } ,
29- visitorKeys : {
30- Program : [ ] ,
31- } ,
32- } ) ,
33- }
34-
3516/**
3617 * Combine array and non-array configs into a single array.
3718 */
@@ -63,7 +44,7 @@ export async function combine(
6344export function renameRules (
6445 rules : Record < string , any > ,
6546 map : Record < string , string > ,
66- ) {
47+ ) : Record < string , any > {
6748 return Object . fromEntries (
6849 Object . entries ( rules ) . map ( ( [ key , value ] ) => {
6950 for ( const [ from , to ] of Object . entries ( map ) ) {
@@ -108,7 +89,7 @@ export function renamePluginInConfigs(
10889 } )
10990}
11091
111- export function getVueVersion ( ) {
92+ export function getVueVersion ( ) : number {
11293 const pkg = getPackageInfoSync ( 'vue' , { paths : [ process . cwd ( ) ] } )
11394 if ( pkg && typeof pkg . version === 'string' && ! Number . isNaN ( + pkg . version [ 0 ] ) )
11495 return + pkg . version [ 0 ]
@@ -131,7 +112,7 @@ export function isPackageInScope(name: string): boolean {
131112 return isPackageExists ( name , { paths : [ scopeUrl ] } )
132113}
133114
134- export async function ensurePackages ( packages : string [ ] ) {
115+ export async function ensurePackages ( packages : string [ ] ) : Promise < void > {
135116 if (
136117 process . env . CI ||
137118 process . stdout . isTTY === false ||
@@ -169,7 +150,7 @@ export function resolveSubOptions<K extends keyof OptionsConfig>(
169150export function getOverrides < K extends keyof OptionsConfig > (
170151 options : OptionsConfig ,
171152 key : K ,
172- ) {
153+ ) : Partial < Linter . RulesRecord & RuleOptions > {
173154 const sub = resolveSubOptions ( options , key )
174155 return {
175156 ...( 'overrides' in sub ? sub . overrides || { } : { } ) ,
0 commit comments