11import semver from 'semver' ;
22
3- import { CodeshiftConfig } from '@hypermod/types' ;
3+ import { Config } from '@hypermod/types' ;
44import { fetchConfig } from '@hypermod/fetcher' ;
55
6- function hasValidTransforms ( config : CodeshiftConfig ) {
6+ function hasValidTransforms ( config : Config ) {
77 if ( ! config . transforms ) return true ;
88
99 return Object . entries ( config . transforms ) . every ( ( [ key ] ) => semver . valid ( key ) ) ;
1010}
1111
12- function hasValidPresets ( config : CodeshiftConfig ) : boolean {
12+ function hasValidPresets ( config : Config ) : boolean {
1313 if ( ! config . presets ) return true ;
1414
1515 return Object . entries ( config . presets ) . every ( ( [ key ] ) =>
1616 key . match ( / ^ [ 0 - 9 a - z A - Z \- ] + $ / ) ,
1717 ) ;
1818}
1919
20- function getInvalidProperties ( config : CodeshiftConfig ) {
20+ function getInvalidProperties ( config : Config ) {
2121 const validProperties = [
2222 'maintainers' ,
2323 'description' ,
@@ -33,7 +33,7 @@ export function isValidPackageName(dir: string): boolean {
3333 return ! ! dir . match ( / ^ ( @ [ a - z 0 - 9 - ~ ] [ a - z 0 - 9 - ._ ~ ] * _ _ ) ? [ a - z 0 - 9 - ~ ] [ a - z 0 - 9 - ._ ~ ] * $ / ) ;
3434}
3535
36- export function isValidConfig ( config : CodeshiftConfig ) {
36+ export function isValidConfig ( config : Config ) {
3737 return hasValidTransforms ( config ) && hasValidPresets ( config ) ;
3838}
3939
@@ -44,10 +44,10 @@ export async function isValidConfigAtPath(filePath: string) {
4444 throw new Error ( `Unable to locate config file at path: ${ filePath } ` ) ;
4545 }
4646
47- const invalidProperites = getInvalidProperties ( configMeta . config ) ;
48- if ( invalidProperites . length ) {
47+ const invalidProperties = getInvalidProperties ( configMeta . config ) ;
48+ if ( invalidProperties . length ) {
4949 throw new Error (
50- `Invalid transform ids found: ${ invalidProperites . join ( ', ' ) } ` ,
50+ `Invalid transform ids found: ${ invalidProperties . join ( ', ' ) } ` ,
5151 ) ;
5252 }
5353
0 commit comments