Skip to content

Commit

Permalink
fix: rename EslintConfig to PracticeConfig; return always PracticeCon…
Browse files Browse the repository at this point in the history
…fig in getOverridenPractice()
  • Loading branch information
adelkahomolova committed Oct 3, 2019
1 parent 713372c commit 81e00cd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
"@types/rimraf": "^2.0.2",
"@types/semver": "^6.0.1",
"@types/toposort": "^2.0.3",
"@types/update-notifier": "^2.5.0",
"@typescript-eslint/eslint-plugin": "^2.2.0",
"@typescript-eslint/parser": "^2.2.0",
"@types/update-notifier": "^2.5.0",
"codecov": "^3.5.0",
"eslint-config-prettier": "^6.3.0",
"eslint-plugin-prettier": "^3.1.0",
Expand Down
11 changes: 8 additions & 3 deletions src/contexts/ConfigProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import yaml from 'js-yaml';
import _ from 'lodash';
import { IFileInspector } from '../inspectors/IFileInspector';
import { Types } from '../types';
import { IConfigProvider, Config, EslintConfig } from './IConfigProvider';
import { IConfigProvider, Config, PracticeConfig } from './IConfigProvider';
import { PracticeImpact } from '../model';

@injectable()
Expand Down Expand Up @@ -39,11 +39,16 @@ export class ConfigProvider implements IConfigProvider {
this.config = parsedContent;
}

getOverridenPractice(practiceId: string): PracticeImpact | EslintConfig {
getOverridenPractice(practiceId: string): PracticeConfig {
const practiceConfig = _.get(this.config, ['practices', practiceId]);
if (typeof practiceConfig !== 'string' && practiceConfig !== undefined) {
return practiceConfig.impact;
}
return practiceConfig;

const impactInConfig = {
impact: practiceConfig,
};

return impactInConfig;
}
}
6 changes: 3 additions & 3 deletions src/contexts/IConfigProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import { PracticeImpact } from '../model';

export interface IConfigProvider {
init(): Promise<void>;
getOverridenPractice(practiceId: string): PracticeImpact | EslintConfig;
getOverridenPractice(practiceId: string): PracticeConfig;
}

export interface Config {
practices?: {
[key in Practices]?: PracticeImpact | EslintConfig;
[key in Practices]?: PracticeImpact | PracticeConfig;
};
tokens?: {
[key in Service]: string;
};
}

export interface EslintConfig {
export interface PracticeConfig {
eslintIgnore?: string[];
useEslintrc?: boolean;
impact?: string;
Expand Down
4 changes: 2 additions & 2 deletions src/contexts/practice/PracticeContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IGitInspector } from '../../inspectors/IGitInspector';
import { IIssueTrackingInspector } from '../../inspectors/IIssueTrackingInspector';
import { IPackageInspector } from '../../inspectors/IPackageInspector';
import { PracticeImpact, ProjectComponent } from '../../model';
import { EslintConfig } from '../IConfigProvider';
import { PracticeConfig } from '../IConfigProvider';

export interface PracticeContext {
projectComponent: ProjectComponent;
Expand All @@ -13,5 +13,5 @@ export interface PracticeContext {
issueTrackingInspector: IIssueTrackingInspector | undefined;
collaborationInspector: ICollaborationInspector | undefined;
fileInspector: IFileInspector | undefined;
config?: EslintConfig | PracticeImpact;
config?: PracticeConfig | PracticeImpact;
}
7 changes: 1 addition & 6 deletions src/scanner/Scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,7 @@ export class Scanner {
const reportString = this.reporter.report(
relevantPractices.map((p) => {
const config = p.componentContext.configProvider.getOverridenPractice(p.practice.getMetadata().id);

if (typeof config === 'string') {
impact = config;
} else if (config && 'impact' in config) {
impact = config.impact;
}
impact = config.impact;

return {
practice: {
Expand Down

0 comments on commit 81e00cd

Please sign in to comment.