Skip to content

Commit b02205d

Browse files
committed
chore(lint): remove uses of Function type
1 parent 8d3a53a commit b02205d

File tree

8 files changed

+57
-53
lines changed

8 files changed

+57
-53
lines changed

.vscode/settings.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
22
"typescript.tsdk": "node_modules/typescript/lib",
3-
"editor.formatOnSave": false
3+
"editor.formatOnSave": true,
4+
"typescript.format.enable": true,
5+
"json.format.enable": false,
6+
"html.format.enable": false,
7+
"html.suggest.angular1": false,
8+
"html.suggest.ionic": false
49
}

src/styles/decorators.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import {StyleResource} from './style-resource';
2-
import {resource} from 'aurelia-templating';
3-
import {RelativeStyleStrategy, StyleStrategy, InlineStyleStrategy} from './style-strategy';
4-
import {metadata} from 'aurelia-metadata';
5-
import {StyleLocator} from './style-locator';
1+
import { StyleResource } from './style-resource';
2+
import { resource } from 'aurelia-templating';
3+
import { RelativeStyleStrategy, StyleStrategy, InlineStyleStrategy } from './style-strategy';
4+
import { metadata } from 'aurelia-metadata';
5+
import { StyleLocator } from './style-locator';
66

77
/**
88
* Decorator: Indicates that the target is a styles class.
@@ -16,7 +16,7 @@ export function styles() {
1616
* @param strategy The style strategy instance.
1717
*/
1818
export function useStyleStrategy(strategy: StyleStrategy): any {
19-
return (target: Function) => {
19+
return (target: new () => any) => {
2020
metadata.define(StyleLocator.styleStrategyMetadataKey, strategy, target);
2121
};
2222
}

src/styles/dynamic-styles.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {styles, useStyles} from './decorators';
1+
import { styles, useStyles } from './decorators';
22

33
let nextThemeId = 0;
44

@@ -7,13 +7,13 @@ function getNextDynamicThemeId() {
77
}
88

99
export interface StyleModule {
10-
[x: string]: Function;
10+
[x: string]: new () => any;
1111
}
1212

1313
export function createDynamicStyleModule(styleUrl: string): StyleModule {
1414
@styles()
1515
@useStyles(styleUrl)
16-
class DynamicTheme {}
16+
class DynamicTheme { }
1717

1818
return {
1919
[getNextDynamicThemeId()]: DynamicTheme

src/styles/style-compiler.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import {BindingLanguage, ViewResources} from 'aurelia-templating';
2-
import {inject} from 'aurelia-dependency-injection';
3-
import {StyleFactory} from './style-factory';
1+
import { BindingLanguage, ViewResources } from 'aurelia-templating';
2+
import { inject } from 'aurelia-dependency-injection';
3+
import { StyleFactory } from './style-factory';
44

55
const classMatcher = /styles.([A-Za-z1-9\-_]+)/g;
66

77
@inject(BindingLanguage, ViewResources)
88
export class StyleCompiler {
9-
constructor(private bindingLanguage: BindingLanguage, private viewResources: ViewResources) {}
9+
constructor(private bindingLanguage: BindingLanguage, private viewResources: ViewResources) { }
1010

11-
public compile(styleObjectType: Function, css: string): StyleFactory {
11+
public compile(styleObjectType: new () => any, css: string): StyleFactory {
1212
const styles = Object.create(null);
1313
const transformed = css.replace(classMatcher, (_: string, capture: string) => {
1414
const name = capture.replace(/\-/g, '_');
@@ -32,15 +32,15 @@ export class StyleCompiler {
3232
}
3333

3434
class PlainCSSBindingExpression {
35-
constructor(private css: string) {}
35+
constructor(private css: string) { }
3636

3737
public createBinding(styleElement: HTMLStyleElement) {
3838
return new CSSBinding(this.css, styleElement);
3939
}
4040
}
4141

4242
class CSSBinding {
43-
constructor(private css: string, private styleElement: HTMLStyleElement) {}
43+
constructor(private css: string, private styleElement: HTMLStyleElement) { }
4444

4545
public bind() {
4646
this.styleElement.innerHTML = this.css;

src/styles/style-factory.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import {StyleController} from './style-controller';
2-
import {AureliaUX} from '../aurelia-ux';
3-
import {computedFrom, camelCase} from 'aurelia-binding';
4-
import {Container} from 'aurelia-dependency-injection';
5-
import {Origin} from 'aurelia-metadata';
6-
import {swatches} from '../colors/swatches';
7-
import {shadows} from '../colors/shadows';
1+
import { StyleController } from './style-controller';
2+
import { AureliaUX } from '../aurelia-ux';
3+
import { computedFrom, camelCase } from 'aurelia-binding';
4+
import { Container } from 'aurelia-dependency-injection';
5+
import { Origin } from 'aurelia-metadata';
6+
import { swatches } from '../colors/swatches';
7+
import { shadows } from '../colors/shadows';
88

99
export class StyleFactory {
1010
public themeKey: string;
1111
private defaultController: StyleController;
1212

13-
constructor(private styleObjectType: Function, private styles: string[], private expression: object) {
13+
constructor(private styleObjectType: new () => any, private styles: string[], private expression: object) {
1414
this.themeKey = camelCase(Origin.get(styleObjectType).moduleMember);
1515
}
1616

@@ -44,7 +44,7 @@ export class StyleFactory {
4444
new StyleOverrideContext(ux, $styles, bindingContext),
4545
this.expression,
4646
destination
47-
);
47+
);
4848
}
4949
}
5050

@@ -64,7 +64,7 @@ class StyleOverrideContext {
6464
public $swatches = swatches;
6565
public $shadows = shadows;
6666

67-
constructor(public $ux: AureliaUX, public $styles: any, public bindingContext: any) {}
67+
constructor(public $ux: AureliaUX, public $styles: any, public bindingContext: any) { }
6868

6969
@computedFrom('$ux.platform')
7070
get $platform() {

src/styles/style-resource.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import {Origin} from 'aurelia-metadata';
2-
import {ViewResources, View} from 'aurelia-templating';
3-
import {Container} from 'aurelia-dependency-injection';
4-
import {StyleFactory} from './style-factory';
5-
import {StyleLocator} from './style-locator';
6-
import {StyleEngine} from './style-engine';
1+
import { Origin } from 'aurelia-metadata';
2+
import { ViewResources, View } from 'aurelia-templating';
3+
import { Container } from 'aurelia-dependency-injection';
4+
import { StyleFactory } from './style-factory';
5+
import { StyleLocator } from './style-locator';
6+
import { StyleEngine } from './style-engine';
77

88
export class StyleResource {
9-
public styleObjectType: Function;
9+
public styleObjectType: new () => any;
1010
public css: string;
1111
public resources: ViewResources;
1212
public factory: StyleFactory;
1313
public container: Container;
1414
private hooks: StyleViewEngineHooks;
1515

16-
public initialize(container: Container, target: Function): void {
16+
public initialize(container: Container, target: new () => any): void {
1717
this.styleObjectType = target;
1818
this.container = container;
1919
this.hooks = new StyleViewEngineHooks(container.get(StyleEngine));
@@ -42,7 +42,7 @@ export class StyleResource {
4242
class StyleViewEngineHooks {
4343
public factory: StyleFactory;
4444

45-
constructor(private engine: StyleEngine) {}
45+
constructor(private engine: StyleEngine) { }
4646

4747
public beforeBind(view: View) {
4848
this.engine.getOrCreateStyleController(view, this.factory).bind(view);

src/styles/style-strategy.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import {StyleFactory} from './style-factory';
2-
import {protocol, Origin} from 'aurelia-metadata';
3-
import {PLATFORM} from 'aurelia-pal';
4-
import {StyleLocator} from './style-locator';
5-
import {relativeToFile} from 'aurelia-path';
6-
import {Container} from 'aurelia-dependency-injection';
7-
import {StyleCompiler} from './style-compiler';
8-
import {Loader} from 'aurelia-loader';
9-
import {AureliaUX} from '../aurelia-ux';
1+
import { StyleFactory } from './style-factory';
2+
import { protocol, Origin } from 'aurelia-metadata';
3+
import { PLATFORM } from 'aurelia-pal';
4+
import { StyleLocator } from './style-locator';
5+
import { relativeToFile } from 'aurelia-path';
6+
import { Container } from 'aurelia-dependency-injection';
7+
import { StyleCompiler } from './style-compiler';
8+
import { Loader } from 'aurelia-loader';
9+
import { AureliaUX } from '../aurelia-ux';
1010

1111
export interface StyleStrategy {
1212
moduleId?: string;
13-
loadStyleFactory(container: Container, styleObjectType: Function): Promise<StyleFactory>;
13+
loadStyleFactory(container: Container, styleObjectType: new () => any): Promise<StyleFactory>;
1414
}
1515

1616
/**
1717
* Decorator: Indicates that the decorated class/object is a style strategy.
1818
*/
19-
export const styleStrategy: Function = (protocol as any).create('aurelia:style-strategy', {
19+
export const styleStrategy: () => (target: any) => void = (protocol as any).create('aurelia:style-strategy', {
2020
validate(target: any): string | boolean {
2121
if (!(typeof target.loadStyleFactory === 'function')) {
2222
return 'Style strategies must implement: loadStyleFactory(): Promise<StyleFactory>';
@@ -70,7 +70,7 @@ export class RelativeStyleStrategy implements StyleStrategy {
7070
/**
7171
* Loads a style factory.
7272
*/
73-
public loadStyleFactory(container: Container, styleObjectType: Function): Promise<StyleFactory> {
73+
public loadStyleFactory(container: Container, styleObjectType: new () => any): Promise<StyleFactory> {
7474
if (this.absolutePath === null && this.moduleId) {
7575
const path = resolveForDesign(this.pathOrDesignMap, container);
7676

@@ -128,7 +128,7 @@ export class ConventionalStyleStrategy implements StyleStrategy {
128128
/**
129129
* Loads a style factory.
130130
*/
131-
public loadStyleFactory(container: Container, styleObjectType: Function): Promise<StyleFactory> {
131+
public loadStyleFactory(container: Container, styleObjectType: new () => any): Promise<StyleFactory> {
132132
return container.get(Loader)
133133
.loadText(this.styleUrl)
134134
.catch(() => null)
@@ -152,12 +152,12 @@ export class InlineStyleStrategy implements StyleStrategy {
152152
/**
153153
* Creates an instance of InlineStyleStrategy.
154154
*/
155-
constructor(private cssOrDesignMap: string | any) {}
155+
constructor(private cssOrDesignMap: string | any) { }
156156

157157
/**
158158
* Loads a style factory.
159159
*/
160-
public loadStyleFactory(container: Container, styleObjectType: Function): Promise<StyleFactory> {
160+
public loadStyleFactory(container: Container, styleObjectType: new () => any): Promise<StyleFactory> {
161161
const css = resolveForDesign(this.cssOrDesignMap, container);
162162
this.transformedCSS = fixupCSSUrls(this.moduleId, css);
163163
const compiler = container.get(StyleCompiler) as StyleCompiler;

tslint.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"array-type": ["array-simple"],
1414
"arrow-parens": false,
1515
"max-classes-per-file": [false],
16-
"prefer-for-of": false,
17-
"ban-types": false
16+
"prefer-for-of": false
1817
}
1918
}

0 commit comments

Comments
 (0)