diff --git a/app/scripts/modules/amazon/src/loadBalancer/details/LoadBalancerActions.tsx b/app/scripts/modules/amazon/src/loadBalancer/details/LoadBalancerActions.tsx index 60abecbf18f..b40ba164ffd 100644 --- a/app/scripts/modules/amazon/src/loadBalancer/details/LoadBalancerActions.tsx +++ b/app/scripts/modules/amazon/src/loadBalancer/details/LoadBalancerActions.tsx @@ -28,7 +28,7 @@ export class LoadBalancerActions extends React.Component = angular2react( - 'scalingPolicySummary', - new ScalingPolicyDetailsSummary(), - this.$injectorProxy, - ) as any; - public SubnetSelectField: React.ComponentClass = angular2react( - 'subnetSelectFieldWrapper', - new SubnetSelectFieldWrapperComponent(), - this.$injectorProxy, - ) as any; + public ScalingPolicySummary: React.ComponentClass = angular2react('scalingPolicySummary', new ScalingPolicyDetailsSummary(), this.$injectorProxy) as any; + public SubnetSelectField: React.ComponentClass = angular2react('subnetSelectFieldWrapper', new SubnetSelectFieldWrapperComponent(), this.$injectorProxy) as any; public initialize($injector: IInjectorService) { const realInjector: { [key: string]: Function } = $injector as any; @@ -30,7 +23,7 @@ export class AwsNgReactInjector extends ReactInject { Object.keys($injector) .filter(key => typeof realInjector[key] === 'function') - .forEach(key => (proxyInjector[key] = realInjector[key].bind(realInjector))); + .forEach(key => proxyInjector[key] = realInjector[key].bind(realInjector)); } } diff --git a/app/scripts/modules/amazon/src/reactShims/aws.react.injector.ts b/app/scripts/modules/amazon/src/reactShims/aws.react.injector.ts index de6477214d6..420d10c46e7 100644 --- a/app/scripts/modules/amazon/src/reactShims/aws.react.injector.ts +++ b/app/scripts/modules/amazon/src/reactShims/aws.react.injector.ts @@ -7,25 +7,15 @@ import { AwsServerGroupTransformer } from '../serverGroup/serverGroup.transforme import { AwsLoadBalancerTransformer } from '../loadBalancer/loadBalancer.transformer'; import { VpcReader } from '../vpc/vpc.read.service'; +// prettier-ignore export class AwsReactInject extends ReactInject { - public get amazonCertificateReader() { - return this.$injector.get('amazonCertificateReader') as AmazonCertificateReader; - } - public get autoScalingProcessService() { - return this.$injector.get('autoScalingProcessService') as any; - } - public get awsLoadBalancerTransformer() { - return this.$injector.get('awsLoadBalancerTransformer') as AwsLoadBalancerTransformer; - } - public get awsServerGroupCommandBuilder() { - return this.$injector.get('awsServerGroupCommandBuilder') as any; - } - public get awsServerGroupTransformer() { - return this.$injector.get('awsServerGroupTransformer') as AwsServerGroupTransformer; - } - public get vpcReader() { - return this.$injector.get('vpcReader') as VpcReader; - } + public get amazonCertificateReader() { return this.$injector.get('amazonCertificateReader') as AmazonCertificateReader; } + public get autoScalingProcessService() { return this.$injector.get('autoScalingProcessService') as any; } + public get awsLoadBalancerTransformer() { return this.$injector.get('awsLoadBalancerTransformer') as AwsLoadBalancerTransformer; } + public get awsServerGroupCommandBuilder() { return this.$injector.get('awsServerGroupCommandBuilder') as any; } + public get awsServerGroupTransformer() { return this.$injector.get('awsServerGroupTransformer') as AwsServerGroupTransformer; } + public get vpcReader() { return this.$injector.get('vpcReader') as VpcReader; } + public initialize($injector: IInjectorService) { this.$injector = $injector; } diff --git a/app/scripts/modules/core/src/api/api.service.ts b/app/scripts/modules/core/src/api/api.service.ts index 3a5b5267493..86c9046ecd6 100644 --- a/app/scripts/modules/core/src/api/api.service.ts +++ b/app/scripts/modules/core/src/api/api.service.ts @@ -5,7 +5,7 @@ import { } from '../authentication/authentication.initializer.service'; import { SETTINGS } from 'core/config/settings'; -interface DefaultParams { +interface IDefaultParams { timeout: number; headers: { [key: string]: string }; } @@ -26,7 +26,7 @@ export interface IRequestBuilder { export class Api { private gateUrl: string; - private defaultParams: DefaultParams; + private defaultParams: IDefaultParams; constructor( private $q: IQService, diff --git a/app/scripts/modules/core/src/application/service/applicationDataSource.ts b/app/scripts/modules/core/src/application/service/applicationDataSource.ts index 271464315db..af838d9ccf1 100644 --- a/app/scripts/modules/core/src/application/service/applicationDataSource.ts +++ b/app/scripts/modules/core/src/application/service/applicationDataSource.ts @@ -122,7 +122,6 @@ export interface IDataSourceConfig { * (Optional) The application has potentially two default fields for each provider: region and credentials. These fields will * only have a value if every data source that contributes values has just one unique value for each provider. Useful * for setting initial values in modal dialogs when creating new server groups, load balancers, etc. - * If the data source should contribute to the application's default region or credentials, this field should be set * to the field name that represents the provider on each data item. */ diff --git a/app/scripts/modules/core/src/cloudProvider/providerSelection/providerSelection.service.spec.ts b/app/scripts/modules/core/src/cloudProvider/providerSelection/providerSelection.service.spec.ts index be589e6b30a..14fda3cb9c7 100644 --- a/app/scripts/modules/core/src/cloudProvider/providerSelection/providerSelection.service.spec.ts +++ b/app/scripts/modules/core/src/cloudProvider/providerSelection/providerSelection.service.spec.ts @@ -3,13 +3,11 @@ import { Application } from 'core/application/application.model'; import { mock, IQService, IScope, IRootScopeService } from 'angular'; import { IModalService } from 'angular-ui-bootstrap'; -import { ACCOUNT_SERVICE, AccountService } from 'core/account/account.service'; +import { ACCOUNT_SERVICE, AccountService, IAccountDetails } from 'core/account/account.service'; import { CLOUD_PROVIDER_REGISTRY, CloudProviderRegistry } from 'core/cloudProvider/cloudProvider.registry'; import { PROVIDER_SELECTION_SERVICE, ProviderSelectionService } from './providerSelection.service'; import { SETTINGS } from 'core/config/settings'; -import { IAccountDetails } from 'core/account/account.service'; - function fakeAccount(provider: string): IAccountDetails { return { cloudProvider: provider, diff --git a/app/scripts/modules/core/src/cloudProvider/providerSelection/providerSelection.service.ts b/app/scripts/modules/core/src/cloudProvider/providerSelection/providerSelection.service.ts index 1c936c7749f..9270a3ac395 100644 --- a/app/scripts/modules/core/src/cloudProvider/providerSelection/providerSelection.service.ts +++ b/app/scripts/modules/core/src/cloudProvider/providerSelection/providerSelection.service.ts @@ -2,9 +2,7 @@ import { IModalService } from 'angular-ui-bootstrap'; import { IPromise, module, IQService } from 'angular'; import { uniq } from 'lodash'; -import { IAccountDetails } from 'core/account/account.service'; - -import { ACCOUNT_SERVICE, AccountService } from 'core/account/account.service'; +import { IAccountDetails, ACCOUNT_SERVICE, AccountService } from 'core/account/account.service'; import { Application } from 'core/application/application.model'; import { CLOUD_PROVIDER_REGISTRY, diff --git a/app/scripts/modules/core/src/diffs/commitHistory.component.ts b/app/scripts/modules/core/src/diffs/commitHistory.component.ts index 8cd898d4b5d..b2b7d2eda43 100644 --- a/app/scripts/modules/core/src/diffs/commitHistory.component.ts +++ b/app/scripts/modules/core/src/diffs/commitHistory.component.ts @@ -1,6 +1,4 @@ -import { module } from 'angular'; - -import { IComponentOptions } from 'angular'; +import { module, IComponentOptions } from 'angular'; export interface ICommit { authorDisplayName: string; diff --git a/app/scripts/modules/core/src/diffs/viewChangesLink.component.ts b/app/scripts/modules/core/src/diffs/viewChangesLink.component.ts index 0580012d779..dd4fada92fe 100644 --- a/app/scripts/modules/core/src/diffs/viewChangesLink.component.ts +++ b/app/scripts/modules/core/src/diffs/viewChangesLink.component.ts @@ -3,8 +3,7 @@ import { IController, IComponentOptions, module } from 'angular'; import { IModalInstanceService, IModalService } from 'angular-ui-bootstrap'; import { IBuildDiffInfo, ICreationMetadata, ICreationMetadataTag, IJenkinsInfo } from 'core/domain'; -import { ICommit } from './commitHistory.component'; -import { COMMIT_HISTORY_COMPONENT } from './commitHistory.component'; +import { ICommit, COMMIT_HISTORY_COMPONENT } from './commitHistory.component'; import { EXECUTION_SERVICE, ExecutionService } from 'core/pipeline/service/execution.service'; import { JAR_DIFF_COMPONENT, IJarDiff } from './jarDiff.component'; diff --git a/app/scripts/modules/core/src/domain/IJobConfig.ts b/app/scripts/modules/core/src/domain/IJobConfig.ts index a11eb8c8fd3..335d7b36045 100644 --- a/app/scripts/modules/core/src/domain/IJobConfig.ts +++ b/app/scripts/modules/core/src/domain/IJobConfig.ts @@ -1,4 +1,4 @@ -export interface ParameterDefinitionList { +export interface IParameterDefinitionList { defaultValue: string; description?: string; name: string; @@ -10,6 +10,6 @@ export interface IJobConfig { description: string; displayName: string; name: string; - parameterDefinitionList: ParameterDefinitionList[]; + parameterDefinitionList: IParameterDefinitionList[]; url: string; } diff --git a/app/scripts/modules/core/src/forms/numberList/numberList.component.spec.ts b/app/scripts/modules/core/src/forms/numberList/numberList.component.spec.ts index 795e0d548ea..4fc9774b234 100644 --- a/app/scripts/modules/core/src/forms/numberList/numberList.component.spec.ts +++ b/app/scripts/modules/core/src/forms/numberList/numberList.component.spec.ts @@ -1,5 +1,5 @@ import { mock } from 'angular'; -import { NUMBER_LIST_COMPONENT, NumberListConstraints } from './numberList.component'; +import { NUMBER_LIST_COMPONENT, INumberListConstraints } from './numberList.component'; describe('Component: numberList', () => { let $compile: ng.ICompileService, @@ -7,7 +7,7 @@ describe('Component: numberList', () => { stringModel: string, $scope: ng.IScope, elem: any, - constraints: NumberListConstraints, + constraints: INumberListConstraints, onChange: () => any; beforeEach(mock.module(NUMBER_LIST_COMPONENT)); diff --git a/app/scripts/modules/core/src/forms/numberList/numberList.component.ts b/app/scripts/modules/core/src/forms/numberList/numberList.component.ts index a68f781a20c..246771c46d2 100644 --- a/app/scripts/modules/core/src/forms/numberList/numberList.component.ts +++ b/app/scripts/modules/core/src/forms/numberList/numberList.component.ts @@ -1,14 +1,14 @@ import { IController, IComponentOptions, module } from 'angular'; import './numberList.component.less'; -export interface NumberListConstraints { +export interface INumberListConstraints { min: number; max: number; } export class NumberListController implements IController { public model: number[] | string; - public constraints: NumberListConstraints; + public constraints: INumberListConstraints; public label: string; public backingModel: number[]; public parameterized: boolean; diff --git a/app/scripts/modules/core/src/instance/instance.states.ts b/app/scripts/modules/core/src/instance/instance.states.ts index d41a4f75b7e..4924eb3f3a9 100644 --- a/app/scripts/modules/core/src/instance/instance.states.ts +++ b/app/scripts/modules/core/src/instance/instance.states.ts @@ -1,9 +1,8 @@ import { module } from 'angular'; import { StateParams } from '@uirouter/angularjs'; -import { APPLICATION_STATE_PROVIDER, ApplicationStateProvider } from 'core/application'; +import { APPLICATION_STATE_PROVIDER, ApplicationStateProvider, Application } from 'core/application'; import { INestedState, STATE_CONFIG_PROVIDER, StateConfigProvider } from 'core/navigation'; -import { Application } from 'core/application'; import { SkinService } from 'core/cloudProvider'; import { ApplicationModelBuilder } from '../application/applicationModel.builder'; diff --git a/app/scripts/modules/core/src/loadBalancer/filter/loadBalancer.filter.service.ts b/app/scripts/modules/core/src/loadBalancer/filter/loadBalancer.filter.service.ts index e4f91e2f222..54f919c0b39 100644 --- a/app/scripts/modules/core/src/loadBalancer/filter/loadBalancer.filter.service.ts +++ b/app/scripts/modules/core/src/loadBalancer/filter/loadBalancer.filter.service.ts @@ -1,8 +1,7 @@ import { ILogService, module } from 'angular'; import { chain, find, forOwn, groupBy, includes, intersection, map, some, sortBy, values, without } from 'lodash'; -import { Debounce } from 'lodash-decorators'; +import { Debounce, BindAll } from 'lodash-decorators'; import { Subject } from 'rxjs'; -import { BindAll } from 'lodash-decorators'; import { Application } from 'core/application/application.model'; import { ILoadBalancer, ILoadBalancerGroup, IInstance, IServerGroup } from 'core/domain'; diff --git a/app/scripts/modules/core/src/modal/index.ts b/app/scripts/modules/core/src/modal/index.ts index 0eb05ee8aaa..f0bf3b07c4c 100644 --- a/app/scripts/modules/core/src/modal/index.ts +++ b/app/scripts/modules/core/src/modal/index.ts @@ -4,8 +4,8 @@ export * from './wizard/WizardModal'; export * from './wizard/WizardPage'; export { V2_MODAL_WIZARD_COMPONENT, V2ModalWizard } from './wizard/v2modalWizard.component'; export { - WizardPage, + IWizardPage, V2_MODAL_WIZARD_SERVICE, V2ModalWizardService, - WizardPageState, + IWizardPageState, } from './wizard/v2modalWizard.service'; diff --git a/app/scripts/modules/core/src/modal/wizard/v2modalWizard.service.ts b/app/scripts/modules/core/src/modal/wizard/v2modalWizard.service.ts index 3549debd3e1..d98bc30030f 100644 --- a/app/scripts/modules/core/src/modal/wizard/v2modalWizard.service.ts +++ b/app/scripts/modules/core/src/modal/wizard/v2modalWizard.service.ts @@ -1,7 +1,7 @@ import { module } from 'angular'; import { SCROLL_TO_SERVICE, ScrollToService } from 'core/utils/scrollTo/scrollTo.service'; -export interface WizardPageState { +export interface IWizardPageState { done: boolean; blocked: boolean; rendered: boolean; @@ -11,16 +11,16 @@ export interface WizardPageState { required: boolean; } -export interface WizardPage { - state: WizardPageState; +export interface IWizardPage { + state: IWizardPageState; key: string; label: string; } export class V2ModalWizardService { - public renderedPages: WizardPage[] = []; - public pageRegistry: WizardPage[] = []; - public currentPage: WizardPage; + public renderedPages: IWizardPage[] = []; + public pageRegistry: IWizardPage[] = []; + public currentPage: IWizardPage; public heading: string; public constructor(private scrollToService: ScrollToService) {} @@ -29,7 +29,7 @@ export class V2ModalWizardService { this.heading = heading; } - public getPage(key: string): WizardPage { + public getPage(key: string): IWizardPage { return this.pageRegistry.find(p => p.key === key); } @@ -49,7 +49,7 @@ export class V2ModalWizardService { this.getPage(key).state.done = false; } - public setCurrentPage(page: WizardPage, skipScroll?: boolean): void { + public setCurrentPage(page: IWizardPage, skipScroll?: boolean): void { this.pageRegistry.forEach(test => (test.state.current = test === page)); this.currentPage = page; this.markClean(page.key); @@ -63,7 +63,7 @@ export class V2ModalWizardService { } } - public registerPage(key: string, label: string, state?: WizardPageState): void { + public registerPage(key: string, label: string, state?: IWizardPageState): void { state = state || { done: false, blocked: true, @@ -78,7 +78,7 @@ export class V2ModalWizardService { } public renderPages(): void { - const renderedPages: WizardPage[] = this.pageRegistry.filter(page => page.state.rendered); + const renderedPages: IWizardPage[] = this.pageRegistry.filter(page => page.state.rendered); this.renderedPages = renderedPages; if (renderedPages.length === 1) { this.setCurrentPage(renderedPages[0]); diff --git a/app/scripts/modules/core/src/modal/wizard/v2wizardPage.component.ts b/app/scripts/modules/core/src/modal/wizard/v2wizardPage.component.ts index b1dde7372ab..726e031e2d4 100644 --- a/app/scripts/modules/core/src/modal/wizard/v2wizardPage.component.ts +++ b/app/scripts/modules/core/src/modal/wizard/v2wizardPage.component.ts @@ -16,7 +16,7 @@ import { V2_MODAL_WIZARD_SERVICE } from './v2modalWizard.service'; * scrolled into view */ -export interface WizardPageState { +export interface IWizardPageState { rendered: boolean; done: boolean; dirty: boolean; @@ -68,7 +68,7 @@ export class WizardPageController implements IController { /** * Internal state of the page, initialized based on other public fields */ - public state: WizardPageState; + public state: IWizardPageState; public constructor(private $scope: ng.IScope, private v2modalWizardService: any) { 'ngInject'; diff --git a/app/scripts/modules/core/src/navigation/urlBuilder.service.ts b/app/scripts/modules/core/src/navigation/urlBuilder.service.ts index 85b3ec1ad76..cc7805e34e4 100644 --- a/app/scripts/modules/core/src/navigation/urlBuilder.service.ts +++ b/app/scripts/modules/core/src/navigation/urlBuilder.service.ts @@ -42,7 +42,7 @@ interface IClusterFilter { } class UrlBuilderUtils { - private static forEachSorted(obj: any, iterator: Function, context: any = undefined): void { + private static forEachSorted(obj: any, iterator: Function, context?: any): void { const keys: string[] = Object.keys(obj).sort(); keys.forEach((key: string) => { iterator.call(context, obj[key], key); diff --git a/app/scripts/modules/core/src/pagerDuty/PageModal.tsx b/app/scripts/modules/core/src/pagerDuty/PageModal.tsx index ed86f25267b..ffa00d5d308 100644 --- a/app/scripts/modules/core/src/pagerDuty/PageModal.tsx +++ b/app/scripts/modules/core/src/pagerDuty/PageModal.tsx @@ -1,7 +1,6 @@ import { IDeferred } from 'angular'; import { IModalServiceInstance } from 'angular-ui-bootstrap'; import * as React from 'react'; -import { MouseEvent } from 'react'; import { Button, Modal } from 'react-bootstrap'; import { get } from 'lodash'; import { BindAll } from 'lodash-decorators'; @@ -75,7 +74,7 @@ export class PageModal extends React.Component }; } - public close(evt?: MouseEvent): void { + public close(evt?: React.MouseEvent): void { evt && evt.stopPropagation(); this.setState(this.getDefaultState(this.props)); this.props.closeCallback(false); diff --git a/app/scripts/modules/core/src/pagerDuty/Pager.tsx b/app/scripts/modules/core/src/pagerDuty/Pager.tsx index 2280ada48b8..596c17f0198 100644 --- a/app/scripts/modules/core/src/pagerDuty/Pager.tsx +++ b/app/scripts/modules/core/src/pagerDuty/Pager.tsx @@ -31,14 +31,16 @@ export interface IUserDisplay { url: string; } -export type UserList = { [level: number]: IUserDisplay[] }; -export type OnCallsByService = { - users?: UserList; +export interface IUserList { + [level: number]: IUserDisplay[]; +} +export interface IOnCallsByService { + users?: IUserList; applications: IApplicationSummary[]; last: moment.Moment; service: IPagerDutyService; searchString: string; -}; +} export interface IPagerProps {} @@ -51,7 +53,7 @@ export interface IPagerState { selectedKeys: Map; sortBy: string; sortDirection: SortDirectionType; - sortedData: OnCallsByService[]; + sortedData: IOnCallsByService[]; } const paddingStyle = { paddingTop: '15px', paddingBottom: '15px' }; @@ -82,7 +84,7 @@ export class Pager extends React.Component { defaultHeight: 50, fixedWidth: true, }); - private allData: OnCallsByService[] = []; + private allData: IOnCallsByService[] = []; private searchApi = new SearchApi(); constructor(props: IPagerProps) { @@ -117,7 +119,7 @@ export class Pager extends React.Component { }); } - private sortByFunction(a: OnCallsByService, b: OnCallsByService, sortBy: string): number { + private sortByFunction(a: IOnCallsByService, b: IOnCallsByService, sortBy: string): number { if (sortBy === 'service') { return a.service.name.localeCompare(b.service.name); } @@ -145,7 +147,7 @@ export class Pager extends React.Component { } } - public sortList(sortedData: OnCallsByService[], sortBy: string, sortDirection: SortDirectionType): void { + public sortList(sortedData: IOnCallsByService[], sortBy: string, sortDirection: SortDirectionType): void { if (sortBy) { sortedData.sort((a, b) => this.sortByFunction(a, b, sortBy)); if (sortDirection === SortDirection.DESC) { @@ -223,11 +225,11 @@ export class Pager extends React.Component { applications: IApplicationSummary[], onCalls: { [id: string]: IOnCall[] }, services: IPagerDutyService[], - ): OnCallsByService[] { + ): IOnCallsByService[] { return services .map(service => { // connect the users attached to the service by way of escalation policy - let users: UserList; + let users: IUserList; const searchTokens: string[] = [service.name]; const levels = onCalls[service.policy]; if (levels) { @@ -343,7 +345,7 @@ export class Pager extends React.Component { } private onCallRenderer(data: TableCellProps): React.ReactNode { - const onCalls: UserList = data.cellData; + const onCalls: IUserList = data.cellData; return ( { @@ -120,7 +120,7 @@ describe('Travis Stage Controller', () => { }); it('gets job config and adds parameters to scope, setting defaults if present and not overridden', () => { - const params: ParameterDefinitionList[] = [ + const params: IParameterDefinitionList[] = [ { name: 'overridden', defaultValue: 'z' }, { name: 'notSet', defaultValue: 'a' }, { name: 'noDefault', defaultValue: null }, diff --git a/app/scripts/modules/core/src/pipeline/config/stages/travis/travisStage.ts b/app/scripts/modules/core/src/pipeline/config/stages/travis/travisStage.ts index deb17f6e5aa..616504a95de 100644 --- a/app/scripts/modules/core/src/pipeline/config/stages/travis/travisStage.ts +++ b/app/scripts/modules/core/src/pipeline/config/stages/travis/travisStage.ts @@ -5,7 +5,7 @@ import * as moment from 'moment'; import { SETTINGS } from 'core/config/settings'; import { IGOR_SERVICE, IgorService, BuildServiceType } from 'core/ci/igor.service'; -import { IJobConfig, ParameterDefinitionList, IStage } from 'core/domain'; +import { IJobConfig, IParameterDefinitionList, IStage } from 'core/domain'; import { TravisExecutionLabel } from './TravisExecutionLabel'; export interface ITravisStageViewState { @@ -31,7 +31,7 @@ export class TravisStage implements IController { public userSuppliedParameters: any; public masters: string[]; public jobs: string[]; - public jobParams: ParameterDefinitionList[]; + public jobParams: IParameterDefinitionList[]; public filterLimit = 100; private filterThreshold = 500; @@ -119,7 +119,7 @@ export class TravisStage implements IController { this.jobParams = config.parameterDefinitionList; this.userSuppliedParameters = stage.parameters; this.useDefaultParameters = {}; - const params = this.jobParams || []; + const params = this.jobParams || []; params.forEach((property: any) => { if (!(property.name in stage.parameters) && property.defaultValue !== null) { this.useDefaultParameters[property.name] = true; diff --git a/app/scripts/modules/core/src/pipeline/create/CreatePipelineModal.tsx b/app/scripts/modules/core/src/pipeline/create/CreatePipelineModal.tsx index e2e5469a164..e88edb39e1e 100644 --- a/app/scripts/modules/core/src/pipeline/create/CreatePipelineModal.tsx +++ b/app/scripts/modules/core/src/pipeline/create/CreatePipelineModal.tsx @@ -1,12 +1,10 @@ import * as React from 'react'; -import { MouseEvent } from 'react'; import { Button, Modal } from 'react-bootstrap'; import Select, { Option } from 'react-select'; -import { BindAll } from 'lodash-decorators'; +import { BindAll, Debounce } from 'lodash-decorators'; import { $log } from 'ngimport'; import { IHttpPromiseCallbackArg } from 'angular'; import { cloneDeep, get, uniqBy } from 'lodash'; -import { Debounce } from 'lodash-decorators'; import { Application } from 'core/application/application.model'; import { IPipeline } from 'core/domain/IPipeline'; @@ -190,7 +188,7 @@ export class CreatePipelineModal extends React.Component): void { + public close(evt?: React.MouseEvent): void { evt && evt.stopPropagation(); this.setState(this.getDefaultState()); this.props.showCallback(false); diff --git a/app/scripts/modules/core/src/presentation/HoverablePopover.tsx b/app/scripts/modules/core/src/presentation/HoverablePopover.tsx index d460b84aa98..5bd4f5413d5 100644 --- a/app/scripts/modules/core/src/presentation/HoverablePopover.tsx +++ b/app/scripts/modules/core/src/presentation/HoverablePopover.tsx @@ -1,6 +1,5 @@ import * as React from 'react'; import * as ReactDOM from 'react-dom'; -import { HTMLProps } from 'react'; import { Overlay, Popover, PopoverProps } from 'react-bootstrap'; import { Observable, Subject } from 'rxjs'; import { BindAll } from 'lodash-decorators'; @@ -13,7 +12,7 @@ export interface IHoverablePopoverContentsProps extends IHoverablePopoverProps { hidePopover: () => void; } -export interface IHoverablePopoverProps extends HTMLProps { +export interface IHoverablePopoverProps extends React.HTMLProps { /** The popover contents (simple mode) */ value?: string; /** The popover contents (advanced mode) */ diff --git a/app/scripts/modules/core/src/presentation/anyFieldFilter/anyField.filter.ts b/app/scripts/modules/core/src/presentation/anyFieldFilter/anyField.filter.ts index 5c4fad83d66..675c7d2a6d7 100644 --- a/app/scripts/modules/core/src/presentation/anyFieldFilter/anyField.filter.ts +++ b/app/scripts/modules/core/src/presentation/anyFieldFilter/anyField.filter.ts @@ -19,8 +19,7 @@ export function anyFieldFilter() { let itemMatches = false; const keys: any[] = Object.keys(props); - for (let i = 0; i < keys.length; i++) { - const prop: any = keys[i]; + for (const prop of keys) { const text: string = (props)[prop].toLowerCase(); if ( item[prop] && diff --git a/app/scripts/modules/core/src/presentation/autoScroll/autoScroll.directive.ts b/app/scripts/modules/core/src/presentation/autoScroll/autoScroll.directive.ts index 29e292c42f6..afbc5c3e11e 100644 --- a/app/scripts/modules/core/src/presentation/autoScroll/autoScroll.directive.ts +++ b/app/scripts/modules/core/src/presentation/autoScroll/autoScroll.directive.ts @@ -3,7 +3,7 @@ import { Subject } from 'rxjs'; import { DirectiveFactory } from 'core/utils/tsDecorators/directiveFactoryDecorator'; -export interface AutoScrollAttrs extends IAttributes { +export interface IAutoScrollAttrs extends IAttributes { autoScrollEnabled: string; autoScroll: string; } @@ -14,7 +14,7 @@ export class AutoScrollController implements IController { public onScroll: (event: Event) => void; public scrollToTop: Subject; public $element: JQuery; - public $attrs: AutoScrollAttrs; + public $attrs: IAutoScrollAttrs; public $scope: IScope; private scrollableContainer: JQuery; @@ -68,7 +68,7 @@ class AutoScrollDirective implements IDirective { scrollToTop: '=?', }; - public link($scope: IScope, $element: JQuery, $attrs: AutoScrollAttrs, ctrl: AutoScrollController) { + public link($scope: IScope, $element: JQuery, $attrs: IAutoScrollAttrs, ctrl: AutoScrollController) { ctrl.$scope = $scope; ctrl.$element = $element; ctrl.$attrs = $attrs; diff --git a/app/scripts/modules/core/src/presentation/forms/components/ExpressionInput.tsx b/app/scripts/modules/core/src/presentation/forms/components/ExpressionInput.tsx index d10f18c0cea..ba663a061a6 100644 --- a/app/scripts/modules/core/src/presentation/forms/components/ExpressionInput.tsx +++ b/app/scripts/modules/core/src/presentation/forms/components/ExpressionInput.tsx @@ -5,7 +5,6 @@ import { truncate } from 'lodash'; import { Markdown } from 'core/presentation/Markdown'; -import '../spel2js.templateParser'; import { Modal } from 'react-bootstrap'; export interface IExpressionInputProps { diff --git a/app/scripts/modules/core/src/presentation/forms/spel2js.templateParser.ts b/app/scripts/modules/core/src/presentation/forms/spel2js.templateParser.ts index e8c38697f0a..cc76b5237f5 100644 --- a/app/scripts/modules/core/src/presentation/forms/spel2js.templateParser.ts +++ b/app/scripts/modules/core/src/presentation/forms/spel2js.templateParser.ts @@ -1,7 +1,6 @@ import * as spel2js from 'spel2js'; -import { SpelExpression } from 'spel2js'; -export function parseSpelExpressions(template: string): SpelExpression[] { +export function parseSpelExpressions(template: string): spel2js.SpelExpression[] { const spelExpressions = new TemplateAwareExpressionParser().parseExpressions(template); // A Monkey patch which adds the current context when an exception occurs @@ -109,8 +108,8 @@ class TemplateAwareExpressionParser { * @return the parsed expressions * @throws ParseException when the expressions cannot be parsed */ - public parseExpressions(expressionString: string): SpelExpression[] { - const expressions: SpelExpression[] = []; + public parseExpressions(expressionString: string): spel2js.SpelExpression[] { + const expressions: spel2js.SpelExpression[] = []; const prefix = '${'; const suffix = '}'; diff --git a/app/scripts/modules/core/src/reactShims/AngularJSAdapter.tsx b/app/scripts/modules/core/src/reactShims/AngularJSAdapter.tsx index f397d6dc4d3..5d0adeb0d05 100644 --- a/app/scripts/modules/core/src/reactShims/AngularJSAdapter.tsx +++ b/app/scripts/modules/core/src/reactShims/AngularJSAdapter.tsx @@ -1,6 +1,5 @@ import * as React from 'react'; -import * as angular from 'angular'; -import { IScope } from 'angular'; +import { IScope, element } from 'angular'; import { $compile, $controller, $templateRequest } from 'ngimport'; export interface IRenderAngularJSBaseProps extends React.HTMLProps { @@ -52,7 +51,7 @@ export class AngularJSAdapter extends React.Component { controllerAs?: string, locals?: object, ) { - const $element = angular.element(ref); + const $element = element(ref); const parentScope = $element.scope(); const $scope = (this.$scope = parentScope.$new()); $scope.props = this.props; diff --git a/app/scripts/modules/core/src/reactShims/ngReact.ts b/app/scripts/modules/core/src/reactShims/ngReact.ts index 54304cc805e..34a9e24de0f 100644 --- a/app/scripts/modules/core/src/reactShims/ngReact.ts +++ b/app/scripts/modules/core/src/reactShims/ngReact.ts @@ -6,7 +6,7 @@ import { AccountSelectFieldWrapperComponent } from '../account/accountSelectFiel import { AddEntityTagLinksWrapperComponent } from 'core/entityTag/addEntityTagLinks.component'; import { ButtonBusyIndicatorComponent } from '../forms/buttonBusyIndicator/buttonBusyIndicator.component'; import { CopyToClipboardComponent } from '../utils/clipboard/copyToClipboard.component'; -import { DiffViewProps } from '../pipeline/config/actions/history/DiffView'; +import { IDiffViewProps } from '../pipeline/config/actions/history/DiffView'; import { EntitySourceComponent } from 'core/entityTag/entitySource.component'; import { HelpFieldWrapperComponent } from '../help/helpField.component'; import { IAccountSelectFieldProps } from 'core/account/AccountSelectField'; @@ -33,92 +33,29 @@ import { ViewChangesLinkWrapper } from 'core/diffs/viewChangesLink.component'; import { ViewScalingActivitiesLink } from 'core/serverGroup/details/scalingActivities/viewScalingActivitiesLink.component'; import { diffViewComponent } from '../pipeline/config/actions/history/diffView.component'; +// prettier-ignore export class NgReactInjector extends ReactInject { public $injectorProxy = {} as IInjectorService; // Reactified components - public AccountSelectField: React.ComponentClass = angular2react( - 'accountSelectFieldWrapper', - new AccountSelectFieldWrapperComponent(), - this.$injectorProxy, - ) as any; - public AddEntityTagLinks: React.ComponentClass = angular2react( - 'addEntityTagLinksWrapper', - new AddEntityTagLinksWrapperComponent(), - this.$injectorProxy, - ) as any; - public ButtonBusyIndicator: React.ComponentClass = angular2react( - 'buttonBusyIndicator', - new ButtonBusyIndicatorComponent(), - this.$injectorProxy, - ) as any; - public CopyToClipboard: React.ComponentClass = angular2react( - 'copyToClipboard', - new CopyToClipboardComponent(), - this.$injectorProxy, - ) as any; - public DiffView: React.ComponentClass = angular2react( - 'diffView', - diffViewComponent, - this.$injectorProxy, - ) as any; - public EntitySource: React.ComponentClass = angular2react( - 'entitySource', - new EntitySourceComponent(), - this.$injectorProxy, - ) as any; - public HelpField: React.ComponentClass = angular2react( - 'helpFieldWrapper', - new HelpFieldWrapperComponent(), - this.$injectorProxy, - ) as any; - public InsightLayout: React.ComponentClass = angular2react( - 'insightLayout', - new InsightLayoutComponent(), - this.$injectorProxy, - ) as any; - public InstanceList: React.ComponentClass = angular2react( - 'instanceList', - { bindings: instanceListBindings }, - this.$injectorProxy, - ) as any; - public LegacySpinner: React.ComponentClass = angular2react( - 'spinnerWrapper', - new SpinnerWrapperComponent(), - this.$injectorProxy, - ) as any; - public RunningTasksTag: React.ComponentClass = angular2react( - 'runningTasksTag', - { bindings: runningTasksTagBindings }, - this.$injectorProxy, - ) as any; - public StageSummaryWrapper: React.ComponentClass = angular2react( - 'stageSummary', - new StageSummaryComponent(), - this.$injectorProxy, - ) as any; - public StepExecutionDetailsWrapper: React.ComponentClass = angular2react( - 'stepExecutionDetails', - new StepExecutionDetailsComponent(), - this.$injectorProxy, - ) as any; - public TaskMonitorWrapper: React.ComponentClass = angular2react( - 'taskMonitorWrapper', - new TaskMonitorWrapperComponent(), - this.$injectorProxy, - ) as any; - public UserMenu: React.ComponentClass<{}> = angular2react('userMenu', {}, this.$injectorProxy) as any; - public ViewChangesLink: React.ComponentClass = angular2react( - 'viewChangesLinkWrapper', - new ViewChangesLinkWrapper(), - this.$injectorProxy, - ) as any; - public ViewScalingActivitiesLink: React.ComponentClass = angular2react( - 'viewScalingActivitiesLink', - new ViewScalingActivitiesLink(), - this.$injectorProxy, - ) as any; - public WhatsNew: React.ComponentClass<{}> = angular2react('whatsNew', {}, this.$injectorProxy) as any; + public AccountSelectField: React.ComponentClass = angular2react('accountSelectFieldWrapper', new AccountSelectFieldWrapperComponent(), this.$injectorProxy) as any; + public AddEntityTagLinks: React.ComponentClass = angular2react('addEntityTagLinksWrapper', new AddEntityTagLinksWrapperComponent(), this.$injectorProxy) as any; + public ButtonBusyIndicator: React.ComponentClass = angular2react('buttonBusyIndicator', new ButtonBusyIndicatorComponent(), this.$injectorProxy) as any; + public CopyToClipboard: React.ComponentClass = angular2react('copyToClipboard', new CopyToClipboardComponent(), this.$injectorProxy) as any; + public DiffView: React.ComponentClass = angular2react('diffView', diffViewComponent, this.$injectorProxy) as any; + public EntitySource: React.ComponentClass = angular2react('entitySource', new EntitySourceComponent(), this.$injectorProxy) as any; + public HelpField: React.ComponentClass = angular2react('helpFieldWrapper', new HelpFieldWrapperComponent(), this.$injectorProxy) as any; + public InsightLayout: React.ComponentClass = angular2react('insightLayout', new InsightLayoutComponent(), this.$injectorProxy) as any; + public InstanceList: React.ComponentClass = angular2react('instanceList', { bindings: instanceListBindings }, this.$injectorProxy) as any; + public LegacySpinner: React.ComponentClass = angular2react('spinnerWrapper', new SpinnerWrapperComponent(), this.$injectorProxy) as any; + public RunningTasksTag: React.ComponentClass = angular2react('runningTasksTag', { bindings: runningTasksTagBindings }, this.$injectorProxy) as any; + public StageSummaryWrapper: React.ComponentClass = angular2react('stageSummary', new StageSummaryComponent(), this.$injectorProxy) as any; + public StepExecutionDetailsWrapper: React.ComponentClass = angular2react('stepExecutionDetails', new StepExecutionDetailsComponent(), this.$injectorProxy) as any; + public TaskMonitorWrapper: React.ComponentClass = angular2react('taskMonitorWrapper', new TaskMonitorWrapperComponent(), this.$injectorProxy) as any; + public UserMenu: React.ComponentClass<{}> = angular2react('userMenu', {}, this.$injectorProxy) as any; + public ViewChangesLink: React.ComponentClass = angular2react('viewChangesLinkWrapper', new ViewChangesLinkWrapper(), this.$injectorProxy) as any; + public ViewScalingActivitiesLink: React.ComponentClass = angular2react('viewScalingActivitiesLink', new ViewScalingActivitiesLink(), this.$injectorProxy) as any; + public WhatsNew: React.ComponentClass<{}> = angular2react('whatsNew', {}, this.$injectorProxy) as any; public initialize($injector: IInjectorService) { const realInjector: { [key: string]: Function } = $injector as any; diff --git a/app/scripts/modules/core/src/reactShims/react.injector.ts b/app/scripts/modules/core/src/reactShims/react.injector.ts index 803e6146ec7..98f7d33ce29 100644 --- a/app/scripts/modules/core/src/reactShims/react.injector.ts +++ b/app/scripts/modules/core/src/reactShims/react.injector.ts @@ -71,6 +71,7 @@ export abstract class ReactInject { public abstract initialize($injector: IInjectorService): void; } +// prettier-ignore export class CoreReactInject extends ReactInject { // weird service because we wrap it private wrappedState: StateService; @@ -83,214 +84,80 @@ export class CoreReactInject extends ReactInject { } // Services - public get $q() { - return this.$injector.get('$q') as IQService; - } - public get $rootScope() { - return this.$injector.get('$rootScope') as IScope; - } - public get $stateParams() { - return this.$injector.get('$stateParams') as StateParams; - } - public get $uiRouter() { - return this.$injector.get('$uiRouter') as UIRouter; - } - public get API() { - return this.$injector.get('API') as Api; - } - public get accountService() { - return this.$injector.get('accountService') as AccountService; - } - public get applicationDataSourceRegistry() { - return this.$injector.get('applicationDataSourceRegistry') as ApplicationDataSourceRegistry; - } - public get applicationModelBuilder() { - return this.$injector.get('applicationModelBuilder') as ApplicationModelBuilder; - } - public get applicationReader() { - return this.$injector.get('applicationReader') as ApplicationReader; - } - public get authenticationService() { - return this.$injector.get('authenticationService') as AuthenticationService; - } - public get cacheInitializer() { - return this.$injector.get('cacheInitializer') as CacheInitializerService; - } - public get cancelModalService() { - return this.$injector.get('cancelModalService') as CancelModalService; - } - public get cloudProviderRegistry() { - return this.$injector.get('cloudProviderRegistry') as CloudProviderRegistry; - } - public get clusterFilterModel() { - return this.$injector.get('clusterFilterModel') as ClusterFilterModel; - } - public get clusterFilterService() { - return this.$injector.get('clusterFilterService') as ClusterFilterService; - } - public get clusterTargetBuilder() { - return this.$injector.get('clusterTargetBuilder') as ClusterTargetBuilder; - } - public get collapsibleSectionStateCache() { - return this.$injector.get('collapsibleSectionStateCache') as CollapsibleSectionStateCache; - } - public get confirmationModalService() { - return this.$injector.get('confirmationModalService') as ConfirmationModalService; - } - public get entityTagWriter() { - return this.$injector.get('entityTagWriter') as EntityTagWriter; - } - public get executionDetailsSectionService() { - return this.$injector.get('executionDetailsSectionService') as ExecutionDetailsSectionService; - } - public get executionFilterModel() { - return this.$injector.get('executionFilterModel') as ExecutionFilterModel; - } - public get executionFilterService() { - return this.$injector.get('executionFilterService') as ExecutionFilterService; - } - public get executionService() { - return this.$injector.get('executionService') as ExecutionService; - } - public get executionsTransformer() { - return this.$injector.get('executionsTransformer') as ExecutionsTransformerService; - } - public get helpContents() { - return this.$injector.get('helpContents') as IHelpContents; - } - public get helpContentsRegistry() { - return this.$injector.get('helpContentsRegistry') as HelpContentsRegistry; - } - public get infrastructureCaches() { - return this.$injector.get('infrastructureCaches') as InfrastructureCacheService; - } - public get infrastructureSearchService() { - return this.$injector.get('infrastructureSearchService') as InfrastructureSearchService; - } - public get infrastructureSearchServiceV2() { - return this.$injector.get('infrastructureSearchServiceV2') as InfrastructureSearchServiceV2; - } - public get insightFilterStateModel() { - return this.$injector.get('insightFilterStateModel') as InsightFilterStateModel; - } - public get loadBalancerFilterModel() { - return this.$injector.get('loadBalancerFilterModel') as LoadBalancerFilterModel; - } - public get loadBalancerFilterService() { - return this.$injector.get('loadBalancerFilterService') as LoadBalancerFilterService; - } - public get loadBalancerWriter() { - return this.$injector.get('loadBalancerWriter') as LoadBalancerWriter; - } - public get manualJudgmentService() { - return this.$injector.get('manualJudgmentService') as ManualJudgmentService; - } - public get modalService(): IModalService { - return this.$injector.get('$uibModal') as IModalService; - } - public get MultiselectModel() { - return this.$injector.get('MultiselectModel') as any; - } - public get namingService() { - return this.$injector.get('namingService') as NamingService; - } - public get notifierService() { - return this.$injector.get('notifierService') as NotifierService; - } - public get overrideRegistry() { - return this.$injector.get('overrideRegistry') as OverrideRegistry; - } - public get pagerDutyReader() { - return this.$injector.get('pagerDutyReader') as PagerDutyReader; - } - public get pagerDutyWriter() { - return this.$injector.get('pagerDutyWriter') as PagerDutyWriter; - } - public get pageTitleService() { - return this.$injector.get('pageTitleService') as PageTitleService; - } - public get pipelineConfig() { - return this.$injector.get('pipelineConfig') as PipelineConfigProvider; - } - public get pipelineConfigService() { - return this.$injector.get('pipelineConfigService') as PipelineConfigService; - } - public get pipelineConfigValidator() { - return this.$injector.get('pipelineConfigValidator') as PipelineConfigValidator; - } - public get pipelineTemplateService() { - return this.$injector.get('pipelineTemplateService') as PipelineTemplateService; - } - public get providerSelectionService() { - return this.$injector.get('providerSelectionService') as ProviderSelectionService; - } - public get schedulerFactory() { - return this.$injector.get('schedulerFactory') as SchedulerFactory; - } - public get scrollToService() { - return this.$injector.get('scrollToService') as ScrollToService; - } - public get securityGroupReader() { - return this.$injector.get('securityGroupReader') as SecurityGroupReader; - } - public get serverGroupReader() { - return this.$injector.get('serverGroupReader') as ServerGroupReader; - } - public get serverGroupWarningMessageService() { - return this.$injector.get('serverGroupWarningMessageService') as ServerGroupWarningMessageService; - } - public get serverGroupWriter() { - return this.$injector.get('serverGroupWriter') as ServerGroupWriter; - } - public get subnetReader() { - return this.$injector.get('subnetReader') as SubnetReader; - } - public get recentHistoryService() { - return this.$injector.get('recentHistoryService') as RecentHistoryService; - } - public get searchService() { - return this.$injector.get('searchService') as SearchService; - } - public get stateEvents() { - return this.$injector.get('stateEvents') as StateEvents; - } - public get taskExecutor() { - return this.$injector.get('taskExecutor') as TaskExecutor; - } - public get taskReader() { - return this.$injector.get('taskReader') as TaskReader; - } - public get taskMonitorBuilder() { - return this.$injector.get('taskMonitorBuilder') as TaskMonitorBuilder; - } - public get urlBuilderService() { - return this.$injector.get('urlBuilderService') as UrlBuilderService; - } - public get variableInputService() { - return this.$injector.get('variableInputService') as VariableInputService; - } - public get variableValidatorService() { - return this.$injector.get('variableValidatorService') as VariableValidatorService; - } - public get skinSelectionService() { - return this.$injector.get('skinSelectionService') as SkinSelectionService; - } - public get skinService() { - return this.$injector.get('skinService') as SkinService; - } - public get viewStateCache() { - return this.$injector.get('viewStateCache') as ViewStateCacheService; - } - public get waypointService() { - return this.$injector.get('waypointService') as WaypointService; - } + public get $q() { return this.$injector.get('$q') as IQService; } + public get $rootScope() { return this.$injector.get('$rootScope') as IScope; } + public get $stateParams() { return this.$injector.get('$stateParams') as StateParams; } + public get $uiRouter() { return this.$injector.get('$uiRouter') as UIRouter; } + public get API() { return this.$injector.get('API') as Api; } + public get accountService() { return this.$injector.get('accountService') as AccountService; } + public get applicationDataSourceRegistry() { return this.$injector.get('applicationDataSourceRegistry') as ApplicationDataSourceRegistry; } + public get applicationModelBuilder() { return this.$injector.get('applicationModelBuilder') as ApplicationModelBuilder; } + public get applicationReader() { return this.$injector.get('applicationReader') as ApplicationReader; } + public get authenticationService() { return this.$injector.get('authenticationService') as AuthenticationService; } + public get cacheInitializer() { return this.$injector.get('cacheInitializer') as CacheInitializerService; } + public get cancelModalService() { return this.$injector.get('cancelModalService') as CancelModalService; } + public get cloudProviderRegistry() { return this.$injector.get('cloudProviderRegistry') as CloudProviderRegistry; } + public get clusterFilterModel() { return this.$injector.get('clusterFilterModel') as ClusterFilterModel; } + public get clusterFilterService() { return this.$injector.get('clusterFilterService') as ClusterFilterService; } + public get clusterTargetBuilder() { return this.$injector.get('clusterTargetBuilder') as ClusterTargetBuilder; } + public get collapsibleSectionStateCache() { return this.$injector.get('collapsibleSectionStateCache') as CollapsibleSectionStateCache; } + public get confirmationModalService() { return this.$injector.get('confirmationModalService') as ConfirmationModalService; } + public get entityTagWriter() { return this.$injector.get('entityTagWriter') as EntityTagWriter; } + public get executionDetailsSectionService() { return this.$injector.get('executionDetailsSectionService') as ExecutionDetailsSectionService; } + public get executionFilterModel() { return this.$injector.get('executionFilterModel') as ExecutionFilterModel; } + public get executionFilterService() { return this.$injector.get('executionFilterService') as ExecutionFilterService; } + public get executionService() { return this.$injector.get('executionService') as ExecutionService; } + public get executionsTransformer() { return this.$injector.get('executionsTransformer') as ExecutionsTransformerService; } + public get helpContents() { return this.$injector.get('helpContents') as IHelpContents } + public get helpContentsRegistry() { return this.$injector.get('helpContentsRegistry') as HelpContentsRegistry; } + public get infrastructureCaches() { return this.$injector.get('infrastructureCaches') as InfrastructureCacheService; } + public get infrastructureSearchService() { return this.$injector.get('infrastructureSearchService') as InfrastructureSearchService; } + public get infrastructureSearchServiceV2() { return this.$injector.get('infrastructureSearchServiceV2') as InfrastructureSearchServiceV2; } + public get insightFilterStateModel() { return this.$injector.get('insightFilterStateModel') as InsightFilterStateModel; } + public get loadBalancerFilterModel() { return this.$injector.get('loadBalancerFilterModel') as LoadBalancerFilterModel; } + public get loadBalancerFilterService() { return this.$injector.get('loadBalancerFilterService') as LoadBalancerFilterService; } + public get loadBalancerWriter() { return this.$injector.get('loadBalancerWriter') as LoadBalancerWriter; } + public get manualJudgmentService() { return this.$injector.get('manualJudgmentService') as ManualJudgmentService; } + public get modalService(): IModalService { return this.$injector.get('$uibModal') as IModalService; } + public get MultiselectModel() { return this.$injector.get('MultiselectModel') as any; } + public get namingService() { return this.$injector.get('namingService') as NamingService; } + public get notifierService() { return this.$injector.get('notifierService') as NotifierService; } + public get overrideRegistry() { return this.$injector.get('overrideRegistry') as OverrideRegistry; } + public get pagerDutyReader() { return this.$injector.get('pagerDutyReader') as PagerDutyReader; } + public get pagerDutyWriter() { return this.$injector.get('pagerDutyWriter') as PagerDutyWriter; } + public get pageTitleService() { return this.$injector.get('pageTitleService') as PageTitleService; } + public get pipelineConfig() { return this.$injector.get('pipelineConfig') as PipelineConfigProvider; } + public get pipelineConfigService() { return this.$injector.get('pipelineConfigService') as PipelineConfigService; } + public get pipelineConfigValidator() { return this.$injector.get('pipelineConfigValidator') as PipelineConfigValidator; } + public get pipelineTemplateService() { return this.$injector.get('pipelineTemplateService') as PipelineTemplateService; } + public get providerSelectionService() { return this.$injector.get('providerSelectionService') as ProviderSelectionService; } + public get schedulerFactory() { return this.$injector.get('schedulerFactory') as SchedulerFactory; } + public get scrollToService() { return this.$injector.get('scrollToService') as ScrollToService; } + public get securityGroupReader() { return this.$injector.get('securityGroupReader') as SecurityGroupReader; } + public get serverGroupReader() { return this.$injector.get('serverGroupReader') as ServerGroupReader; } + public get serverGroupWarningMessageService() { return this.$injector.get('serverGroupWarningMessageService') as ServerGroupWarningMessageService; } + public get serverGroupWriter() { return this.$injector.get('serverGroupWriter') as ServerGroupWriter; } + public get subnetReader() { return this.$injector.get('subnetReader') as SubnetReader; } + public get recentHistoryService() { return this.$injector.get('recentHistoryService') as RecentHistoryService; } + public get searchService() { return this.$injector.get('searchService') as SearchService; } + public get stateEvents() { return this.$injector.get('stateEvents') as StateEvents; } + public get taskExecutor() { return this.$injector.get('taskExecutor') as TaskExecutor; } + public get taskReader() { return this.$injector.get('taskReader') as TaskReader; } + public get taskMonitorBuilder() { return this.$injector.get('taskMonitorBuilder') as TaskMonitorBuilder; } + public get urlBuilderService() { return this.$injector.get('urlBuilderService') as UrlBuilderService; } + public get variableInputService() { return this.$injector.get('variableInputService') as VariableInputService; } + public get variableValidatorService() { return this.$injector.get('variableValidatorService') as VariableValidatorService; } + public get skinSelectionService() { return this.$injector.get('skinSelectionService') as SkinSelectionService; } + public get skinService() { return this.$injector.get('skinService') as SkinService; } + public get viewStateCache() { return this.$injector.get('viewStateCache') as ViewStateCacheService; } + public get waypointService() { return this.$injector.get('waypointService') as WaypointService; } private createStateService(): StateService { const wrappedState = Object.create(this.$injector.get('$state')) as StateService; const $rootScope = this.$injector.get('$rootScope') as IRootScopeService; const $q = this.$injector.get('$q') as IQService; const originalGo = wrappedState.go; - wrappedState.go = function() { + wrappedState.go = function () { const args = arguments; const deferred = $q.defer(); const promise = Object.create(deferred); diff --git a/app/scripts/modules/core/src/search/infrastructure/ProjectSummaryPod.tsx b/app/scripts/modules/core/src/search/infrastructure/ProjectSummaryPod.tsx index ab3dc184c11..7871573983d 100644 --- a/app/scripts/modules/core/src/search/infrastructure/ProjectSummaryPod.tsx +++ b/app/scripts/modules/core/src/search/infrastructure/ProjectSummaryPod.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import { MouseEvent } from 'react'; import { BindAll } from 'lodash-decorators'; import { UISref } from '@uirouter/react'; import { UIRouterContext } from '@uirouter/react-hybrid'; @@ -19,7 +18,7 @@ export interface IProjectSummaryPodProps { @UIRouterContext @BindAll() export class ProjectSummaryPod extends React.Component { - private handleRemoveClicked(evt: MouseEvent) { + private handleRemoveClicked(evt: React.MouseEvent) { evt.preventDefault(); this.props.onRemoveProject(this.props.id); } diff --git a/app/scripts/modules/core/src/search/infrastructure/SearchResultPodItem.tsx b/app/scripts/modules/core/src/search/infrastructure/SearchResultPodItem.tsx index ab6da50200e..7f6f84d510d 100644 --- a/app/scripts/modules/core/src/search/infrastructure/SearchResultPodItem.tsx +++ b/app/scripts/modules/core/src/search/infrastructure/SearchResultPodItem.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import { MouseEvent } from 'react'; import { UISref } from '@uirouter/react'; import { BindAll } from 'lodash-decorators'; import { UIRouterContext } from '@uirouter/react-hybrid'; @@ -19,7 +18,7 @@ export interface ISearchResultPodItemProps { @UIRouterContext @BindAll() export class SearchResultPodItem extends React.Component { - private handleRemoveClicked(evt: MouseEvent, categoryName: string, itemId: string) { + private handleRemoveClicked(evt: React.MouseEvent, categoryName: string, itemId: string) { evt.preventDefault(); this.props.onRemoveItem(categoryName, itemId); } diff --git a/app/scripts/modules/core/src/search/infrastructure/infrastructureSearchV2.service.ts b/app/scripts/modules/core/src/search/infrastructure/infrastructureSearchV2.service.ts index f4e7b57d78a..70351677508 100644 --- a/app/scripts/modules/core/src/search/infrastructure/infrastructureSearchV2.service.ts +++ b/app/scripts/modules/core/src/search/infrastructure/infrastructureSearchV2.service.ts @@ -6,11 +6,10 @@ import { SETTINGS } from 'core/config'; import { UrlBuilderService, URL_BUILDER_SERVICE, IQueryParams } from 'core/navigation'; import { ISearchResultSet } from './infrastructureSearch.service'; -import { ISearchResults } from '../search.service'; +import { ISearchResult, SEARCH_SERVICE, ISearchResults } from '../search.service'; import { SearchResultType } from '../searchResult/searchResultType'; import { SearchStatus } from '../searchResult/SearchResults'; import { searchResultTypeRegistry } from '../searchResult/searchResultType.registry'; -import { ISearchResult, SEARCH_SERVICE } from '../search.service'; export class InfrastructureSearchServiceV2 { private EMPTY_RESULTS: ISearchResultSet[] = searchResultTypeRegistry diff --git a/app/scripts/modules/core/src/serverGroup/ServerGroup.tsx b/app/scripts/modules/core/src/serverGroup/ServerGroup.tsx index ee12f0d78bd..1f605d3a4aa 100644 --- a/app/scripts/modules/core/src/serverGroup/ServerGroup.tsx +++ b/app/scripts/modules/core/src/serverGroup/ServerGroup.tsx @@ -16,12 +16,12 @@ import { ISortFilter } from 'core/filterModel'; import { ServerGroupHeader } from './ServerGroupHeader'; import { SETTINGS } from 'core'; -export interface JenkinsViewModel { +export interface IJenkinsViewModel { number: number; href?: string; } -export interface DockerViewModel { +export interface IDockerViewModel { image: string; tag: string; href?: string; @@ -37,8 +37,8 @@ export interface IServerGroupProps { } export interface IServerGroupState { - jenkins: JenkinsViewModel; - docker: DockerViewModel; + jenkins: IJenkinsViewModel; + docker: IDockerViewModel; instances: IInstance[]; images?: string; @@ -64,9 +64,9 @@ export class ServerGroup extends React.Component { public state = { value: '', matches: false }; - private handleChange(evt: ChangeEvent) { + private handleChange(evt: React.ChangeEvent) { const { value } = evt.target; const { expectedValue } = this.props; diff --git a/app/scripts/modules/core/src/utils/failedToInstantiateModule.ts b/app/scripts/modules/core/src/utils/failedToInstantiateModule.ts index 5a3ee00dcfc..681934b20a2 100644 --- a/app/scripts/modules/core/src/utils/failedToInstantiateModule.ts +++ b/app/scripts/modules/core/src/utils/failedToInstantiateModule.ts @@ -1,10 +1,9 @@ import * as angular from 'angular'; -import { IModule } from 'angular'; // Improve errors/stack traces related to: // `Error: [ng:areq] Argument 'module' is not a function, got undefined` const realModule = angular.module; -(angular as any).module = function(name: string, requires?: string[], configFn?: Function): IModule { +(angular as any).module = function(name: string, requires?: string[], configFn?: Function): angular.IModule { if (requires && requires.some(dep => !dep)) { const deps = requires.map(r => (typeof r === 'string' ? `'${r}'` : `${r}`)).join(', '); throw new Error(`Got falsey dependency whilst registering angular module '${name}': [${deps}]`); diff --git a/app/scripts/modules/core/src/utils/selectOnDblClick.directive.ts b/app/scripts/modules/core/src/utils/selectOnDblClick.directive.ts index e540cc7fdc8..aeaf83d05cc 100644 --- a/app/scripts/modules/core/src/utils/selectOnDblClick.directive.ts +++ b/app/scripts/modules/core/src/utils/selectOnDblClick.directive.ts @@ -1,4 +1,4 @@ -/** based on http://jsfiddle.net/epinapala/WdeTM/4/ **/ +/** based on http://jsfiddle.net/epinapala/WdeTM/4/ */ import { IController, IDirective, IScope, module } from 'angular'; import { DirectiveFactory } from './tsDecorators/directiveFactoryDecorator'; diff --git a/app/scripts/modules/core/src/widgets/CustomDropdown.tsx b/app/scripts/modules/core/src/widgets/CustomDropdown.tsx index 2a27bf046fb..3f20a7666f6 100644 --- a/app/scripts/modules/core/src/widgets/CustomDropdown.tsx +++ b/app/scripts/modules/core/src/widgets/CustomDropdown.tsx @@ -1,14 +1,14 @@ import * as React from 'react'; import { BindAll } from 'lodash-decorators'; -export interface ToggleProps { +export interface IToggleProps { bsRole: string; onClick?: React.EventHandler>; } @BindAll() -export class CustomToggle extends React.Component { - constructor(props: ToggleProps) { +export class CustomToggle extends React.Component { + constructor(props: IToggleProps) { super(props); } @@ -26,15 +26,15 @@ export class CustomToggle extends React.Component { } } -export interface MenuProps { +export interface IMenuProps { bsRole: string; } -export interface MenuState { +export interface IMenuState { value: string; } -export class CustomMenu extends React.Component { - constructor(props: MenuProps) { +export class CustomMenu extends React.Component { + constructor(props: IMenuProps) { super(props); this.state = { value: '' }; } diff --git a/app/scripts/modules/ecs/metricAlarm/MetricAlarm.ts b/app/scripts/modules/ecs/metricAlarm/MetricAlarm.ts index 7b62a8050d8..a73493f60ef 100644 --- a/app/scripts/modules/ecs/metricAlarm/MetricAlarm.ts +++ b/app/scripts/modules/ecs/metricAlarm/MetricAlarm.ts @@ -1,4 +1,4 @@ -export interface MetricAlarmDescriptor { +export interface IMetricAlarmDescriptor { accountName: string; region: string; alarmName: string; diff --git a/app/scripts/modules/ecs/metricAlarm/metricAlarm.read.service.ts b/app/scripts/modules/ecs/metricAlarm/metricAlarm.read.service.ts index b97bc06f54d..ad7faa61d74 100644 --- a/app/scripts/modules/ecs/metricAlarm/metricAlarm.read.service.ts +++ b/app/scripts/modules/ecs/metricAlarm/metricAlarm.read.service.ts @@ -1,14 +1,14 @@ import { module } from 'angular'; import { API_SERVICE, Api } from 'core/api/api.service'; -import { MetricAlarmDescriptor } from './MetricAlarm'; +import { IMetricAlarmDescriptor } from './MetricAlarm'; export class MetricAlarmReader { public constructor(private API: Api) { 'ngInject'; } - public listMetricAlarms(): ng.IPromise { + public listMetricAlarms(): ng.IPromise { return this.API.all('ecs') .all('cloudMetrics') .all('alarms') diff --git a/app/scripts/modules/ecs/serverGroup/configure/serverGroupConfiguration.service.ts b/app/scripts/modules/ecs/serverGroup/configure/serverGroupConfiguration.service.ts index 620c7e32d47..e96e227c6e3 100644 --- a/app/scripts/modules/ecs/serverGroup/configure/serverGroupConfiguration.service.ts +++ b/app/scripts/modules/ecs/serverGroup/configure/serverGroupConfiguration.service.ts @@ -28,7 +28,7 @@ import { IamRoleReader } from '../../iamRoles/iamRole.read.service'; import { EscClusterReader } from '../../ecsCluster/ecsCluster.read.service'; import { MetricAlarmReader } from '../../metricAlarm/metricAlarm.read.service'; import { IRoleDescriptor } from '../../iamRoles/IRole'; -import { MetricAlarmDescriptor } from '../../metricAlarm/MetricAlarm'; +import { IMetricAlarmDescriptor } from '../../metricAlarm/MetricAlarm'; import { PlacementStrategyService } from '../../placementStrategy/placementStrategy.service'; import { IPlacementStrategy } from '../../placementStrategy/IPlacementStrategy'; import { IEcsClusterDescriptor } from '../../ecsCluster/IEcsCluster'; @@ -45,7 +45,7 @@ export interface IEcsServerGroupCommandBackingDataFiltered extends IServerGroupC targetGroups: string[]; iamRoles: string[]; ecsClusters: string[]; - metricAlarms: MetricAlarmDescriptor[]; + metricAlarms: IMetricAlarmDescriptor[]; } export interface IEcsServerGroupCommandBackingData extends IServerGroupCommandBackingData { @@ -53,7 +53,7 @@ export interface IEcsServerGroupCommandBackingData extends IServerGroupCommandBa targetGroups: string[]; ecsClusters: IEcsClusterDescriptor[]; iamRoles: IRoleDescriptor[]; - metricAlarms: MetricAlarmDescriptor[]; + metricAlarms: IMetricAlarmDescriptor[]; } export interface IEcsServerGroupCommand extends IServerGroupCommand { @@ -182,7 +182,7 @@ export class EcsServerGroupConfigurationService { return { alarmName: metricAlarm.alarmName, alarmArn: metricAlarm.alarmArn, - } as MetricAlarmDescriptor; + } as IMetricAlarmDescriptor; }) .value(); diff --git a/app/scripts/modules/ecs/serverGroup/serverGroup.transformer.spec.ts b/app/scripts/modules/ecs/serverGroup/serverGroup.transformer.spec.ts index b383147395f..2f153240217 100644 --- a/app/scripts/modules/ecs/serverGroup/serverGroup.transformer.spec.ts +++ b/app/scripts/modules/ecs/serverGroup/serverGroup.transformer.spec.ts @@ -1,8 +1,13 @@ import { mock, IQService, IRootScopeService, IScope } from 'angular'; import { ECS_SERVER_GROUP_TRANSFORMER, EcsServerGroupTransformer } from './serverGroup.transformer'; -import { IScalingPolicyAlarmView, IAmazonServerGroup, IStepAdjustment } from '@spinnaker/amazon'; -import { VPC_READ_SERVICE, VpcReader } from '@spinnaker/amazon'; +import { + IScalingPolicyAlarmView, + IAmazonServerGroup, + IStepAdjustment, + VPC_READ_SERVICE, + VpcReader, +} from '@spinnaker/amazon'; describe('ecsServerGroupTransformer', () => { let transformer: EcsServerGroupTransformer, vpcReader: VpcReader, $q: IQService, $scope: IScope; diff --git a/app/scripts/modules/ecs/serverGroup/serverGroup.transformer.ts b/app/scripts/modules/ecs/serverGroup/serverGroup.transformer.ts index 80edc266bb8..1a4fe9f54d0 100644 --- a/app/scripts/modules/ecs/serverGroup/serverGroup.transformer.ts +++ b/app/scripts/modules/ecs/serverGroup/serverGroup.transformer.ts @@ -11,8 +11,9 @@ import { IStepAdjustmentView, IScalingPolicy, IAmazonServerGroupView, + VPC_READ_SERVICE, + VpcReader, } from '@spinnaker/amazon'; -import { VPC_READ_SERVICE, VpcReader } from '@spinnaker/amazon'; export class EcsServerGroupTransformer { public constructor(private vpcReader: VpcReader) { diff --git a/app/scripts/modules/google/src/loadBalancer/configure/common/sessionAffinityNameMaps.ts b/app/scripts/modules/google/src/loadBalancer/configure/common/sessionAffinityNameMaps.ts index be43eb6ae98..01384d07085 100644 --- a/app/scripts/modules/google/src/loadBalancer/configure/common/sessionAffinityNameMaps.ts +++ b/app/scripts/modules/google/src/loadBalancer/configure/common/sessionAffinityNameMaps.ts @@ -1,10 +1,10 @@ import * as _ from 'lodash'; -export interface StringMap { +export interface IStringMap { [key: string]: string; } -export const sessionAffinityViewToModelMap: StringMap = { +export const sessionAffinityViewToModelMap: IStringMap = { None: 'NONE', 'Client IP': 'CLIENT_IP', 'Generated Cookie': 'GENERATED_COOKIE', @@ -12,4 +12,4 @@ export const sessionAffinityViewToModelMap: StringMap = { 'Client IP, port and protocol': 'CLIENT_IP_PORT_PROTO', }; -export const sessionAffinityModelToViewMap = _.invert(sessionAffinityViewToModelMap); +export const sessionAffinityModelToViewMap = _.invert(sessionAffinityViewToModelMap); diff --git a/app/scripts/modules/titus/src/loadBalancers/TitusLoadBalancersTag.tsx b/app/scripts/modules/titus/src/loadBalancers/TitusLoadBalancersTag.tsx index 3b357025745..4606417f317 100644 --- a/app/scripts/modules/titus/src/loadBalancers/TitusLoadBalancersTag.tsx +++ b/app/scripts/modules/titus/src/loadBalancers/TitusLoadBalancersTag.tsx @@ -15,8 +15,7 @@ import { HoverablePopover, } from '@spinnaker/core'; -import { AmazonLoadBalancerDataUtils } from '@spinnaker/amazon'; -import { IAmazonServerGroup, ITargetGroup } from '@spinnaker/amazon'; +import { AmazonLoadBalancerDataUtils, IAmazonServerGroup, ITargetGroup } from '@spinnaker/amazon'; interface ILoadBalancerListItemProps { loadBalancer: ILoadBalancer | ITargetGroup; diff --git a/app/scripts/modules/titus/src/reactShims/titus.react.injector.ts b/app/scripts/modules/titus/src/reactShims/titus.react.injector.ts index bf0cd872307..fd9cbf2d3c7 100644 --- a/app/scripts/modules/titus/src/reactShims/titus.react.injector.ts +++ b/app/scripts/modules/titus/src/reactShims/titus.react.injector.ts @@ -2,10 +2,9 @@ import IInjectorService = angular.auto.IInjectorService; import { ReactInject } from '@spinnaker/core'; +// prettier-ignore export class TitusReactInject extends ReactInject { - public get titusServerGroupTransformer() { - return this.$injector.get('titusServerGroupTransformer') as any; - } + public get titusServerGroupTransformer() { return this.$injector.get('titusServerGroupTransformer') as any; } public initialize($injector: IInjectorService) { this.$injector = $injector; diff --git a/app/scripts/modules/titus/src/validation/applicationName.validator.ts b/app/scripts/modules/titus/src/validation/applicationName.validator.ts index 35db87d0cd0..625c2fedcd3 100644 --- a/app/scripts/modules/titus/src/validation/applicationName.validator.ts +++ b/app/scripts/modules/titus/src/validation/applicationName.validator.ts @@ -35,10 +35,7 @@ class TitusApplicationNameValidator implements IApplicationNameValidator { this.validateLength(name, warnings, errors); } - return { - warnings: warnings, - errors: errors, - }; + return { warnings, errors }; } } diff --git a/package.json b/package.json index 70796524aa7..4992f87082c 100644 --- a/package.json +++ b/package.json @@ -164,6 +164,7 @@ "thread-loader": "^1.1.5", "ts-loader": "4.1.0", "tslint": "^5.9.1", + "tslint-config-prettier": "^1.10.0", "tslint-eslint-rules": "^5.1.0", "tslint-loader": "^3.6.0", "tslint-react": "^3.5.1", diff --git a/tslint.json b/tslint.json index 1302787a08b..12f8a05e41b 100644 --- a/tslint.json +++ b/tslint.json @@ -1,38 +1,32 @@ { - "extends": ["tslint-eslint-rules", "tslint-react"], + "extends": ["tslint:latest", "tslint-react", "tslint-eslint-rules", "tslint-config-prettier"], "rules": { + "ordered-imports": false, + "no-var-requires": false, + "no-implicit-dependencies": false, + "no-this-assignment": false, + "max-classes-per-file": false, + "only-arrow-functions": false, + "no-submodule-imports": false, + "no-object-literal-type-assertion": false, + "no-reference": false, + "one-variable-per-declaration": false, + "prefer-conditional-expression": false, + "no-empty-interface": false, + "no-invalid-template-strings": false, "class-name": true, - "comment-format": [ - true, - "check-space" - ], + "comment-format": [true, "check-space"], "curly": true, "eofline": true, "forin": true, - "indent": [ - true, - "spaces" - ], + "indent": [true, "spaces"], "label-position": true, "max-line-length": false, "member-access": true, - "member-ordering": [ - true, - "static-before-instance", - "variables-before-functions" - ], + "member-ordering": [true, "static-before-instance", "variables-before-functions"], "no-arg": true, "no-bitwise": true, - "no-console": [ - true, - "log", - "warn", - "debug", - "info", - "time", - "timeEnd", - "trace" - ], + "no-console": [true, "log", "warn", "debug", "info", "time", "timeEnd", "trace"], "no-construct": true, "no-debugger": true, "no-duplicate-variable": true, @@ -48,37 +42,18 @@ "no-var-keyword": true, "object-curly-spacing": "always", "object-literal-sort-keys": false, - "one-line": [ - true, - "check-catch", - "check-else", - "check-open-brace", - "check-whitespace" - ], + "one-line": [true, "check-catch", "check-else", "check-open-brace", "check-whitespace"], "prefer-const": [ true, { "destructuring": "all" } ], - "quotemark": [ - true, - "single", - "avoid-escape", - "jsx-double" - ], + "quotemark": [true, "single", "avoid-escape", "jsx-double"], "radix": true, - "semicolon": [ - "always" - ], - "triple-equals": [ - true, - "allow-null-check" - ], - "typedef": [ - "call-signature", - "property-declaration" - ], + "semicolon": ["always"], + "triple-equals": [true, "allow-null-check"], + "typedef": ["call-signature", "property-declaration"], "typedef-whitespace": [ true, { @@ -89,19 +64,8 @@ "variable-declaration": "nospace" } ], - "variable-name": [ - true, - "ban-keywords", - "allow-leading-underscore" - ], - "whitespace": [ - true, - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type" - ], + "variable-name": [true, "ban-keywords", "allow-leading-underscore"], + "whitespace": [true, "check-branch", "check-decl", "check-operator", "check-separator", "check-type"], "jsx-no-multiline-js": false, "jsx-no-lambda": false } diff --git a/yarn.lock b/yarn.lock index 66359d181bc..729c7403584 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13269,6 +13269,10 @@ tslib@^1.8.1: version "1.8.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.8.1.tgz#6946af2d1d651a7b1863b531d6e5afa41aa44eac" +tslint-config-prettier@^1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/tslint-config-prettier/-/tslint-config-prettier-1.10.0.tgz#5063c413d43de4f6988c73727f65ecfc239054ec" + tslint-eslint-rules@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/tslint-eslint-rules/-/tslint-eslint-rules-5.1.0.tgz#3232b318da55dbb5a83e3f5d657c1ddbb27b9ff2"