xshell 1.0.157 → 1.0.158
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/git.d.ts +3 -2
- package/git.js +16 -11
- package/package.json +20 -19
- package/path.d.ts +2 -2
- package/process.d.ts +4 -1
- package/process.js +15 -3
- package/prototype.browser.d.ts +10 -2
- package/prototype.browser.js +14 -0
- package/prototype.d.ts +10 -2
- package/prototype.js +14 -0
- package/utils.browser.d.ts +1 -1
- package/utils.d.ts +1 -1
- package/xlint.d.ts +1 -1
- package/xlint.js +34 -32
package/git.d.ts
CHANGED
|
@@ -30,10 +30,11 @@ export declare class Git {
|
|
|
30
30
|
print?: boolean;
|
|
31
31
|
remote?: string;
|
|
32
32
|
}): Promise<void>;
|
|
33
|
-
/**
|
|
33
|
+
/** 创建或者切换到分支
|
|
34
|
+
- branch?: `'main'` */
|
|
34
35
|
checkout(branch?: 'main'): Promise<void>;
|
|
35
36
|
checkout(branch?: string): Promise<void>;
|
|
36
|
-
_checkout(branch?: string): Promise<void>;
|
|
37
|
+
_checkout(branch: string, create: boolean, remote_branch?: string): Promise<void>;
|
|
37
38
|
get_version_info(version?: string): Promise<{
|
|
38
39
|
version: string;
|
|
39
40
|
branch: string;
|
package/git.js
CHANGED
|
@@ -86,20 +86,25 @@ export class Git {
|
|
|
86
86
|
console.log('更新远程分支成功');
|
|
87
87
|
}
|
|
88
88
|
async checkout(branch = 'main') {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
else {
|
|
89
|
+
let create = false;
|
|
90
|
+
if (branch !== 'main') {
|
|
92
91
|
const branches = await this.get_branches(false);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
await this.call(['checkout', '-b', branch], print_no_command);
|
|
98
|
-
}
|
|
92
|
+
// 无本地及远程对应分支
|
|
93
|
+
if (!(branches.includes(branch) ||
|
|
94
|
+
branches.find(b => b.endsWith(`/${branch}`) && b.startsWith('remotes/'))))
|
|
95
|
+
create = true;
|
|
99
96
|
}
|
|
97
|
+
if (create)
|
|
98
|
+
console.log(`创建分支 ${branch}`);
|
|
99
|
+
await this._checkout(branch, create);
|
|
100
100
|
}
|
|
101
|
-
async _checkout(branch) {
|
|
102
|
-
await this.call([
|
|
101
|
+
async _checkout(branch, create, remote_branch) {
|
|
102
|
+
await this.call([
|
|
103
|
+
'checkout',
|
|
104
|
+
...create ? ['-b'] : [],
|
|
105
|
+
branch,
|
|
106
|
+
...remote_branch ? [remote_branch] : []
|
|
107
|
+
], print_no_command);
|
|
103
108
|
}
|
|
104
109
|
async get_version_info(version) {
|
|
105
110
|
const branch = await this.get_branch();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xshell",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.158",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -49,23 +49,24 @@
|
|
|
49
49
|
]
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@babel/core": "^7.
|
|
53
|
-
"@babel/parser": "^7.
|
|
54
|
-
"@babel/traverse": "^7.
|
|
52
|
+
"@babel/core": "^7.25.2",
|
|
53
|
+
"@babel/parser": "^7.25.3",
|
|
54
|
+
"@babel/traverse": "^7.25.3",
|
|
55
55
|
"@koa/cors": "^5.0.0",
|
|
56
|
+
"@stylistic/eslint-plugin": "^2.6.0",
|
|
56
57
|
"@svgr/webpack": "^8.1.0",
|
|
57
58
|
"@types/sass-loader": "^8.0.8",
|
|
58
|
-
"@types/ws": "^8.5.
|
|
59
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
60
|
-
"@typescript-eslint/parser": "^
|
|
61
|
-
"@typescript-eslint/utils": "^
|
|
59
|
+
"@types/ws": "^8.5.12",
|
|
60
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
61
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
62
|
+
"@typescript-eslint/utils": "^8.0.0",
|
|
62
63
|
"@xterm/addon-fit": "^0.10.0",
|
|
63
64
|
"@xterm/addon-web-links": "^0.11.0",
|
|
64
65
|
"@xterm/addon-webgl": "^0.18.0",
|
|
65
66
|
"@xterm/xterm": "^5.5.0",
|
|
66
67
|
"ali-oss": "^6.20.0",
|
|
67
68
|
"archiver": "^7.0.1",
|
|
68
|
-
"byte-size": "^
|
|
69
|
+
"byte-size": "^9.0.0",
|
|
69
70
|
"chalk": "^5.3.0",
|
|
70
71
|
"chardet": "^2.0.0",
|
|
71
72
|
"cli-table3": "^0.6.5",
|
|
@@ -74,13 +75,13 @@
|
|
|
74
75
|
"commander": "^12.1.0",
|
|
75
76
|
"css-loader": "^7.1.2",
|
|
76
77
|
"emoji-regex": "^10.3.0",
|
|
77
|
-
"eslint": "^9.
|
|
78
|
+
"eslint": "^9.8.0",
|
|
78
79
|
"eslint-plugin-import": "^2.29.1",
|
|
79
|
-
"eslint-plugin-react": "^7.
|
|
80
|
+
"eslint-plugin-react": "^7.35.0",
|
|
80
81
|
"gulp-sort": "^2.0.0",
|
|
81
82
|
"hash-string": "^1.0.0",
|
|
82
83
|
"https-proxy-agent": "^7.0.5",
|
|
83
|
-
"i18next": "^23.12.
|
|
84
|
+
"i18next": "^23.12.2",
|
|
84
85
|
"i18next-scanner": "^4.5.0",
|
|
85
86
|
"koa": "^2.15.3",
|
|
86
87
|
"koa-compress": "^5.1.1",
|
|
@@ -90,11 +91,11 @@
|
|
|
90
91
|
"mime-types": "^2.1.35",
|
|
91
92
|
"ora": "^8.0.1",
|
|
92
93
|
"react": "^18.3.1",
|
|
93
|
-
"react-i18next": "^
|
|
94
|
+
"react-i18next": "^15.0.0",
|
|
94
95
|
"react-object-model": "^1.2.8",
|
|
95
96
|
"resolve-path": "^1.4.0",
|
|
96
97
|
"sass": "^1.77.8",
|
|
97
|
-
"sass-loader": "^
|
|
98
|
+
"sass-loader": "^16.0.0",
|
|
98
99
|
"source-map-loader": "^5.0.0",
|
|
99
100
|
"strip-ansi": "^7.1.0",
|
|
100
101
|
"style-loader": "^4.0.0",
|
|
@@ -102,9 +103,9 @@
|
|
|
102
103
|
"tough-cookie": "^4.1.4",
|
|
103
104
|
"ts-loader": "^9.5.1",
|
|
104
105
|
"tslib": "^2.6.3",
|
|
105
|
-
"typescript": "^5.5.
|
|
106
|
+
"typescript": "^5.5.4",
|
|
106
107
|
"ua-parser-js": "^2.0.0-beta.3",
|
|
107
|
-
"undici": "^6.19.
|
|
108
|
+
"undici": "^6.19.5",
|
|
108
109
|
"vinyl": "^3.0.0",
|
|
109
110
|
"vinyl-fs": "^4.0.0",
|
|
110
111
|
"webpack": "^5.93.0",
|
|
@@ -112,20 +113,20 @@
|
|
|
112
113
|
"ws": "^8.18.0"
|
|
113
114
|
},
|
|
114
115
|
"devDependencies": {
|
|
115
|
-
"@babel/types": "^7.
|
|
116
|
+
"@babel/types": "^7.25.2",
|
|
116
117
|
"@types/ali-oss": "^6.16.11",
|
|
117
118
|
"@types/archiver": "^6.0.2",
|
|
118
119
|
"@types/babel__traverse": "^7.20.6",
|
|
119
120
|
"@types/byte-size": "^8.1.2",
|
|
120
121
|
"@types/chardet": "^0.8.3",
|
|
121
|
-
"@types/eslint": "^
|
|
122
|
+
"@types/eslint": "^9.6.0",
|
|
122
123
|
"@types/estree": "^1.0.5",
|
|
123
124
|
"@types/gulp-sort": "^2.0.4",
|
|
124
125
|
"@types/koa": "^2.15.0",
|
|
125
126
|
"@types/koa-compress": "^4.0.6",
|
|
126
127
|
"@types/lodash": "^4.17.7",
|
|
127
128
|
"@types/mime-types": "^2.1.4",
|
|
128
|
-
"@types/node": "^
|
|
129
|
+
"@types/node": "^22.0.2",
|
|
129
130
|
"@types/react": "^18.3.3",
|
|
130
131
|
"@types/through2": "^2.0.41",
|
|
131
132
|
"@types/tough-cookie": "^4.0.5",
|
package/path.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export declare function extname(path: string): string;
|
|
|
55
55
|
/** `/` */
|
|
56
56
|
export declare const sep = "/";
|
|
57
57
|
/** The platform-specific file delimiter. ';' or ':'. */
|
|
58
|
-
export declare const delimiter: "
|
|
58
|
+
export declare const delimiter: ";" | ":";
|
|
59
59
|
/** Returns an object from a path string - the opposite of format().
|
|
60
60
|
@param path path to evaluate.
|
|
61
61
|
@throws {TypeError} if `path` is not a string. */
|
|
@@ -83,7 +83,7 @@ export declare let path: {
|
|
|
83
83
|
basename: typeof basename;
|
|
84
84
|
extname: typeof extname;
|
|
85
85
|
sep: string;
|
|
86
|
-
delimiter: "
|
|
86
|
+
delimiter: ";" | ":";
|
|
87
87
|
parse: typeof parse;
|
|
88
88
|
format: typeof format;
|
|
89
89
|
toNamespacedPath: typeof toNamespacedPath;
|
package/process.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ChildProcess } from 'child_process';
|
|
2
2
|
import './prototype.js';
|
|
3
3
|
import { Encoding } from './file.js';
|
|
4
|
+
import type { MyProxy } from './net.js';
|
|
4
5
|
import { inspect } from './utils.js';
|
|
5
6
|
export declare const exe_nodejs: string;
|
|
6
7
|
export declare const platform: NodeJS.Platform;
|
|
@@ -21,6 +22,8 @@ interface StartOptions {
|
|
|
21
22
|
cwd?: string;
|
|
22
23
|
/** `process.env` 覆盖/添加到 process.env 的环境变量 */
|
|
23
24
|
envs?: Record<string, string>;
|
|
25
|
+
/** 创建子进程时添加 http_proxy, https_proxy, no_proxy 环境变量以启用代理 */
|
|
26
|
+
proxy?: MyProxy | true;
|
|
24
27
|
/** `'utf-8'` 子进程输出编码 child output encoding */
|
|
25
28
|
encoding?: Encoding | 'binary';
|
|
26
29
|
/** `true` print 选项,支持设置细项 print option (with details) */
|
|
@@ -57,7 +60,7 @@ interface StartOptions {
|
|
|
57
60
|
- print?: `true` print 选项,支持设置细项 print option (with details)
|
|
58
61
|
- stdio?: `'pipe'` 设置为 'ignore' 时忽略 stdio 处理 when 'ignore' then ignore stdio processing
|
|
59
62
|
- detached?: `false` 是否断开和 child 的关系 (ignore stdio, unref) whether to break the connection with child (ignore stdio, unref) */
|
|
60
|
-
export declare function start(exe: string, args?: string[], { cwd, encoding, print, stdio, detached, envs, window: _window, }?: StartOptions): Promise<ChildProcess>;
|
|
63
|
+
export declare function start(exe: string, args?: string[], { cwd, encoding, print, stdio, detached, envs, window: _window, proxy, }?: StartOptions): Promise<ChildProcess>;
|
|
61
64
|
export declare function start_nodejs(js: string, args?: string[], options?: StartOptions): Promise<ChildProcess>;
|
|
62
65
|
export interface CallOptions extends StartOptions {
|
|
63
66
|
throw_code?: boolean;
|
package/process.js
CHANGED
|
@@ -18,14 +18,26 @@ export const print_no_command = { print: { command: false, code: false, stdout:
|
|
|
18
18
|
- print?: `true` print 选项,支持设置细项 print option (with details)
|
|
19
19
|
- stdio?: `'pipe'` 设置为 'ignore' 时忽略 stdio 处理 when 'ignore' then ignore stdio processing
|
|
20
20
|
- detached?: `false` 是否断开和 child 的关系 (ignore stdio, unref) whether to break the connection with child (ignore stdio, unref) */
|
|
21
|
-
export async function start(exe, args = [], { cwd, encoding = 'utf-8', print = true, stdio = 'pipe', detached = false, envs, window: _window = true, } = {}) {
|
|
21
|
+
export async function start(exe, args = [], { cwd, encoding = 'utf-8', print = true, stdio = 'pipe', detached = false, envs, window: _window = true, proxy, } = {}) {
|
|
22
|
+
if (proxy === true) {
|
|
23
|
+
const { MyProxy } = await import('./net.js');
|
|
24
|
+
proxy = MyProxy.socks5;
|
|
25
|
+
}
|
|
22
26
|
const options = {
|
|
23
27
|
cwd,
|
|
24
28
|
shell: false,
|
|
25
29
|
windowsHide: !_window,
|
|
26
30
|
stdio,
|
|
27
|
-
...envs ? {
|
|
28
|
-
env: {
|
|
31
|
+
...envs || proxy ? {
|
|
32
|
+
env: {
|
|
33
|
+
...process.env,
|
|
34
|
+
...proxy ? {
|
|
35
|
+
http_proxy: proxy,
|
|
36
|
+
https_proxy: proxy,
|
|
37
|
+
no_proxy: '127.0.0.1,::1,localhost,192.168.0.0/20,192.168.100.0/24'
|
|
38
|
+
} : {},
|
|
39
|
+
...envs
|
|
40
|
+
}
|
|
29
41
|
} : {},
|
|
30
42
|
};
|
|
31
43
|
if (typeof print === 'boolean')
|
package/prototype.browser.d.ts
CHANGED
|
@@ -77,14 +77,22 @@ declare global {
|
|
|
77
77
|
text: string;
|
|
78
78
|
};
|
|
79
79
|
space(this: string): string;
|
|
80
|
-
/** 返回去掉 prefix
|
|
80
|
+
/** 返回去掉 prefix 开头的字符串
|
|
81
|
+
- validate?: `false` 传 true 时确保字符串以 prefix 开头(失败时抛出错误) */
|
|
81
82
|
strip_start(this: string, prefix: string, validate?: boolean): string;
|
|
82
83
|
/** 返回去掉 prefix 开头的字符串,如果没有以 prefix 开头则返回原字符串 */
|
|
83
84
|
strip_if_start(this: string, prefix: string): string;
|
|
84
|
-
/** 返回去掉 suffix
|
|
85
|
+
/** 返回去掉 suffix 结尾的字符串
|
|
86
|
+
- validate?: `false` 传 true 时确保字符串以 suffix 结尾(失败时抛出错误) */
|
|
85
87
|
strip_end(this: string, suffix: string, validate?: boolean): string;
|
|
86
88
|
/** 返回去掉 suffix 结尾的字符串,如果没有以 suffix 结尾则返回原字符串 */
|
|
87
89
|
strip_if_end(this: string, suffix: string): string;
|
|
90
|
+
/** 从 search 字符串出现的位置开始截取到最后
|
|
91
|
+
- include?: `false` 传 true 时包括 search 部分 */
|
|
92
|
+
slice_from(this: string, search: string, include?: boolean): string;
|
|
93
|
+
/** 从 search 字符串出现的位置开始截断,去掉尾部
|
|
94
|
+
- include?: `false` 传 true 时包括 search 部分 */
|
|
95
|
+
slice_to(this: string, search: string, include?: boolean): string;
|
|
88
96
|
/** 等价于 .endsWith('/') */
|
|
89
97
|
isdir: boolean;
|
|
90
98
|
/** 以 `/` 分割的路径,可能以 / 结尾 */
|
package/prototype.browser.js
CHANGED
|
@@ -275,6 +275,20 @@ Object.defineProperties(String.prototype, {
|
|
|
275
275
|
strip_if_end(suffix) {
|
|
276
276
|
return this.endsWith(suffix) ? this.slice(0, -suffix.length) : this;
|
|
277
277
|
},
|
|
278
|
+
slice_from(search, include = false) {
|
|
279
|
+
const i = this.indexOf(search);
|
|
280
|
+
if (i === -1)
|
|
281
|
+
throw new Error(`slice_from 在字符串 ${this} 中找不到 search: ${search}`);
|
|
282
|
+
else
|
|
283
|
+
return this.slice(include ? i : i + search.length);
|
|
284
|
+
},
|
|
285
|
+
slice_to(search, include) {
|
|
286
|
+
const i = this.lastIndexOf(search);
|
|
287
|
+
if (i === -1)
|
|
288
|
+
throw new Error(`slice_to 在字符串 ${this} 中找不到 search: ${search}`);
|
|
289
|
+
else
|
|
290
|
+
return this.slice(0, include ? i + search.length : i);
|
|
291
|
+
},
|
|
278
292
|
space() {
|
|
279
293
|
if (!this)
|
|
280
294
|
return this;
|
package/prototype.d.ts
CHANGED
|
@@ -99,14 +99,22 @@ declare global {
|
|
|
99
99
|
decode_base64(this: string, buffer: true): Buffer;
|
|
100
100
|
decode_base64(this: string, buffer?: boolean): string | Buffer;
|
|
101
101
|
space(this: string): string;
|
|
102
|
-
/** 返回去掉 prefix
|
|
102
|
+
/** 返回去掉 prefix 开头的字符串
|
|
103
|
+
- validate?: `false` 传 true 时确保字符串以 prefix 开头(失败时抛出错误) */
|
|
103
104
|
strip_start(this: string, prefix: string, validate?: boolean): string;
|
|
104
105
|
/** 返回去掉 prefix 开头的字符串,如果没有以 prefix 开头则返回原字符串 */
|
|
105
106
|
strip_if_start(this: string, prefix: string): string;
|
|
106
|
-
/** 返回去掉 suffix
|
|
107
|
+
/** 返回去掉 suffix 结尾的字符串
|
|
108
|
+
- validate?: `false` 传 true 时确保字符串以 suffix 结尾(失败时抛出错误) */
|
|
107
109
|
strip_end(this: string, suffix: string, validate?: boolean): string;
|
|
108
110
|
/** 返回去掉 suffix 结尾的字符串,如果没有以 suffix 结尾则返回原字符串 */
|
|
109
111
|
strip_if_end(this: string, suffix: string): string;
|
|
112
|
+
/** 从 search 字符串出现的位置开始截取到最后
|
|
113
|
+
- include?: `false` 传 true 时包括 search 部分 */
|
|
114
|
+
slice_from(this: string, search: string, include?: boolean): string;
|
|
115
|
+
/** 从 search 字符串出现的位置开始截断,去掉尾部
|
|
116
|
+
- include?: `false` 传 true 时包括 search 部分 */
|
|
117
|
+
slice_to(this: string, search: string, include?: boolean): string;
|
|
110
118
|
/** 等价于 .endsWith('/') */
|
|
111
119
|
isdir: boolean;
|
|
112
120
|
/** 以 `/` 分割的路径,可能以 / 结尾 */
|
package/prototype.js
CHANGED
|
@@ -294,6 +294,20 @@ if (!globalThis.my_prototype_defined) {
|
|
|
294
294
|
strip_if_end(suffix) {
|
|
295
295
|
return this.endsWith(suffix) ? this.slice(0, -suffix.length) : this;
|
|
296
296
|
},
|
|
297
|
+
slice_from(search, include = false) {
|
|
298
|
+
const i = this.indexOf(search);
|
|
299
|
+
if (i === -1)
|
|
300
|
+
throw new Error(`slice_from 在字符串 ${this} 中找不到 search: ${search}`);
|
|
301
|
+
else
|
|
302
|
+
return this.slice(include ? i : i + search.length);
|
|
303
|
+
},
|
|
304
|
+
slice_to(search, include) {
|
|
305
|
+
const i = this.lastIndexOf(search);
|
|
306
|
+
if (i === -1)
|
|
307
|
+
throw new Error(`slice_to 在字符串 ${this} 中找不到 search: ${search}`);
|
|
308
|
+
else
|
|
309
|
+
return this.slice(0, include ? i + search.length : i);
|
|
310
|
+
},
|
|
297
311
|
space() {
|
|
298
312
|
if (!this)
|
|
299
313
|
return this;
|
package/utils.browser.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export declare function encode(str: string): Uint8Array;
|
|
|
68
68
|
在流式处理 (buffer 可能不完整) 时,应使用独立的 TextDecoder 实例调用 decode(buffer, { stream: true }) */
|
|
69
69
|
export declare function decode(buffer: Uint8Array): string;
|
|
70
70
|
/** 字符串字典序比较 */
|
|
71
|
-
export declare function strcmp(l: string, r: string):
|
|
71
|
+
export declare function strcmp(l: string, r: string): 1 | 0 | -1;
|
|
72
72
|
/** 比较 1.10.02 这种版本号
|
|
73
73
|
- l, r: 两个版本号字符串
|
|
74
74
|
- loose?: 宽松模式,允许两个版本号格式(位数)不一致 */
|
package/utils.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare function filter_values<TObj extends Record<string, any>>(obj: TOb
|
|
|
37
37
|
/** 忽略对象中的 keys, 返回新对象 */
|
|
38
38
|
export declare function omit<TObj>(obj: TObj, omit_keys: string[]): TObj;
|
|
39
39
|
/** 字符串字典序比较 */
|
|
40
|
-
export declare function strcmp(l: string, r: string):
|
|
40
|
+
export declare function strcmp(l: string, r: string): 1 | 0 | -1;
|
|
41
41
|
/** 比较 1.10.02 这种版本号
|
|
42
42
|
- l, r: 两个版本号字符串
|
|
43
43
|
- loose?: 宽松模式,允许两个版本号格式(位数)不一致 */
|
package/xlint.d.ts
CHANGED
package/xlint.js
CHANGED
|
@@ -3,6 +3,7 @@ import TSParser from '@typescript-eslint/parser';
|
|
|
3
3
|
import ts_plugin from '@typescript-eslint/eslint-plugin';
|
|
4
4
|
import react_plugin from 'eslint-plugin-react';
|
|
5
5
|
import import_plugin from 'eslint-plugin-import';
|
|
6
|
+
import stylistic_plugin from '@stylistic/eslint-plugin';
|
|
6
7
|
const line_break_pattern = /\r\n|[\r\n\u2028\u2029]/u;
|
|
7
8
|
const meta = {
|
|
8
9
|
fixable: 'whitespace',
|
|
@@ -85,11 +86,11 @@ export const xlint_plugin = {
|
|
|
85
86
|
if (node.alternate && node.alternate.type !== 'IfStatement')
|
|
86
87
|
lint(node.alternate, node);
|
|
87
88
|
},
|
|
88
|
-
WhileStatement: node => lint(node.body, node),
|
|
89
|
-
DoWhileStatement: node => lint(node.body, node),
|
|
90
|
-
ForStatement: node => lint(node.body, node),
|
|
91
|
-
ForInStatement: node => lint(node.body, node),
|
|
92
|
-
ForOfStatement: node => lint(node.body, node)
|
|
89
|
+
WhileStatement: node => { lint(node.body, node); },
|
|
90
|
+
DoWhileStatement: node => { lint(node.body, node); },
|
|
91
|
+
ForStatement: node => { lint(node.body, node); },
|
|
92
|
+
ForInStatement: node => { lint(node.body, node); },
|
|
93
|
+
ForOfStatement: node => { lint(node.body, node); }
|
|
93
94
|
};
|
|
94
95
|
},
|
|
95
96
|
},
|
|
@@ -741,7 +742,7 @@ export const xlint_config = {
|
|
|
741
742
|
parserOptions: {
|
|
742
743
|
ecmaVersion: 'latest',
|
|
743
744
|
sourceType: 'module',
|
|
744
|
-
|
|
745
|
+
projectService: true,
|
|
745
746
|
ecmaFeatures: {
|
|
746
747
|
jsx: true
|
|
747
748
|
},
|
|
@@ -751,6 +752,7 @@ export const xlint_config = {
|
|
|
751
752
|
'@typescript-eslint': ts_plugin,
|
|
752
753
|
react: react_plugin,
|
|
753
754
|
import: import_plugin,
|
|
755
|
+
'@stylistic': stylistic_plugin,
|
|
754
756
|
xlint: xlint_plugin,
|
|
755
757
|
},
|
|
756
758
|
settings: {
|
|
@@ -770,9 +772,9 @@ export const xlint_config = {
|
|
|
770
772
|
'xlint/keep-indent': 'error',
|
|
771
773
|
// 函数使用 function 来声明而不是 const foo = () => { }
|
|
772
774
|
'xlint/func-style': 'error',
|
|
773
|
-
'@
|
|
774
|
-
'@
|
|
775
|
-
'semi-style': ['error', 'first'],
|
|
775
|
+
'@stylistic/semi': ['error', 'never'],
|
|
776
|
+
'@stylistic/no-extra-semi': 'error',
|
|
777
|
+
'@stylistic/semi-style': ['error', 'first'],
|
|
776
778
|
// 使用 ===
|
|
777
779
|
eqeqeq: 'error',
|
|
778
780
|
// 父类尽量返回 this 类型
|
|
@@ -780,7 +782,7 @@ export const xlint_config = {
|
|
|
780
782
|
// 尽量使用 . 访问属性而不是 []
|
|
781
783
|
'@typescript-eslint/dot-notation': 'error',
|
|
782
784
|
// 必须 throw Error
|
|
783
|
-
'@typescript-eslint/
|
|
785
|
+
'@typescript-eslint/only-throw-error': 'error',
|
|
784
786
|
// ------------ async
|
|
785
787
|
// 返回 Promise 的函数一定要标记为 async 函数
|
|
786
788
|
'@typescript-eslint/promise-function-async': 'error',
|
|
@@ -788,60 +790,60 @@ export const xlint_config = {
|
|
|
788
790
|
'@typescript-eslint/return-await': 'error',
|
|
789
791
|
// ------------ 括号
|
|
790
792
|
// a => { } 而不是 (a) => { }
|
|
791
|
-
'arrow-parens': ['error', 'as-needed', { requireForBlockBody: false }],
|
|
793
|
+
'@stylistic/arrow-parens': ['error', 'as-needed', { requireForBlockBody: false }],
|
|
792
794
|
// 不要多余的大括号
|
|
793
795
|
// if (true)
|
|
794
796
|
// console.log()
|
|
795
797
|
curly: ['error', 'multi'],
|
|
796
798
|
// 简单属性不要冗余的大括号 <Component prop='simple-value' />
|
|
797
|
-
'
|
|
799
|
+
'@stylistic/jsx-curly-brace-presence': ['error', 'never'],
|
|
798
800
|
// ------------ 空格
|
|
799
801
|
// { a, b } 这样的对象,大括号里面要有空格
|
|
800
|
-
'@
|
|
802
|
+
'@stylistic/object-curly-spacing': ['error', 'always'],
|
|
801
803
|
// [a, b, c]
|
|
802
|
-
'@
|
|
804
|
+
'@stylistic/comma-spacing': 'error',
|
|
803
805
|
// foo()
|
|
804
|
-
'@
|
|
806
|
+
'@stylistic/func-call-spacing': 'error',
|
|
805
807
|
// a => { } 中箭头左右两边空格
|
|
806
|
-
'arrow-spacing': ['error'],
|
|
808
|
+
'@stylistic/arrow-spacing': ['error'],
|
|
807
809
|
// 注释双斜杠后面要有空格
|
|
808
|
-
'spaced-comment': ['error', 'always', { markers: ['/'] }],
|
|
810
|
+
'@stylistic/spaced-comment': ['error', 'always', { markers: ['/'] }],
|
|
809
811
|
// 函数声明中,名称后面要有空格
|
|
810
|
-
'@
|
|
812
|
+
'@stylistic/space-before-function-paren': 'error',
|
|
811
813
|
// { return true } 这样的 block 大括号里面要有空格
|
|
812
|
-
'block-spacing': ['error', 'always'],
|
|
814
|
+
'@stylistic/block-spacing': ['error', 'always'],
|
|
813
815
|
// aaa: 123
|
|
814
|
-
'@
|
|
816
|
+
'@stylistic/key-spacing': ['error', { beforeColon: false, afterColon: true, mode: 'minimum' }],
|
|
815
817
|
// aaa: string
|
|
816
|
-
'@
|
|
818
|
+
'@stylistic/type-annotation-spacing': 'error',
|
|
817
819
|
// if ()
|
|
818
|
-
'@
|
|
820
|
+
'@stylistic/keyword-spacing': ['error', { before: true, after: true }],
|
|
819
821
|
// if (1) { }
|
|
820
|
-
'@
|
|
822
|
+
'@stylistic/space-before-blocks': 'error',
|
|
821
823
|
// case 1: ...
|
|
822
|
-
'switch-colon-spacing': 'error',
|
|
824
|
+
'@stylistic/switch-colon-spacing': 'error',
|
|
823
825
|
// <Hello name={firstname} />
|
|
824
|
-
'
|
|
826
|
+
'@stylistic/jsx-equals-spacing': ['error', 'never'],
|
|
825
827
|
// 不允许使用 tab
|
|
826
|
-
'no-tabs': 'error',
|
|
828
|
+
'@stylistic/no-tabs': 'error',
|
|
827
829
|
// 使用 \n 换行
|
|
828
|
-
'linebreak-style': ['error', 'unix'],
|
|
830
|
+
'@stylistic/linebreak-style': ['error', 'unix'],
|
|
829
831
|
// 文件以 \n 结尾
|
|
830
|
-
'eol-last': ['error', 'always'],
|
|
832
|
+
'@stylistic/eol-last': ['error', 'always'],
|
|
831
833
|
// ------------ 引号
|
|
832
834
|
// 用单引号
|
|
833
|
-
'jsx-quotes': ['error', 'prefer-single'],
|
|
835
|
+
'@stylistic/jsx-quotes': ['error', 'prefer-single'],
|
|
834
836
|
// 用单引号
|
|
835
|
-
quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: false }],
|
|
837
|
+
'@stylistic/quotes': ['error', 'single', { avoidEscape: true, allowTemplateLiterals: false }],
|
|
836
838
|
// 不要冗余的引号包裹属性
|
|
837
|
-
'quote-props': ['error', 'as-needed', { keywords: false, unnecessary: true }],
|
|
839
|
+
'@stylistic/quote-props': ['error', 'as-needed', { keywords: false, unnecessary: true }],
|
|
838
840
|
// ------------ 其它
|
|
839
841
|
// boolean 属性不要冗余的 ={true} <Component boolprop />
|
|
840
842
|
'react/jsx-boolean-value': ['error', 'never'],
|
|
841
843
|
// 没有 children 的 Component 写成闭合标签 <Component />
|
|
842
844
|
'react/self-closing-comp': 'error',
|
|
843
845
|
// 单行类型声明用 `,` 分割,多行类型声明结尾不要加分号
|
|
844
|
-
'@
|
|
846
|
+
'@stylistic/member-delimiter-style': [
|
|
845
847
|
'error',
|
|
846
848
|
{
|
|
847
849
|
multiline: {
|