Skip to content

Commit 30f442d

Browse files
przepompowniaiamcco
authored andcommitted
Prepare to use tslint (#23)
* Prepare to use tslint * add newline character * Require tslint as a dev dependency * Add `fix` command * Make automatic fixes by tslint
1 parent 1c1968c commit 30f442d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2104
-2025
lines changed

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
"build-docs": "rm ./src/docs/builtin-docs.json && ./bin/build-docs.js",
1818
"build": "rm -rf ./out && webpack",
1919
"watch": "webpack -w",
20-
"test": "mocha test/src/**/*.ts --require ts-node/register"
20+
"test": "mocha test/src/**/*.ts --require ts-node/register",
21+
"lint": "tslint -c tslint.json {.,test}/src/**/*.ts",
22+
"fix": "tslint -c tslint.json --fix {.,test}/src/**/*.ts"
2123
},
2224
"bin": {
2325
"vim-language-server": "./bin/index.js"
@@ -39,6 +41,7 @@
3941
"vscode-languageserver": "^5.2.1",
4042
"vscode-uri": "^1.0.6",
4143
"webpack": "^4.41.2",
42-
"webpack-cli": "^3.3.9"
44+
"webpack-cli": "^3.3.9",
45+
"tslint": "^5.20.0"
4346
}
4447
}

src/common/constant.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export const sortTexts = {
2-
one: '00001',
3-
two: '00002',
4-
three: '00003',
5-
four: '00004'
6-
}
2+
one: "00001",
3+
two: "00002",
4+
three: "00003",
5+
four: "00004",
6+
};
77

8-
export const projectRootPatterns = ['.git', 'autoload', 'plugin']
8+
export const projectRootPatterns = [".git", "autoload", "plugin"];

src/common/fuzzy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ export default function fuzzy(origin: string, query: string): number {
1616
}
1717

1818
return score;
19-
};
19+
}

src/common/logger.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { connection } from '../server/connection';
1+
import { connection } from "../server/connection";
22

33
export default function(name: string) {
44
return {
55
log(message: string) {
6-
connection.console.log(`${name}: ${message}`)
6+
connection.console.log(`${name}: ${message}`);
77
},
88
info(message: string) {
9-
connection.console.info(`${name}: ${message}`)
9+
connection.console.info(`${name}: ${message}`);
1010
},
1111
warn(message: string) {
12-
connection.console.warn(`${name}: ${message}`)
12+
connection.console.warn(`${name}: ${message}`);
1313
},
1414
error(message: string) {
15-
connection.console.error(`${name}: ${message}`)
15+
connection.console.error(`${name}: ${message}`);
1616
},
17-
}
17+
};
1818
}

src/common/patterns.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
export type kindPattern = RegExp[]
1+
export type kindPattern = RegExp[];
22

3-
export const errorLinePattern = /[^:]+:\s*(.+?):\s*line\s*([0-9]+)\s*col\s*([0-9]+)/
3+
export const errorLinePattern = /[^:]+:\s*(.+?):\s*line\s*([0-9]+)\s*col\s*([0-9]+)/;
44

