--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: invalid.js --- # Input ```jsx var foo = { get bar() {} }; var foo = { get bar(){ if(baz) { return true; } } }; var foo = { get bar() { ~function () { return true; } } }; var foo = { get bar() { return; } }; class Foo { get bar() {} } class Foo { get bar(){ if(baz) { return true; } } } class Foo { get bar() { ~function () { return true; } } } class Foo { get bar() { return; } } class Foo { get bar(){ try { return foo(); } catch {} finally {} } } class Foo { get bar(){ switch (this.n) { case 0: return 0; case 1: case 2: break; } } } var foo = { get bar(){ if(baz) { return true; } else { false; } } }; var foo = { get bar(){ if(baz) { true; } else { return false; } } }; var foo = { get bar(){ for (;;) { break; } while (false) { return true; } } }; var foo = { get bar(){ do { if (bar()) { return 0; } } while(foo()); for (x in [1, 2]) { if (x == 0) { return 0; } } } }; var foo = { get bar(){ if(baz) { if (foo) { return true; } } else { return true; } } }; ``` # Diagnostics ``` invalid.js:2:5 lint/suspicious/useGetterReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This getter should return a value. 1 │ var foo = { > 2 │ get bar() {} │ ^^^^^^^^^^^^ 3 │ }; 4 │ ``` ``` invalid.js:6:5 lint/suspicious/useGetterReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This getter should return a value. 5 │ var foo = { > 6 │ get bar(){ │ ^^^^^^^^^^ > 7 │ if(baz) { > 8 │ return true; > 9 │ } > 10 │ } │ ^ 11 │ }; 12 │ ``` ``` invalid.js:14:5 lint/suspicious/useGetterReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This getter should return a value. 13 │ var foo = { > 14 │ get bar() { │ ^^^^^^^^^^^ > 15 │ ~function () { > 16 │ return true; > 17 │ } > 18 │ } │ ^ 19 │ }; 20 │ ``` ``` invalid.js:23:9 lint/suspicious/useGetterReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This return should return a value because it is located in a getter. 21 │ var foo = { 22 │ get bar() { > 23 │ return; │ ^^^^^^^ 24 │ } 25 │ }; ``` ``` invalid.js:28:5 lint/suspicious/useGetterReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This getter should return a value. 27 │ class Foo { > 28 │ get bar() {} │ ^^^^^^^^^^^^ 29 │ } 30 │ ``` ``` invalid.js:32:5 lint/suspicious/useGetterReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This getter should return a value. 31 │ class Foo { > 32 │ get bar(){ │ ^^^^^^^^^^ > 33 │ if(baz) { > 34 │ return true; > 35 │ } > 36 │ } │ ^ 37 │ } 38 │ ``` ``` invalid.js:40:5 lint/suspicious/useGetterReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This getter should return a value. 39 │ class Foo { > 40 │ get bar() { │ ^^^^^^^^^^^ > 41 │ ~function () { > 42 │ return true; > 43 │ } > 44 │ } │ ^ 45 │ } 46 │ ``` ``` invalid.js:49:9 lint/suspicious/useGetterReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This return should return a value because it is located in a getter. 47 │ class Foo { 48 │ get bar() { > 49 │ return; │ ^^^^^^^ 50 │ } 51 │ } ``` ``` invalid.js:54:5 lint/suspicious/useGetterReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This getter should return a value. 53 │ class Foo { > 54 │ get bar(){ │ ^^^^^^^^^^ > 55 │ try { > 56 │ return foo(); > 57 │ } catch {} finally {} > 58 │ } │ ^ 59 │ } 60 │ ``` ``` invalid.js:62:5 lint/suspicious/useGetterReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This getter should return a value. 61 │ class Foo { > 62 │ get bar(){ │ ^^^^^^^^^^ > 63 │ switch (this.n) { ... > 69 │ } > 70 │ } │ ^ 71 │ } 72 │ ``` ``` invalid.js:74:5 lint/suspicious/useGetterReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This getter should return a value. 73 │ var foo = { > 74 │ get bar(){ │ ^^^^^^^^^^ > 75 │ if(baz) { ... > 79 │ } > 80 │ } │ ^ 81 │ }; 82 │ ``` ``` invalid.js:84:5 lint/suspicious/useGetterReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This getter should return a value. 83 │ var foo = { > 84 │ get bar(){ │ ^^^^^^^^^^ > 85 │ if(baz) { ... > 89 │ } > 90 │ } │ ^ 91 │ }; 92 │ ``` ``` invalid.js:94:5 lint/suspicious/useGetterReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This getter should return a value. 93 │ var foo = { > 94 │ get bar(){ │ ^^^^^^^^^^ > 95 │ for (;;) { ... > 100 │ } > 101 │ } │ ^ 102 │ }; 103 │ ``` ``` invalid.js:105:5 lint/suspicious/useGetterReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This getter should return a value. 104 │ var foo = { > 105 │ get bar(){ │ ^^^^^^^^^^ > 106 │ do { ... > 115 │ } > 116 │ } │ ^ 117 │ }; 118 │ ``` ``` invalid.js:120:5 lint/suspicious/useGetterReturn ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This getter should return a value. 119 │ var foo = { > 120 │ get bar(){ │ ^^^^^^^^^^ > 121 │ if(baz) { ... > 127 │ } > 128 │ } │ ^ 129 │ }; 130 │ ```