Skip to main content

Function: insertProperty()

insertProperty(fixer: RuleFixer, obj: Readonly<JSONObjectExpression>, key: string, value: JsonPrimitive, indent?: string): RuleTextEdit

Defined in: _internal/jsonc-helpers.ts:272

Build fixer text for inserting a new property into an existing object.

Parametersโ€‹

fixerโ€‹

RuleFixer

ESLint rule fixer.

objโ€‹

Readonly<JSONObjectExpression>

Target JSON object to insert into.

keyโ€‹

string

Property name to insert.

valueโ€‹

JsonPrimitive

Property value to insert.

indent?โ€‹

string = " "

Indentation string for the new line (default: " ").

Returnsโ€‹

RuleTextEdit

An ESLint fix object.

Remarksโ€‹

Appends the property after the last existing property in the object, or creates a simple { "key": value } when the object is empty.