Skip to content

Commit 5f18625

Browse files
committed
refactor(interfaces): enhance LintFixer interface and update function signatures 🧹
- Add comprehensive LintFixer interface methods for text manipulation - Remove unused context parameter from createOptionalChainingFix function - Update PreferOptionalChain rule to use simplified function signature
1 parent c1ed28f commit 5f18625

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/interfaces/DenoContext.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,22 @@ export interface LintContext {
257257
* Fixer object provided to lint rules for applying automatic fixes to source code.
258258
*/
259259
export interface LintFixer {
260+
/** Insert text after the given node */
261+
insertTextAfter(node: ASTNode, text: string): unknown
262+
/** Insert text after the given range */
263+
insertTextAfterRange(range: [number, number], text: string): unknown
264+
/** Insert text before the given node */
265+
insertTextBefore(node: ASTNode, text: string): unknown
266+
/** Insert text before the given range */
267+
insertTextBeforeRange(range: [number, number], text: string): unknown
268+
/** Remove the given node */
269+
remove(node: ASTNode): unknown
270+
/** Remove text in the given range */
271+
removeRange(range: [number, number]): unknown
260272
/** Replace the text of a node */
261273
replaceText(node: ASTNode, text: string): unknown
274+
/** Replace text in the given range */
275+
replaceTextRange(range: [number, number], text: string): unknown
262276
}
263277

264278
/**

src/rules/PreferOptionalChain.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const preferOptionalChainRule = {
3131
context.report({
3232
node,
3333
message: 'Prefer optional chaining (?.) over logical AND (&&) for property access.',
34-
fix: createOptionalChainingFix(context, node, convertedText)
34+
fix: createOptionalChainingFix(node, convertedText)
3535
})
3636
}
3737
}

src/utils/FixUtils.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,11 @@ export function createAddSuffixFix(
125125

126126
/**
127127
* Creates a fix that converts logical AND to optional chaining.
128-
* @param _context - The lint context
129128
* @param node - The logical expression node
130129
* @param convertedText - The converted text
131130
* @returns A fix function
132131
*/
133132
export function createOptionalChainingFix(
134-
_context: LintContext,
135133
node: DenoASTNode,
136134
convertedText: string
137135
): (fixer: LintFixer) => unknown {

0 commit comments

Comments
 (0)