Skip to content
This repository was archived by the owner on Aug 13, 2020. It is now read-only.

Commit 24d769f

Browse files
author
Jianing
committed
fix code format.
1 parent c0cf892 commit 24d769f

File tree

10 files changed

+6852
-19
lines changed

10 files changed

+6852
-19
lines changed

.eslintrc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"extends": [
3+
"eslint:recommended",
4+
"plugin:@typescript-eslint/recommended",
5+
"plugin:@typescript-eslint/eslint-recommended",
6+
"prettier"
7+
],
8+
"parser": "@typescript-eslint/parser",
9+
"plugins": ["prettier", "@typescript-eslint"],
10+
"parserOptions": {
11+
"ecmaVersion": 6,
12+
"sourceType": "module",
13+
"impliedStrict": true
14+
},
15+
"rules": {
16+
"no-sparse-arrays": 0,
17+
"no-self-assign": 0,
18+
"no-unused-vars": 0, // @typescript-eslint/no-unused-vars
19+
"no-inner-declarations": 0,
20+
"prettier/prettier": 2,
21+
"@typescript-eslint/no-unused-vars": 1,
22+
"@typescript-eslint/no-non-null-assertion": 0,
23+
"@typescript-eslint/no-explicit-any": 0,
24+
"@typescript-eslint/no-use-before-define": [2, { "functions": false }],
25+
"@typescript-eslint/ban-ts-ignore": 0,
26+
"@typescript-eslint/interface-name-prefix": 0,
27+
"@typescript-eslint/no-empty-interface": 0,
28+
"@typescript-eslint/camelcase": 0,
29+
"@typescript-eslint/no-inferrable-types": 0,
30+
"@typescript-eslint/explicit-function-return-type": 0,
31+
"@typescript-eslint/type-annotation-spacing": 0,
32+
"@typescript-eslint/no-empty-function": 1
33+
}
34+
}

.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"trailingComma": "es5",
5+
"bracketSpacing": true,
6+
"printWidth": 120,
7+
"arrowParens": "always"
8+
}

__tests__

Whitespace-only changes.

package.json

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"fix": "eslint --ext .ts ./src --fix && prettier --write ./src",
9+
"lint": "eslint --ext .ts"
810
},
911
"repository": {
1012
"type": "git",
@@ -17,9 +19,27 @@
1719
},
1820
"homepage": "https://github.com/ProtoTeam/intern-repo#readme",
1921
"dependencies": {
22+
"@typescript-eslint/eslint-plugin": "^3.8.0",
2023
"lodash": "^4.17.19"
2124
},
2225
"devDependencies": {
23-
"@types/lodash": "^4.14.159"
26+
"@types/lodash": "^4.14.159",
27+
"eslint": "^7.6.0",
28+
"eslint-config-prettier": "^6.11.0",
29+
"prettier": "^2.0.5",
30+
"typescript": "^3.9.7",
31+
"@commitlint/cli": "^8.2.0",
32+
"@commitlint/config-angular": "^8.2.0",
33+
"@types/jest": "^25.2.1",
34+
"@typescript-eslint/eslint-plugin": "^2.0.0",
35+
"@typescript-eslint/parser": "^2.0.0",
36+
"conventional-changelog-cli": "^2.0.28",
37+
"eslint-plugin-prettier": "^3.1.0",
38+
"jest": "^26.0.1",
39+
"jest-extended": "^0.11.2",
40+
"lint-staged": "^10.0.7",
41+
"npm-run-all": "^4.1.5",
42+
"ts-jest": "^25.4.0",
43+
"ts-loader": "^7.0.0"
2444
}
2545
}

src/data-set.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Query } from './query';
44

55
/** 前端数据集模块 */
66
export class DataSet {
7-
87
private data = [];
98

109
constructor(data: Data) {
@@ -31,4 +30,4 @@ export class DataSet {
3130
public query() {
3231
return new Query(this.data);
3332
}
34-
}
33+
}

src/field.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Field } from './types';
22

33
/**
44
* 聚合求和
5-
* @param field
5+
* @param field
66
*/
77
export function SUM(field: string): Field {
88
return {
@@ -13,7 +13,7 @@ export function SUM(field: string): Field {
1313

1414
/**
1515
* 聚合 MAX
16-
* @param field
16+
* @param field
1717
*/
1818
export function MAX(field: string): Field {
1919
return {
@@ -24,7 +24,7 @@ export function MAX(field: string): Field {
2424

2525
/**
2626
* 聚合 MIN
27-
* @param field
27+
* @param field
2828
*/
2929
export function MIN(field: string): Field {
3030
return {
@@ -35,11 +35,11 @@ export function MIN(field: string): Field {
3535

3636
/**
3737
* 无聚合字段
38-
* @param field
38+
* @param field
3939
*/
4040
export function RAW(field: string): Field {
4141
return {
4242
aggregate: 'raw',
4343
field,
4444
};
45-
}
45+
}

src/query.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Data, Field, Options, Order, Datum, Groups } from "./types";
2-
import _ from "lodash";
1+
import { Data, Field, Options, Order, Datum, Groups } from './types';
2+
import _ from 'lodash';
33

44
export class Query {
55
private data: Data;
@@ -30,7 +30,7 @@ export class Query {
3030
* @param asc
3131
*/
3232
public orderBy(fields: string, asc?: boolean): Query {
33-
const order: Order = { order: asc ? "asc" : "desc", orderBy: fields };
33+
const order: Order = { order: asc ? 'asc' : 'desc', orderBy: fields };
3434

3535
this.options = {
3636
...this.options,
@@ -73,7 +73,7 @@ export class Query {
7373
public record(): Data {
7474
const { select, orders, limit, gKey } = this.options;
7575

76-
const agg = select.find((e) => e.aggregate !== "raw");
76+
const agg = select.find((e) => e.aggregate !== 'raw');
7777

7878
if (!agg) {
7979
return _.orderBy(
@@ -107,13 +107,12 @@ export class Query {
107107
}
108108
default:
109109
}
110-
111110
});
112111

113112
return _.orderBy(
114113
res,
115114
orders.map((e) => e.orderBy),
116115
orders.map((e) => e.order)
117-
);;
116+
);
118117
}
119118
}

src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ export type Field = {
1212
readonly aggregate: 'sum' | 'max' | 'min' | 'raw'; // 可扩展
1313
/** 字段名 */
1414
readonly field: string;
15-
}
15+
};
1616

1717
export type Order = {
1818
order?: 'asc' | 'desc';
1919
orderBy?: string;
20-
}
20+
};
2121

2222
export type Options = {
2323
select?: Field[];
2424
orders?: Order[];
2525
limit?: number;
2626
gKey?: string;
27-
}
27+
};
2828

2929
export type Groups = Map<string, Data>;

0 commit comments

Comments
 (0)