--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: invalid.ts --- # Input ```ts export function h(a: number, b?: number, c: number) {} export function l(a = 0, b?: number, c: number) {} export function f(a = 0, b = 0, c?: string, c: string) {} export function h(a/* before */?/* after */: number, b: number) {} export class Foo { constructor(readonly a = 10, readonly b: number) {} } ``` # Diagnostics ``` invalid.ts:1:30 lint/style/useDefaultParameterLast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This optional parameter should follow the last required parameter or should be a required parameter. > 1 │ export function h(a: number, b?: number, c: number) {} │ ^^^^^^^^^^ 2 │ 3 │ export function l(a = 0, b?: number, c: number) {} i The last required parameter is here: > 1 │ export function h(a: number, b?: number, c: number) {} │ ^^^^^^^^^ 2 │ 3 │ export function l(a = 0, b?: number, c: number) {} i A optional parameter that precedes a required parameter cannot be omitted at call site. i Unsafe fix: Turn the parameter into a required parameter. 1 │ export·function·h(a:·number,·b?:·number,·c:·number)·{} │ - ``` ``` invalid.ts:3:19 lint/style/useDefaultParameterLast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This default parameter should follow the last required parameter or should be a required parameter. 1 │ export function h(a: number, b?: number, c: number) {} 2 │ > 3 │ export function l(a = 0, b?: number, c: number) {} │ ^^^^^ 4 │ 5 │ export function f(a = 0, b = 0, c?: string, c: string) {} i The last required parameter is here: 1 │ export function h(a: number, b?: number, c: number) {} 2 │ > 3 │ export function l(a = 0, b?: number, c: number) {} │ ^^^^^^^^^ 4 │ 5 │ export function f(a = 0, b = 0, c?: string, c: string) {} i A default parameter that precedes a required parameter cannot be omitted at call site. i Unsafe fix: Turn the parameter into a required parameter. 3 │ export·function·l(a·=·0,·b?:·number,·c:·number)·{} │ ---- ``` ``` invalid.ts:3:26 lint/style/useDefaultParameterLast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This optional parameter should follow the last required parameter or should be a required parameter. 1 │ export function h(a: number, b?: number, c: number) {} 2 │ > 3 │ export function l(a = 0, b?: number, c: number) {} │ ^^^^^^^^^^ 4 │ 5 │ export function f(a = 0, b = 0, c?: string, c: string) {} i The last required parameter is here: 1 │ export function h(a: number, b?: number, c: number) {} 2 │ > 3 │ export function l(a = 0, b?: number, c: number) {} │ ^^^^^^^^^ 4 │ 5 │ export function f(a = 0, b = 0, c?: string, c: string) {} i A optional parameter that precedes a required parameter cannot be omitted at call site. i Unsafe fix: Turn the parameter into a required parameter. 3 │ export·function·l(a·=·0,·b?:·number,·c:·number)·{} │ - ``` ``` invalid.ts:5:19 lint/style/useDefaultParameterLast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This default parameter should follow the last required parameter or should be a required parameter. 3 │ export function l(a = 0, b?: number, c: number) {} 4 │ > 5 │ export function f(a = 0, b = 0, c?: string, c: string) {} │ ^^^^^ 6 │ 7 │ export function h(a/* before */?/* after */: number, b: number) {} i The last required parameter is here: 3 │ export function l(a = 0, b?: number, c: number) {} 4 │ > 5 │ export function f(a = 0, b = 0, c?: string, c: string) {} │ ^^^^^^^^^ 6 │ 7 │ export function h(a/* before */?/* after */: number, b: number) {} i A default parameter that precedes a required parameter cannot be omitted at call site. i Unsafe fix: Turn the parameter into a required parameter. 5 │ export·function·f(a·=·0,·b·=·0,·c?:·string,·c:·string)·{} │ ---- ``` ``` invalid.ts:5:26 lint/style/useDefaultParameterLast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This default parameter should follow the last required parameter or should be a required parameter. 3 │ export function l(a = 0, b?: number, c: number) {} 4 │ > 5 │ export function f(a = 0, b = 0, c?: string, c: string) {} │ ^^^^^ 6 │ 7 │ export function h(a/* before */?/* after */: number, b: number) {} i The last required parameter is here: 3 │ export function l(a = 0, b?: number, c: number) {} 4 │ > 5 │ export function f(a = 0, b = 0, c?: string, c: string) {} │ ^^^^^^^^^ 6 │ 7 │ export function h(a/* before */?/* after */: number, b: number) {} i A default parameter that precedes a required parameter cannot be omitted at call site. i Unsafe fix: Turn the parameter into a required parameter. 5 │ export·function·f(a·=·0,·b·=·0,·c?:·string,·c:·string)·{} │ ---- ``` ``` invalid.ts:5:33 lint/style/useDefaultParameterLast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This optional parameter should follow the last required parameter or should be a required parameter. 3 │ export function l(a = 0, b?: number, c: number) {} 4 │ > 5 │ export function f(a = 0, b = 0, c?: string, c: string) {} │ ^^^^^^^^^^ 6 │ 7 │ export function h(a/* before */?/* after */: number, b: number) {} i The last required parameter is here: 3 │ export function l(a = 0, b?: number, c: number) {} 4 │ > 5 │ export function f(a = 0, b = 0, c?: string, c: string) {} │ ^^^^^^^^^ 6 │ 7 │ export function h(a/* before */?/* after */: number, b: number) {} i A optional parameter that precedes a required parameter cannot be omitted at call site. i Unsafe fix: Turn the parameter into a required parameter. 5 │ export·function·f(a·=·0,·b·=·0,·c?:·string,·c:·string)·{} │ - ``` ``` invalid.ts:7:19 lint/style/useDefaultParameterLast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This optional parameter should follow the last required parameter or should be a required parameter. 5 │ export function f(a = 0, b = 0, c?: string, c: string) {} 6 │ > 7 │ export function h(a/* before */?/* after */: number, b: number) {} │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 │ 9 │ export class Foo { i The last required parameter is here: 5 │ export function f(a = 0, b = 0, c?: string, c: string) {} 6 │ > 7 │ export function h(a/* before */?/* after */: number, b: number) {} │ ^^^^^^^^^ 8 │ 9 │ export class Foo { i A optional parameter that precedes a required parameter cannot be omitted at call site. i Unsafe fix: Turn the parameter into a required parameter. 7 │ export·function·h(a/*·before·*/?/*·after·*/:·number,·b:·number)·{} │ - ``` ``` invalid.ts:10:17 lint/style/useDefaultParameterLast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This default parameter should follow the last required parameter or should be a required parameter. 9 │ export class Foo { > 10 │ constructor(readonly a = 10, readonly b: number) {} │ ^^^^^^^^^^^^^^^ 11 │ } i The last required parameter is here: 9 │ export class Foo { > 10 │ constructor(readonly a = 10, readonly b: number) {} │ ^^^^^^^^^^^^^^^^^^ 11 │ } i A default parameter that precedes a required parameter cannot be omitted at call site. i Unsafe fix: Turn the parameter into a required parameter. 10 │ ····constructor(readonly·a·=·10,·readonly·b:·number)·{} │ ----- ```