Skip to content

Commit

Permalink
style(lint): lint all files again
Browse files Browse the repository at this point in the history
  • Loading branch information
liangchunn committed Oct 16, 2018
1 parent 4774abe commit 3825f21
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 118 deletions.
38 changes: 12 additions & 26 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
{
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
},
"env": {
"node": true,
"mocha": true,
"es6": true
},
"extends": "eslint:recommended",
"rules": {
"indent": [
"error",
2
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
}
},
"env": {
"node": true,
"mocha": true,
"es6": true
},
"extends": "eslint:recommended"
}
8 changes: 6 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"singleQuote": true
}
"singleQuote": true,
"semi": true,
"tabWidth": 2,
"useTabs": false,
"printWidth": 80
}
8 changes: 3 additions & 5 deletions src/CancellationToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ export class CancellationToken {
lastCancellationCheckTime: number;
constructor(cancellationFileName: string, isCancelled: boolean) {
this.isCancelled = !!isCancelled;
this.cancellationFileName = cancellationFileName || crypto.randomBytes(64).toString('hex');
this.cancellationFileName =
cancellationFileName || crypto.randomBytes(64).toString('hex');
this.lastCancellationCheckTime = 0;
}

static createFromJSON(json: CancellationTokenData) {
return new CancellationToken(
json.cancellationFileName,
json.isCancelled
);
return new CancellationToken(json.cancellationFileName, json.isCancelled);
}

toJSON() {
Expand Down
10 changes: 5 additions & 5 deletions src/FilesWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ export class FilesWatcher {
}

this.watchers = this.watchPaths.map((watchPath: string) => {
return chokidar.watch(
watchPath,
{ persistent: true, alwaysStat: true }
)
return chokidar
.watch(watchPath, { persistent: true, alwaysStat: true })
.on('change', (filePath: string, stats: any) => {
if (this.isFileSupported(filePath)) {
(this.listeners['change'] || []).forEach(changeListener => {
Expand Down Expand Up @@ -67,7 +65,9 @@ export class FilesWatcher {

off(event: string, listener: Function) {
if (this.listeners[event]) {
this.listeners[event] = this.listeners[event].filter(oldListener => oldListener !== listener);
this.listeners[event] = this.listeners[event].filter(
oldListener => oldListener !== listener
);
}
}
}
4 changes: 2 additions & 2 deletions src/Message.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NormalizedMessage } from './NormalizedMessage';

export interface Message {
diagnostics: NormalizedMessage[];
lints: NormalizedMessage[];
diagnostics: NormalizedMessage[];
lints: NormalizedMessage[];
}
8 changes: 6 additions & 2 deletions src/WorkResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export class WorkResult {

set(workName: number, result: any) {
if (!this.supports(workName)) {
throw new Error('Cannot set result - work "' + workName + '" is not supported.');
throw new Error(
'Cannot set result - work "' + workName + '" is not supported.'
);
}

this.workResult[workName] = result;
Expand All @@ -27,7 +29,9 @@ export class WorkResult {

get(workName: number) {
if (!this.supports(workName)) {
throw new Error('Cannot get result - work "' + workName + '" is not supported.');
throw new Error(
'Cannot get result - work "' + workName + '" is not supported.'
);
}

return this.workResult[workName];
Expand Down
6 changes: 5 additions & 1 deletion src/WorkSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ export class WorkSet {
workBegin: number;
workEnd: number;

constructor(workDomain: ReadonlyArray<ts.SourceFile> | string[], workNumber: number, workDivision: number) {
constructor(
workDomain: ReadonlyArray<ts.SourceFile> | string[],
workNumber: number,
workDivision: number
) {
this.workDomain = workDomain;
this.workNumber = workNumber;
this.workDivision = workDivision;
Expand Down
25 changes: 9 additions & 16 deletions src/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ const workers: childProcess.ChildProcess[] = [];

for (let num = 0; num < division; num++) {
workers.push(
childProcess.fork(
path.resolve(__dirname, './service.js'),
[],
{
execArgv: ['--max-old-space-size=' + process.env.MEMORY_LIMIT],
env: Object.assign({}, process.env, { WORK_NUMBER: num }),
stdio: ['inherit', 'inherit', 'inherit', 'ipc']
}
)
childProcess.fork(path.resolve(__dirname, './service.js'), [], {
execArgv: ['--max-old-space-size=' + process.env.MEMORY_LIMIT],
env: Object.assign({}, process.env, { WORK_NUMBER: num }),
stdio: ['inherit', 'inherit', 'inherit', 'ipc']
})
);
}

Expand All @@ -46,13 +42,10 @@ process.on('message', (message: Message) => {
workers.forEach(worker => {
worker.on('message', (message: Message) => {
// set result from worker
result.set(
worker.pid,
{
diagnostics: message.diagnostics.map(NormalizedMessage.createFromJSON),
lints: message.lints.map(NormalizedMessage.createFromJSON)
}
);
result.set(worker.pid, {
diagnostics: message.diagnostics.map(NormalizedMessage.createFromJSON),
lints: message.lints.map(NormalizedMessage.createFromJSON)
});

// if we have result from all workers, send merged
if (result.hasAll()) {
Expand Down
2 changes: 1 addition & 1 deletion src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function run(cancellationToken: CancellationToken) {
}
}

process.on('message', (message) => {
process.on('message', message => {
run(CancellationToken.createFromJSON(message));
});

Expand Down
36 changes: 17 additions & 19 deletions src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
{
"compilerOptions": {
"target": "es5",
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"suppressImplicitAnyIndexErrors": true,
"strictNullChecks": false,
"lib": [
"es5", "es2015.core", "dom"
],
"module": "commonjs",
"moduleResolution": "node",
"declaration": true,
"outDir": "../lib",
"declarationDir": "../lib/types"
}
}
"compilerOptions": {
"target": "es5",
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"suppressImplicitAnyIndexErrors": true,
"strictNullChecks": false,
"lib": ["es5", "es2015.core", "dom"],
"module": "commonjs",
"moduleResolution": "node",
"declaration": true,
"outDir": "../lib",
"declarationDir": "../lib/types"
}
}
55 changes: 24 additions & 31 deletions src/tslint.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"max-line-length": [false, 140],
"object-literal-sort-keys": false,
"interface-name": [true, "never-prefix"],
"member-ordering": [
false
],
"no-object-literal-type-assertion":false,
"no-var-requires": false,
"no-string-literal": false,
"ordered-imports":false,
"prefer-object-spread": false,
"ban-types": false,
"arrow-parens": false,
"member-access": [
false
],
"trailing-comma": [false],
"triple-equals": [
true
],
"variable-name": [true,
"ban-keywords",
"check-format",
"allow-leading-underscore",
"allow-pascal-case"
],
"no-namespace": false
}
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"object-literal-sort-keys": false,
"interface-name": [true, "never-prefix"],
"member-ordering": [false],
"no-object-literal-type-assertion": false,
"no-var-requires": false,
"no-string-literal": false,
"ordered-imports": false,
"prefer-object-spread": false,
"ban-types": false,
"arrow-parens": false,
"member-access": [false],
"trailing-comma": [false],
"triple-equals": [true],
"variable-name": [
true,
"ban-keywords",
"check-format",
"allow-leading-underscore",
"allow-pascal-case"
],
"no-namespace": false
}
}
21 changes: 13 additions & 8 deletions src/types/vue-template-compiler.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ declare module 'vue-template-compiler' {

interface CompiledResultFunctions {
render: () => VNode;
staticRenderFns: (() => VNode)[];
staticRenderFns: Array<() => VNode>;
}

interface ModuleOptions {
Expand All @@ -36,7 +36,10 @@ declare module 'vue-template-compiler' {
staticKeys?: string[];
}

type DirectiveFunction = (node: ASTElement, directiveMeta: ASTDirective) => void;
type DirectiveFunction = (
node: ASTElement,
directiveMeta: ASTDirective
) => void;

/*
* AST Types
Expand All @@ -49,7 +52,7 @@ declare module 'vue-template-compiler' {
* - 3: CHILDREN - self un-optimizable but have fully optimizable children
* - 4: PARTIAL - self un-optimizable with some un-optimizable children
*/
export type SSROptimizability = 0 | 1 | 2 | 3 | 4
export type SSROptimizability = 0 | 1 | 2 | 3 | 4;

export interface ASTModifiers {
[key: string]: boolean;
Expand Down Expand Up @@ -83,7 +86,7 @@ declare module 'vue-template-compiler' {
export interface ASTElement {
type: 1;
tag: string;
attrsList: { name: string; value: any }[];
attrsList: Array<{ name: string; value: any }>;
attrsMap: Record<string, any>;
parent: ASTElement | undefined;
children: ASTNode[];
Expand All @@ -97,8 +100,8 @@ declare module 'vue-template-compiler' {
hasBindings?: boolean;

text?: string;
attrs?: { name: string; value: any }[];
props?: { name: string; value: string }[];
attrs?: Array<{ name: string; value: any }>;
props?: Array<{ name: string; value: string }>;
plain?: boolean;
pre?: true;
ns?: string;
Expand Down Expand Up @@ -162,7 +165,7 @@ declare module 'vue-template-compiler' {
type: 2;
expression: string;
text: string;
tokens: (string | Record<string, any>)[];
tokens: Array<string | Record<string, any>>;
static?: boolean;
// 2.4 ssr optimization
ssrOptimizability?: SSROptimizability;
Expand Down Expand Up @@ -218,7 +221,9 @@ declare module 'vue-template-compiler' {
options?: CompilerOptions
): CompiledResult;

export function ssrCompileToFunctions(template: string): CompiledResultFunctions;
export function ssrCompileToFunctions(
template: string
): CompiledResultFunctions;

export function parseComponent(
file: string,
Expand Down

0 comments on commit 3825f21

Please sign in to comment.