Skip to content

Commit 27f9a73

Browse files
heiskrCopilot
andauthored
Remove 'any' from markdownlint .d.ts declarations (#61661)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 807bf73 commit 27f9a73

4 files changed

Lines changed: 17 additions & 22 deletions

File tree

eslint.config.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,6 @@ export default [
259259
'src/search/lib/search-request-params/get-search-from-request-params.ts',
260260
'src/search/scripts/index/index-cli.ts',
261261
'src/search/scripts/index/utils/indexing-elasticsearch-utils.ts',
262-
'src/types/github__markdownlint-github.d.ts',
263-
'src/types/markdownlint-lib-rules.d.ts',
264-
'src/types/markdownlint-rule-helpers.d.ts',
265262
],
266263
rules: {
267264
'@typescript-eslint/no-explicit-any': 'off',

src/types/github__markdownlint-github.d.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
declare module '@github/markdownlint-github' {
2+
import type { RuleParams, RuleOnError } from 'markdownlint'
3+
24
interface MarkdownlintRule {
35
names: string[]
46
description: string
57
tags: string[]
6-
// Using any because @github/markdownlint-github doesn't provide TypeScript definitions
7-
// params contains markdownlint parsing context with varying structures per rule
8-
// onError is a callback function with dynamic signature
9-
function: (params: any, onError: any) => void
8+
function: (params: RuleParams, onError: RuleOnError) => void
109
}
1110

1211
const markdownlintGitHub: MarkdownlintRule[]

src/types/markdownlint-lib-rules.d.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
declare module '*/markdownlint/lib/rules' {
2+
import type { RuleParams, RuleOnError } from 'markdownlint'
3+
24
interface MarkdownlintRule {
35
names: string[]
46
description: string
57
tags: string[]
6-
// Using any because markdownlint doesn't provide TypeScript definitions
7-
// params contains parsing context with varying structures per rule
8-
// onError is a callback function with dynamic signature
9-
function: (params: any, onError: any) => void
8+
function: (params: RuleParams, onError: RuleOnError) => void
109
}
1110

1211
const rules: MarkdownlintRule[]
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
declare module 'markdownlint-rule-helpers' {
2+
import type { RuleParams, RuleErrorCallback, MarkdownToken } from '@/content-linter/types'
3+
import type { LintError } from 'markdownlint'
4+
25
/**
36
* Adds an error to the linting results
4-
* Using any because this third-party library doesn't provide TypeScript definitions
5-
* onError is a callback function with dynamic signature from markdownlint
6-
* fixInfo contains various fix information structures depending on the error type
77
*/
88
export function addError(
9-
onError: any,
9+
onError: RuleErrorCallback,
1010
lineNumber: number,
1111
detail?: string,
1212
context?: string | null,
1313
range?: [number, number] | number[] | string | null,
14-
fixInfo?: any,
14+
fixInfo?: unknown,
1515
): void
1616

1717
/**
1818
* Filters tokens by type and calls a handler for each matching token
19-
* Using any because markdownlint-rule-helpers has no TypeScript definitions
20-
* params contains markdownlint parsing parameters with varying structures
21-
* token represents markdown tokens with different properties per token type
2219
*/
23-
export function filterTokens(params: any, type: string, handler: (token: any) => void): void
20+
export function filterTokens(
21+
params: RuleParams,
22+
type: string,
23+
handler: (token: MarkdownToken) => void,
24+
): void
2425

2526
/**
2627
* Truncates long strings with ellipsis for display
@@ -34,7 +35,6 @@ declare module 'markdownlint-rule-helpers' {
3435

3536
/**
3637
* Applies fixes to markdown content
37-
* Using any[] because error objects from markdownlint have dynamic structures
3838
*/
39-
export function applyFixes(content: string, errors: any[]): string
39+
export function applyFixes(content: string, errors: LintError[]): string
4040
}

0 commit comments

Comments
 (0)