-
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.
This is the third and last part of the refactor to the eslint plugin. With this part, we can finally delete the ASTFunctions file which was very long and a bit complicated to understand.
- Loading branch information
Showing
7 changed files
with
46 additions
and
41 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
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
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { TSESTree } from '@typescript-eslint/types'; | ||
|
||
export class Parameter { | ||
constructor(public readonly node: TSESTree.Parameter) {} | ||
|
||
get name() { | ||
return (this.node as TSESTree.Identifier).name; | ||
} | ||
} |
34 changes: 0 additions & 34 deletions
34
packages/eslint-plugin-obsidian/rules/unresolvedProviderDependencies/ASTFunctions.ts
This file was deleted.
Oops, something went wrong.
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
6 changes: 4 additions & 2 deletions
6
packages/eslint-plugin-obsidian/rules/unresolvedProviderDependencies/graphHandler.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
22 changes: 22 additions & 0 deletions
22
.../eslint-plugin-obsidian/rules/unresolvedProviderDependencies/resolvedDependencyChecker.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { Clazz } from '../dto/class'; | ||
import type { Parameter } from '../dto/parameter'; | ||
|
||
type DependencyCheckResult = { error: boolean; param?: string; node?: any }; | ||
|
||
export class ResolvedDependencyChecker { | ||
|
||
public check(clazz: Clazz, dependencies: string[]): DependencyCheckResult { | ||
const unresolvedDependency = clazz | ||
.getDecoratedMethods('Provides') | ||
.flatMap((method) => method.parameters) | ||
.find((provider) => !dependencies.includes(provider.name)); | ||
return this.getResult(unresolvedDependency); | ||
} | ||
|
||
private getResult(unresolvedDependency: Parameter | undefined): DependencyCheckResult { | ||
if (unresolvedDependency) { | ||
return { error: true, param: unresolvedDependency.name, node: unresolvedDependency.node }; | ||
} | ||
return { error: false }; | ||
} | ||
} |