Skip to content
This repository was archived by the owner on Oct 19, 2019. It is now read-only.

Commit 902f712

Browse files
committed
added linting
1 parent 10bccff commit 902f712

22 files changed

+1217
-1095
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ node_js:
44
notifications:
55
email: false
66
script:
7+
- "npm run lint"
78
- "npm run build"
89
- "npm test"

lib/Hoster.ts

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1-
import objectMerge = require("object-merge");
2-
import normalizeUrl = require("normalize-url");
3-
4-
5-
const _private = new WeakMap();
6-
7-
export class Hoster {
8-
public name: string;
9-
10-
constructor({ url, name }: { url:string, name:string }) {
11-
this.url = url;
12-
this.name = name;
13-
}
14-
15-
get url(): string {
16-
return _private.get(this).url;
17-
}
18-
set url(value: string) {
19-
(_private.get(this) || _private.set(this, {}).get(this)).url = normalizeUrl(value);
20-
}
21-
22-
toJSON(): object {
23-
return objectMerge(this, _private.get(this));
24-
}
25-
}
1+
import normalizeUrl = require('normalize-url');
2+
import objectMerge = require('object-merge');
3+
4+
const _private = new WeakMap();
5+
6+
export class Hoster {
7+
public name: string;
8+
9+
constructor({ url, name }: { url: string, name: string }) {
10+
this.url = url;
11+
this.name = name;
12+
}
13+
14+
get url(): string {
15+
return _private.get(this).url;
16+
}
17+
set url(value: string) {
18+
(_private.get(this) || _private.set(this, {}).get(this)).url = normalizeUrl(value);
19+
}
20+
21+
public toJSON(): object {
22+
return objectMerge(this, _private.get(this));
23+
}
24+
}

lib/HosterInfo.ts

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1-
import objectMerge = require("object-merge");
2-
3-
import { Info } from './Info';
4-
import { Hoster } from './Hoster';
5-
6-
7-
const _private = new WeakMap();
8-
9-
export class HosterInfo extends Info {
10-
public title: string;
11-
constructor({ hoster, title }: { hoster?:Hoster[]|Hoster, title?:string } = {}) {
12-
super();
13-
14-
this.hoster = typeof hoster === 'undefined' ? [] : Array.isArray(hoster) ? hoster : [hoster];
15-
this.title = title;
16-
}
17-
18-
get hoster(): Hoster[] {
19-
return _private.get(this).hoster;
20-
}
21-
set hoster(value: Hoster[]) {
22-
(_private.get(this) || _private.set(this, {}).get(this)).hoster = value;
23-
}
24-
25-
toJSON(): object {
26-
return objectMerge(this, _private.get(this));
27-
}
28-
}
1+
import objectMerge = require('object-merge');
2+
3+
import { Hoster } from './Hoster';
4+
import { Info } from './Info';
5+
6+
const _private = new WeakMap();
7+
8+
export class HosterInfo extends Info {
9+
public title: string;
10+
constructor({ hoster, title }: { hoster?: Hoster[] | Hoster, title?: string } = {}) {
11+
super();
12+
13+
this.hoster = typeof hoster === 'undefined' ? [] : Array.isArray(hoster) ? hoster : [hoster];
14+
this.title = title;
15+
}
16+
17+
get hoster(): Hoster[] {
18+
return _private.get(this).hoster;
19+
}
20+
set hoster(value: Hoster[]) {
21+
(_private.get(this) || _private.set(this, {}).get(this)).hoster = value;
22+
}
23+
24+
public toJSON(): object {
25+
return objectMerge(this, _private.get(this));
26+
}
27+
}

lib/HosterScrapper.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import { Scrapper } from './Scrapper';
2-
import { Runner } from "./Runner";
3-
import { HosterInfo } from "./HosterInfo";
4-
5-
6-
export type HosterScrapperExec = (args: any) => HosterInfo|Promise<HosterInfo|null>|null;
7-
8-
export class HosterScrapper extends Scrapper {
9-
constructor({ name, domain, runner, runnerOptions={}, exec }: { name:string, domain?:string[]|string, runner:Runner|string, runnerOptions?:any, exec:HosterScrapperExec }) {
10-
super({
11-
name,
12-
type: 'link',
13-
domain,
14-
runner,
15-
runnerOptions,
16-
exec
17-
});
18-
}
19-
}
1+
import { HosterInfo } from './HosterInfo';
2+
import { Runner } from './Runner';
3+
import { Scrapper } from './Scrapper';
4+
5+
export type HosterScrapperExec = (args: any) => HosterInfo | Promise<HosterInfo | null> | null;
6+
7+
export class HosterScrapper extends Scrapper {
8+
constructor({ name, domain, runner, runnerOptions= {}, exec }:
9+
{ name: string, domain?: string[] | string, runner: Runner | string, runnerOptions?: any, exec: HosterScrapperExec }) {
10+
super({
11+
name,
12+
type: 'link',
13+
domain,
14+
runner,
15+
runnerOptions,
16+
exec
17+
});
18+
}
19+
}

lib/Info.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export class Info {
2-
3-
}
1+
export class Info {
2+
3+
}

lib/Runner.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { ScrapperExec } from "./Scrapper";
2-
import { Info } from "./Info";
3-
4-
5-
export type RunnerFunction = (o:{url:string, scrapper:ScrapperExec, options:any}) => Info|Promise<Info|null>|null;
6-
7-
export class Runner {
8-
public type:string;
9-
public run:RunnerFunction;
10-
11-
constructor(type: string, f: RunnerFunction) {
12-
this.type = type;
13-
this.run = f;
14-
}
15-
}
1+
import { Info } from './Info';
2+
import { ScrapperExec } from './Scrapper';
3+
4+
export type RunnerFunction = (o: {url: string, scrapper: ScrapperExec, options: any}) => Info | Promise<Info | null> | null;
5+
6+
export class Runner {
7+
public type: string;
8+
public run: RunnerFunction;
9+
10+
constructor(type: string, f: RunnerFunction) {
11+
this.type = type;
12+
this.run = f;
13+
}
14+
}

lib/RunnerList.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
import { Runner } from "./Runner";
2-
3-
4-
export class RunnerList extends Array<Runner> {
5-
constructor(length: number)
6-
constructor(...elements: Runner[])
7-
constructor(...args: any[]) {
8-
super(...args);
9-
}
10-
11-
getByType(type: string): Runner|undefined {
12-
return this.find(e => e.type === type);
13-
}
14-
toMap(): Map<string, Runner> {
15-
return new Map(this.map(e => [ e.type, e ]) as [string, Runner][]);
16-
}
17-
}
1+
import { Runner } from './Runner';
2+
3+
export class RunnerList extends Array<Runner> {
4+
constructor(length: number)
5+
constructor(...elements: Runner[])
6+
constructor(...args: any[]) {
7+
super(...args);
8+
}
9+
10+
public getByType(type: string): Runner | undefined {
11+
return this.find((e) => e.type === type);
12+
}
13+
public toMap(): Map<string, Runner> {
14+
return new Map(this.map((e) => [ e.type, e ]) as Array<[string, Runner]>);
15+
}
16+
}

lib/Scrap.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { Info } from './Info';
2-
import { Scrapper } from './Scrapper';
3-
4-
5-
export class Scrap {
6-
public info: Info|null;
7-
public url: string;
8-
public scrapper: string;
9-
10-
constructor({ info, url, scrapper }: {info: Info|null, url: string, scrapper: Scrapper}) {
11-
this.info = info;
12-
this.url = url;
13-
this.scrapper = scrapper.name;
14-
}
15-
}
1+
import { Info } from './Info';
2+
import { Scrapper } from './Scrapper';
3+
4+
export class Scrap {
5+
public info: Info | null;
6+
public url: string;
7+
public scrapper: string;
8+
9+
constructor({ info, url, scrapper }: {info: Info | null, url: string, scrapper: Scrapper}) {
10+
this.info = info;
11+
this.url = url;
12+
this.scrapper = scrapper.name;
13+
}
14+
}

0 commit comments

Comments
 (0)