@@ -65,10 +65,8 @@ fn is_inside_yield_or_await(node: &AstNode) -> bool {
6565
6666impl Rule for PreferAwaitToThen {
6767 fn from_configuration ( value : serde_json:: Value ) -> Self {
68- let strict = match value {
69- Value :: Object ( obj) => obj. get ( "strict" ) . and_then ( Value :: as_bool) . unwrap_or ( false ) ,
70- _ => false ,
71- } ;
68+ let config = value. get ( 0 ) ;
69+ let strict = config. and_then ( |v| v. get ( "strict" ) ) . and_then ( Value :: as_bool) . unwrap_or ( false ) ;
7270
7371 Self ( PreferAwaitToThenConfig { strict } )
7472 }
@@ -135,7 +133,7 @@ fn test() {
135133 ) ,
136134 (
137135 "async function hi() { await thing().then() }" ,
138- Some ( serde_json:: json!( { "strict" : false } ) ) ,
136+ Some ( serde_json:: json!( [ { "strict" : false } ] ) ) ,
139137 ) ,
140138 ( "const { promise, resolve } = Promise.withResolvers()" , None ) ,
141139 ( "function x () { return Promise.all() } " , None ) ,
@@ -153,9 +151,13 @@ fn test() {
153151 ( "something().then(async () => await somethingElse())" , None ) ,
154152 (
155153 "async function foo() { await thing().then() }" ,
156- Some ( serde_json:: json!( { "strict" : true } ) ) ,
154+ Some ( serde_json:: json!( [ { "strict" : true } ] ) ) ,
155+ ) ,
156+ ( "async function foo() { thing().then() }" , Some ( serde_json:: json!( [ { "strict" : false } ] ) ) ) ,
157+ (
158+ "async function hi() { await thing().then(x => {}) }" ,
159+ Some ( serde_json:: json!( [ { "strict" : true } ] ) ) ,
157160 ) ,
158- ( "async function foo() { thing().then() }" , Some ( serde_json:: json!( { "strict" : false } ) ) ) ,
159161 ] ;
160162
161163 Tester :: new ( PreferAwaitToThen :: NAME , PreferAwaitToThen :: PLUGIN , pass, fail) . test_and_snapshot ( ) ;
0 commit comments