-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always print own before injected
- Loading branch information
Showing
3 changed files
with
38 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 9 additions & 3 deletions
12
.../eslint-plugin-obsidian/src/rules/stronglyTypedInjectComponent/result/missingTypeError.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
import type { Type } from '../../../dto/types/type'; | ||
import type { Result } from './result'; | ||
|
||
export class MissingTypeError implements Result { | ||
readonly isError = true; | ||
|
||
constructor(private readonly missingTypes: Type[]) { } | ||
constructor(private readonly own: string[], private readonly injected: string[]) { } | ||
|
||
getMessage() { | ||
return `The call to injectComponent is missing prop types. It should be typed as: injectComponent<${this.missingTypes.map(t => t.toString()).join(', ')}> `; | ||
console.log(this.getGenerics()); | ||
return `The call to injectComponent is missing prop types. It should be typed as: injectComponent<${this.getGenerics()}> `; | ||
} | ||
|
||
private getGenerics(): string { | ||
const own = this.own[0]; | ||
const injected = this.injected[0]; | ||
return own && injected ? `${own}, ${injected}` : own; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters