Skip to content

Commit

Permalink
fix: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 committed Feb 1, 2019
1 parent 12873dc commit d9e1ab9
Show file tree
Hide file tree
Showing 33 changed files with 40 additions and 61 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"opencollective-postinstall": "^2.0.1",
"tree-kill": "^1.2.0",
"tslint": "^5.12.0",
"tslint-no-unused-expression-chai": "^0.1.4",
"typedoc": "^0.11.1",
"typescript": "^3.2.0",
"vuepress": "^0.14.8"
Expand Down
2 changes: 1 addition & 1 deletion packages/midway-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"typings": "dist/index.d.ts",
"scripts": {
"build": "npm run lint && midway-bin build -c",
"lint": "../../node_modules/.bin/tslint --format prose -c ../../tslint.json --fix 'src/**/*.ts'",
"lint": "../../node_modules/.bin/tslint --format prose -c ../../tslint.json --fix 'src/**/*.ts' 'test/**/*.ts'",
"test": "npm run lint && midway-bin clean && NODE_ENV=test midway-bin test --ts",
"cov": "midway-bin clean && midway-bin cov --ts",
"autod": "midway-bin autod"
Expand Down
4 changes: 1 addition & 3 deletions packages/midway-core/src/loading.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* Midway Loading 文件加载
*/
/* tslint:disable:no-unused-expression */
const debug = require('debug')('midway:loading');
const is = require('is-type-of');
const globby = require('globby');
Expand All @@ -18,7 +17,7 @@ function inject(obj, properties, result) {
obj[property] = result;
return;
}
obj[property] || (obj[property] = {});
obj[property] = obj[property] || {};
inject(obj[property], properties, result);
}

Expand Down Expand Up @@ -98,4 +97,3 @@ export function loading(files, options) {

return results;
}
/* tslint:enable:no-unused-expression */
2 changes: 1 addition & 1 deletion packages/midway-core/test/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as extend2 from 'extend2';
describe('/test/base.test.ts', () => {
it('should proxy app when set property', () => {
let app = {};
let pluginContext = {};
const pluginContext = {};

app = new Proxy<any>(app, {
defineProperty(target, prop, attributes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ module.exports = {
enable: true,
path: path.join(__dirname, '../plugins/plugin2'),
}
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ module.exports = {
enable: true,
path: path.join(__dirname, '../plugins/plugin2'),
}
};
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {config, plugin} from '../../../../../src/decorators';
import {provide, async, init, inject} from 'injection';


@provide()
export class A {
config = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ exports.baseService = async (ctx, next) => {
const context = ctx.app.applicationContext;
const baseService = await context.getAsync(BaseService);
ctx.body = baseService.config.c + baseService.plugin2.text;
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ module.exports = {
enable: true,
path: path.join(__dirname, '../plugins/plugin2'),
}
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ exports.error = async (ctx, next) => {
}

ctx.body = 'error';
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ export const plugins = {
plugin2: true
};


export const adapterName = 'google';
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {provide} from 'injection';
import { autowire } from 'injection';
import { autowire, provide } from 'injection';

@provide()
@autowire(false)
Expand All @@ -10,4 +9,3 @@ export class GoogleAdapter {
@provide()
export class BaiduAdapter {
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import {IApplicationContext} from 'injection';

export function adapterFactory(context: IApplicationContext) {
return async (adapterName: string) => {
if(adapterName === 'google') {
return await context.getAsync('googleAdapter');
if (adapterName === 'google') {
return context.getAsync('googleAdapter');
}

if(adapterName === 'baidu') {
return await context.getAsync('baiduAdapter');
if (adapterName === 'baidu') {
return context.getAsync('baiduAdapter');
}
};
}
Expand All @@ -19,4 +19,3 @@ providerWrapper([
provider: adapterFactory
}
]);

Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export function otherFactory3(context: IApplicationContext) {
return new MyTestAuto('test');
}


providerWrapper([
{
id: 'otherFactory',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {config, plugin} from '../../../../../src/decorators';
import {provide, async, init, inject} from 'injection';


@provide()
export class A {
config = {
Expand Down
8 changes: 4 additions & 4 deletions packages/midway-core/test/fixtures/midway/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ export class AgentWorkerLoader extends MidwayLoader {

}

class MidwayApplication extends (<{
class MidwayApplication extends (Application as {
new(...x)
}> Application) {
}) {

get [Symbol.for('egg#loader')]() {
return AppWorkerLoader;
Expand All @@ -68,9 +68,9 @@ class MidwayApplication extends (<{
}
}

class MidwayAgent extends (<{
class MidwayAgent extends (Agent as {
new(...x)
}> Agent) {
}) {

get [Symbol.for('egg#loader')]() {
return AgentWorkerLoader;
Expand Down
5 changes: 2 additions & 3 deletions packages/midway-core/test/fixtures/ts-app-inject/app.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {Loader} from './loader';
import {provide} from 'injection';
import {inject} from 'injection';
import { inject, provide } from 'injection';
import { Loader } from './loader';

@provide()
export class App {
Expand Down
4 changes: 2 additions & 2 deletions packages/midway-core/test/midwayContainer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('/test/midwayContainer.test.ts', () => {
loadDir: path.join(__dirname, './fixtures/ts-app-inject')
});

const app = <App> container.get('app');
const app = container.get('app') as App;
expect(app.loader).not.to.be.undefined;
expect(app.getConfig().a).to.equal(3);
// 其实这里循环依赖了
Expand All @@ -25,7 +25,7 @@ describe('/test/midwayContainer.test.ts', () => {
loadDir: path.join(__dirname, './fixtures/js-app-inject')
});

const app = <App> container.get('app');
const app = container.get('app') as App;
expect(app.getConfig().a).to.equal(1);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/midway-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"typings": "dist/index.d.ts",
"scripts": {
"build": "npm run lint && midway-bin build -c",
"lint": "../../node_modules/.bin/tslint --format prose -c ../../tslint.json --fix 'src/**/*.ts'",
"lint": "../../node_modules/.bin/tslint --format prose -c ../../tslint.json --fix 'src/**/*.ts' 'test/**/*.ts'",
"test": "npm run lint && midway-bin clean && NODE_ENV=test midway-bin test --ts",
"cov": "midway-bin cov --ts",
"ci": "npm run test",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {config, plugin} from 'midway-core';
import {provide, async, init, inject} from 'injection';


@provide()
export class A {
config = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';


import { inject, provide, scope, ScopeEnum } from 'injection';
import { controller, get } from '../../../../../../../src/';

Expand All @@ -26,4 +25,4 @@ export class My {
assert(this.logger.constructor.name === 'ContextLogger');
ctx.body = 'hello';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export class My {
async index(ctx) {
ctx.body = 'root_test';
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';


import { inject, provide, scope, ScopeEnum } from 'injection';
import { controller, get } from '../../../../../../../src/';

Expand All @@ -26,4 +25,4 @@ export class Api {
assert(this.logger.constructor.name === 'ContextLogger');
ctx.body = 'hello';
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';


import { inject, provide, scope, ScopeEnum } from 'injection';
import { controller, get } from '../../../../../../../src/';

Expand All @@ -26,4 +25,4 @@ export class Api {
assert(this.logger.constructor.name === 'ContextLogger');
ctx.body = 'hello';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export class My {
async index(ctx) {
ctx.body = 'root_test';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { HelloService } from '../../lib/HelloService';
@provide()
@controller('/hello')
export class HelloController {
name: Array<string> = ['a', 'b'];
name: string[] = ['a', 'b'];

xxx: string = 'hjjj';
xxx = 'hjjj';

aaaa;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {provide, inject} from 'injection';
import { BaseService } from './service';


@provide()
export class HelloService {
xxx: Array<string> = ['a', 'b'];
xxx: string[] = ['a', 'b'];

name: string;

Expand All @@ -17,4 +16,4 @@ export class HelloService {
}
return `${this.xxx.join(',')}`;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ export const plugins = {
plugin2: true
};


export const adapterName = 'google';
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ export class GoogleAdapter {
export class BaiduAdapter {

}

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { IApplicationContext } from 'injection';
export function adapterFactory(context: IApplicationContext) {
return async (adapterName: string) => {
if (adapterName === 'google') {
return await context.getAsync('googleAdapter');
return context.getAsync('googleAdapter');
}

if (adapterName === 'baidu') {
return await context.getAsync('baiduAdapter');
return context.getAsync('baiduAdapter');
}
};
}
Expand All @@ -30,4 +30,3 @@ providerWrapper([
provider: contextHandler
}
]);

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { config, plugin } from 'midway-core';
import { async, init, inject, provide } from 'injection';


@provide()
export class A {
config = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {Loader} from './loader';
import {provide} from 'injection';
import {inject} from 'injection';
import { inject, provide } from 'injection';
import { Loader } from './loader';

@provide()
export class App {
Expand Down
10 changes: 4 additions & 6 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"extends": "./packages/tslint-midway-contrib/tslint.json",
"linterOptions": {
"exclude": [
"**/test/**"
]
}
"extends": [
"./packages/tslint-midway-contrib/tslint.json",
"tslint-no-unused-expression-chai"
]
}

0 comments on commit d9e1ab9

Please sign in to comment.