@@ -2,19 +2,24 @@ import { RuleConverter } from "../converter";
22
33const SUPPORTED_OPTIONS : string [ ] = [ "anonymous" , "asyncArrow" , "named" ] ;
44
5+ type ObjectArgument = Record < string , "always" | "never" > ;
6+
7+ const isObjectArgument = ( argument : unknown ) : argument is ObjectArgument =>
8+ typeof argument === "object" && argument !== null ;
9+
510export const convertSpaceBeforeFunctionParen : RuleConverter = tslintRule => {
6- const argument : "always" | "never" | { [ key : string ] : "always" | "never" } | undefined =
7- tslintRule . ruleArguments [ 0 ] ;
11+ const argument : unknown = tslintRule . ruleArguments [ 0 ] ;
812 const ruleName = "space-before-function-paren" ;
913 if ( argument === "always" || argument === "never" ) {
1014 return { rules : [ { ruleArguments : [ argument ] , ruleName } ] } ;
11- } else if ( typeof argument === "object" && argument !== null ) {
15+ }
16+ if ( isObjectArgument ( argument ) ) {
1217 const notices = Object . keys ( argument )
1318 . filter ( option => ! SUPPORTED_OPTIONS . includes ( option ) )
1419 . map ( option => `Option "${ option } " is not supported by ESLint.` ) ;
1520 const filtered = Object . keys ( argument )
1621 . filter ( option => SUPPORTED_OPTIONS . includes ( option ) )
17- . reduce < Record < string , "always" | "never" > > ( ( obj , option ) => {
22+ . reduce < ObjectArgument > ( ( obj , option ) => {
1823 return { ...obj , [ option ] : argument [ option ] } ;
1924 } , { } ) ;
2025 return {
0 commit comments