xshell 1.0.157 → 1.0.159

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 CHANGED
@@ -30,10 +30,11 @@ export declare class Git {
30
30
  print?: boolean;
31
31
  remote?: string;
32
32
  }): Promise<void>;
33
- /** - branch?: `'main'` */
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
- if (branch === 'main')
90
- await this._checkout('main');
91
- else {
89
+ let create = false;
90
+ if (branch !== 'main') {
92
91
  const branches = await this.get_branches(false);
93
- if (branches.includes(branch) || branches.find(b => b.endsWith(`/${branch}`) && b.startsWith('remotes/')))
94
- await this._checkout(branch);
95
- else {
96
- console.log(`创建分支 ${branch}`);
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(['checkout', branch], print_no_command);
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.157",
3
+ "version": "1.0.159",
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.24.9",
53
- "@babel/parser": "^7.24.8",
54
- "@babel/traverse": "^7.24.8",
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.4",
56
57
  "@svgr/webpack": "^8.1.0",
57
- "@types/sass-loader": "^8.0.8",
58
- "@types/ws": "^8.5.11",
59
- "@typescript-eslint/eslint-plugin": "^7.16.1",
60
- "@typescript-eslint/parser": "^7.16.1",
61
- "@typescript-eslint/utils": "^7.16.1",
58
+ "@types/sass-loader": "^8.0.9",
59
+ "@types/ws": "^8.5.12",
60
+ "@typescript-eslint/eslint-plugin": "^8.2.0",
61
+ "@typescript-eslint/parser": "^8.2.0",
62
+ "@typescript-eslint/utils": "^8.2.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
- "ali-oss": "^6.20.0",
67
+ "ali-oss": "^6.21.0",
67
68
  "archiver": "^7.0.1",
68
- "byte-size": "^8.1.1",
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.7.0",
78
+ "eslint": "^9.9.0",
78
79
  "eslint-plugin-import": "^2.29.1",
79
- "eslint-plugin-react": "^7.34.4",
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.1",
84
+ "i18next": "^23.14.0",
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": "^14.1.3",
94
- "react-object-model": "^1.2.8",
94
+ "react-i18next": "^15.0.1",
95
+ "react-object-model": "^1.2.11",
95
96
  "resolve-path": "^1.4.0",
96
97
  "sass": "^1.77.8",
97
- "sass-loader": "^14.2.1",
98
+ "sass-loader": "^16.0.1",
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.3",
106
+ "typescript": "^5.5.4",
106
107
  "ua-parser-js": "^2.0.0-beta.3",
107
- "undici": "^6.19.2",
108
+ "undici": "^6.19.8",
108
109
  "vinyl": "^3.0.0",
109
110
  "vinyl-fs": "^4.0.0",
110
111
  "webpack": "^5.93.0",
@@ -112,26 +113,26 @@
112
113
  "ws": "^8.18.0"
113
114
  },
114
115
  "devDependencies": {
115
- "@babel/types": "^7.24.9",
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": "^8.56.10",
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": "^20.14.10",
129
+ "@types/node": "^22.4.1",
129
130
  "@types/react": "^18.3.3",
130
131
  "@types/through2": "^2.0.41",
131
132
  "@types/tough-cookie": "^4.0.5",
132
133
  "@types/ua-parser-js": "^0.7.39",
133
134
  "@types/vinyl-fs": "^3.0.5",
134
- "@types/vscode": "^1.91.0",
135
+ "@types/vscode": "^1.92.0",
135
136
  "@types/webpack-bundle-analyzer": "^4.7.0"
136
137
  },
137
138
  "pnpm": {
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;
@@ -1,40 +1,55 @@
1
+ function define(proto, key, func) {
2
+ Object.defineProperty(proto, key, {
3
+ configurable: true,
4
+ writable: true,
5
+ enumerable: false,
6
+ value: func
7
+ });
8
+ }
1
9
  if (!Promise.withResolvers)
2
- Promise.withResolvers = function PromiseWithResolvers() {
10
+ define(Promise, 'withResolvers', function PromiseWithResolvers() {
3
11
  let resolve, reject;
4
12
  let promise = new Promise((_resolve, _reject) => {
5
13
  resolve = _resolve;
6
14
  reject = _reject;
7
15
  });
8
16
  return { promise, resolve, reject };
9
- };
17
+ });
10
18
  if (!Array.prototype.toReversed)
11
- Object.defineProperty(Array.prototype, 'toReversed', {
12
- configurable: true,
13
- writable: true,
14
- enumerable: false,
15
- value: function toReversed() {
16
- return [...this].reverse();
17
- }
19
+ define(Array.prototype, 'toReversed', function toReversed() {
20
+ return [...this].reverse();
18
21
  });
19
22
  if (!Array.prototype.toSpliced)
20
- Object.defineProperty(Array.prototype, 'toSpliced', {
21
- configurable: true,
22
- writable: true,
23
- enumerable: false,
24
- value: function toSpliced(...args) {
25
- const copy = [...this];
26
- copy.splice(...args);
27
- return copy;
28
- }
23
+ define(Array.prototype, 'toSpliced', function toSpliced(...args) {
24
+ const copy = [...this];
25
+ copy.splice(...args);
26
+ return copy;
29
27
  });
30
28
  if (!Array.prototype.at)
31
- Object.defineProperty(Array.prototype, 'at', {
32
- configurable: true,
33
- writable: true,
34
- enumerable: false,
35
- value: function at(index) {
36
- return index >= 0 ? this[index] : this[index + this.length];
37
- }
29
+ define(Array.prototype, 'at', function at(index) {
30
+ return index >= 0 ? this[index] : this[index + this.length];
31
+ });
32
+ // @ts-ignore
33
+ if (!Iterator.prototype.map)
34
+ define(
35
+ // @ts-ignore
36
+ Iterator.prototype, 'map',
37
+ // @ts-ignore
38
+ function iterator_map(callback) {
39
+ const iterator = this;
40
+ let index = 0;
41
+ return {
42
+ [Symbol.iterator]() {
43
+ return this;
44
+ },
45
+ next() {
46
+ const { value, done } = iterator.next();
47
+ if (done)
48
+ return { value: undefined, done: true };
49
+ else
50
+ return { value: callback(value, index++), done: false };
51
+ }
52
+ };
38
53
  });
39
54
  export {};
40
55
  //# sourceMappingURL=polyfill.browser.js.map
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) */
@@ -52,12 +55,12 @@ interface StartOptions {
52
55
  - args: `[]` 参数列表 arguments list
53
56
  - options
54
57
  - cwd?: `继承当前工作目录 process.cwd()` 子进程的工作目录 `inherit the cwd` cwd of the child process.
55
- - envs?: `process.env` 覆盖/添加到 process.env 的环境变量
58
+ - envs?: `process.env` 覆盖/添加到 process.env 的环境变量,传 null 时可以取消设置该变量
56
59
  - encoding?: `'utf-8'` 子进程输出编码 child output encoding
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;
@@ -91,7 +94,7 @@ export interface CallError {
91
94
  - args: `[]` 参数列表 arguments list
92
95
  - options?:
93
96
  - cwd?: `process.cwd()`
94
- - envs?: `process.env` 覆盖/添加到 process.env 的环境变量 overwrite/add to process.env
97
+ - envs?: `process.env` 覆盖/添加到 process.env 的环境变量,传 null 时可以取消设置该变量
95
98
  - encoding?: `'utf-8'` 子进程输出编码, 设置为 binary 时返回 stdout, stderr 类型为 Buffer; 否则是 string
96
99
  child output encoding. When set to binary, return stdout, stderr is of type Buffer; otherwise it is string
97
100
  - print?: `true` print 选项,支持设置细项 print option (with details)
package/process.js CHANGED
@@ -2,7 +2,7 @@ import { spawn } from 'child_process';
2
2
  import os from 'os';
3
3
  import { t } from './i18n/instance.js';
4
4
  import './prototype.js';
5
- import { inspect, DecoderStream } from './utils.js';
5
+ import { inspect, DecoderStream, filter_values } from './utils.js';
6
6
  export const exe_nodejs = process.execPath.fp;
7
7
  export const platform = os.platform();
8
8
  export const username = os.userInfo().username;
@@ -13,19 +13,31 @@ export const print_no_command = { print: { command: false, code: false, stdout:
13
13
  - args: `[]` 参数列表 arguments list
14
14
  - options
15
15
  - cwd?: `继承当前工作目录 process.cwd()` 子进程的工作目录 `inherit the cwd` cwd of the child process.
16
- - envs?: `process.env` 覆盖/添加到 process.env 的环境变量
16
+ - envs?: `process.env` 覆盖/添加到 process.env 的环境变量,传 null 时可以取消设置该变量
17
17
  - encoding?: `'utf-8'` 子进程输出编码 child output encoding
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: { ...process.env, ...envs }
31
+ ...envs || proxy ? {
32
+ env: filter_values({
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')
@@ -77,14 +77,22 @@ declare global {
77
77
  text: string;
78
78
  };
79
79
  space(this: string): string;
80
- /** 返回去掉 prefix 开头的字符串,可选 validate = true 确保字符串以 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 结尾的字符串,可选 validate = true 确保字符串以 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
  /** 以 `/` 分割的路径,可能以 / 结尾 */
@@ -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 开头的字符串,可选 validate = true 确保字符串以 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 结尾的字符串,可选 validate = true 确保字符串以 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;
@@ -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): 0 | 1 | -1;
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): 0 | 1 | -1;
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
@@ -1,3 +1,3 @@
1
1
  import type { ESLint, Linter } from 'eslint';
2
2
  export declare const xlint_plugin: ESLint.Plugin;
3
- export declare const xlint_config: Linter.FlatConfig;
3
+ export declare const xlint_config: Linter.Config;
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
- project: './tsconfig.json',
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
- '@typescript-eslint/semi': ['error', 'never'],
774
- '@typescript-eslint/no-extra-semi': 'error',
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/no-throw-literal': 'error',
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
- 'react/jsx-curly-brace-presence': ['error', 'never'],
799
+ '@stylistic/jsx-curly-brace-presence': ['error', 'never'],
798
800
  // ------------ 空格
799
801
  // { a, b } 这样的对象,大括号里面要有空格
800
- '@typescript-eslint/object-curly-spacing': ['error', 'always'],
802
+ '@stylistic/object-curly-spacing': ['error', 'always'],
801
803
  // [a, b, c]
802
- '@typescript-eslint/comma-spacing': 'error',
804
+ '@stylistic/comma-spacing': 'error',
803
805
  // foo()
804
- '@typescript-eslint/func-call-spacing': 'error',
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
- '@typescript-eslint/space-before-function-paren': 'error',
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
- '@typescript-eslint/key-spacing': ['error', { beforeColon: false, afterColon: true, mode: 'minimum' }],
816
+ '@stylistic/key-spacing': ['error', { beforeColon: false, afterColon: true, mode: 'minimum' }],
815
817
  // aaa: string
816
- '@typescript-eslint/type-annotation-spacing': 'error',
818
+ '@stylistic/type-annotation-spacing': 'error',
817
819
  // if ()
818
- '@typescript-eslint/keyword-spacing': ['error', { before: true, after: true }],
820
+ '@stylistic/keyword-spacing': ['error', { before: true, after: true }],
819
821
  // if (1) { }
820
- '@typescript-eslint/space-before-blocks': 'error',
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
- 'react/jsx-equals-spacing': ['error', 'never'],
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
- '@typescript-eslint/member-delimiter-style': [
846
+ '@stylistic/member-delimiter-style': [
845
847
  'error',
846
848
  {
847
849
  multiline: {