5-
export const commentPattern = /^[ \t]*("|')/
5+
export const commentPattern = /^[ \t]*("|')/;
66

7-
export const keywordPattern = /[\w#&$<>.:]/
7+
export const keywordPattern = /[\w#&$<>.:]/;
88

9-
export const builtinFunctionPattern = /^((<SID>|\b(v|g|b|s|l|a):)?[\w#&]+)[ \t]*\([^)]*\)/
9+
export const builtinFunctionPattern = /^((<SID>|\b(v|g|b|s|l|a):)?[\w#&]+)[ \t]*\([^)]*\)/;
1010

11-
export const wordPrePattern = /^.*?(((<SID>|\b(v|g|b|s|l|a):)?[\w#&$.]+)|(<SID>|<SID|<SI|<S|<|\b(v|g|b|s|l|a):))$/
11+
export const wordPrePattern = /^.*?(((<SID>|\b(v|g|b|s|l|a):)?[\w#&$.]+)|(<SID>|<SID|<SI|<S|<|\b(v|g|b|s|l|a):))$/;
1212

13-
export const wordNextPattern = /^((SID>|ID>|D>|>|<SID>|\b(v|g|b|s|l|a):)?[\w#&$.]+|(:[\w#&$.]+)).*?(\r\n|\r|\n)?$/
13+
export const wordNextPattern = /^((SID>|ID>|D>|>|<SID>|\b(v|g|b|s|l|a):)?[\w#&$.]+|(:[\w#&$.]+)).*?(\r\n|\r|\n)?$/;
1414

15-
export const colorschemePattern = /\bcolorscheme[ \t]+\w*$/
15+
export const colorschemePattern = /\bcolorscheme[ \t]+\w*$/;
1616

17-
export const mapCommandPattern = /^([ \t]*(\[ \t]*)?)\w*map[ \t]+/
17+
export const mapCommandPattern = /^([ \t]*(\[ \t]*)?)\w*map[ \t]+/;
1818

19-
export const highlightLinkPattern = /^[ \t]*(hi|highlight)[ \t]+link([ \t]+[^ \t]+)*[ \t]*$/
19+
export const highlightLinkPattern = /^[ \t]*(hi|highlight)[ \t]+link([ \t]+[^ \t]+)*[ \t]*$/;
2020

21-
export const highlightPattern = /^[ \t]*(hi|highlight)([ \t]+[^ \t]+)*[ \t]*$/
21+
export const highlightPattern = /^[ \t]*(hi|highlight)([ \t]+[^ \t]+)*[ \t]*$/;
2222

23-
export const highlightValuePattern = /^[ \t]*(hi|highlight)([ \t]+[^ \t]+)*[ \t]+([^ \t=]+)=[^ \t=]*$/
23+
export const highlightValuePattern = /^[ \t]*(hi|highlight)([ \t]+[^ \t]+)*[ \t]+([^ \t=]+)=[^ \t=]*$/;
2424

25-
export const autocmdPattern = /^[ \t]*(au|autocmd)!?[ \t]+([^ \t,]+,)*[^ \t,]*$/
25+
export const autocmdPattern = /^[ \t]*(au|autocmd)!?[ \t]+([^ \t,]+,)*[^ \t,]*$/;
2626

2727
export const builtinVariablePattern = [
28-
/\bv:\w*$/
29-
]
28+
/\bv:\w*$/,
29+
];
3030

3131
export const optionPattern = [
3232
/(^|[ \t]+)&\w*$/,
33-
/(^|[ \t]+)set(l|local|g|global)?[ \t]+\w+$/
34-
]
33+
/(^|[ \t]+)set(l|local|g|global)?[ \t]+\w+$/,
34+
];
3535

3636
export const notFunctionPattern = [
3737
/^[ \t]*\\$/,
@@ -40,28 +40,28 @@ export const notFunctionPattern = [
4040
/(let|set|colorscheme)[ \t][^ \t]*$/,
4141
/[^([,\\ \t\w#]\w*$/,
4242
/^[ \t]*(hi|highlight)([ \t]+link)?([ \t]+[^ \t]+)*[ \t]*$/,
43-
autocmdPattern
44-
]
43+
autocmdPattern,
44+
];
4545

4646
export const commandPattern = [
4747
/(^|[ \t]):\w+$/,
4848
/^[ \t]*\w+$/,
49-
/:?silent!?[ \t]\w+/
50-
]
49+
/:?silent!?[ \t]\w+/,
50+
];
5151

5252
export const featurePattern = [
53-
/\bhas\([ \t]*["']\w*/
54-
]
53+
/\bhas\([ \t]*["']\w*/,
54+
];
5555

5656
export const expandPattern = [
5757
/\bexpand\(['"]<\w*$/,
58-
/\bexpand\([ \t]*['"]\w*$/
59-
]
58+
/\bexpand\([ \t]*['"]\w*$/,
59+
];
6060

6161
export const notIdentifierPattern = [
6262
commentPattern,
6363
/("|'):\w*$/,
6464
/^[ \t]*\\$/,
6565
/^[ \t]*call[ \t]+[^ \t()]*$/,
66-
/('|"|#|&|\$|<)\w*$/
67-
]
66+
/('|"|#|&|\$|<)\w*$/,
67+
];

src/common/types.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
import { Subscription} from 'rxjs';
2-
import { CompletionItem } from 'vscode-languageserver';
1+
import { Subscription} from "rxjs";
2+
import { CompletionItem } from "vscode-languageserver";
33

44
export interface IParserHandles {
5-
[uri: string]: Subscription | undefined
5+
[uri: string]: Subscription | undefined;
66
}
77

88
export interface IDiagnostic {
9-
enable: boolean
9+
enable: boolean;
1010
}
1111

1212
export interface ISuggest {
13-
fromRuntimepath: boolean
14-
fromVimruntime: boolean
13+
fromRuntimepath: boolean;
14+
fromVimruntime: boolean;
1515
}
1616

1717
export interface IIndexes {
18-
runtimepath: boolean
19-
gap: number
20-
count: number,
21-
projectRootPatterns: string[]
18+
runtimepath: boolean;
19+
gap: number;
20+
count: number;
21+
projectRootPatterns: string[];
2222
}
2323

2424
// initialization options
2525
export interface IConfig {
26-
iskeyword: string
27-
vimruntime: string
28-
runtimepath: string[]
29-
diagnostic: IDiagnostic
30-
snippetSupport: boolean
31-
suggest: ISuggest
32-
indexes: IIndexes
26+
iskeyword: string;
27+
vimruntime: string;
28+
runtimepath: string[];
29+
diagnostic: IDiagnostic;
30+
snippetSupport: boolean;
31+
suggest: ISuggest;
32+
indexes: IIndexes;
3333
}
3434

3535
// builtin-doc
@@ -41,15 +41,15 @@ export interface BuiltinDoc {
4141
variables: CompletionItem[]
4242
features: CompletionItem[]
4343
expandKeywords: CompletionItem[]
44-
autocmds: CompletionItem[]
45-
}
46-
signatureHelp: Record<string, string[]>
44+
autocmds: CompletionItem[],
45+
};
46+
signatureHelp: Record<string, string[]>;
4747
documents: {
4848
functions: Record<string, string[]>
4949
commands: Record<string, string[]>
5050
options: Record<string, string[]>
5151
variables: Record<string, string[]>
5252
features: Record<string, string[]>
53-
expandKeywords: Record<string, string[]>
54-
}
53+
expandKeywords: Record<string, string[]>,
54+
};
5555
}

0 commit comments

Comments
 (0)