Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Commit 68a8801

Browse files
committed
use more strict eslint rules & update deps
1 parent a0d8b69 commit 68a8801

55 files changed

Lines changed: 748 additions & 603 deletions

Some content is hidden

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

.eslintrc

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
{
2-
"extends": [
3-
"eslint:recommended",
4-
"plugin:@typescript-eslint/recommended",
5-
"prettier",
6-
"prettier/@typescript-eslint"
7-
],
8-
"plugins": ["@typescript-eslint"],
2+
"extends": ["alloy", "alloy/typescript"],
93
"rules": {
104
"no-console": "off",
11-
"no-unused-vars": "error",
12-
"semi": ["error", "never"],
5+
"no-unused-vars": "off",
6+
"no-implicit-coercion": [2, { "number": false }],
137
"quotes": [
148
"error",
159
"single",
1610
{
1711
"avoidEscape": true
1812
}
1913
],
14+
"semi": ["error", "never"],
15+
"max-params": "off",
2016
"@typescript-eslint/explicit-member-accessibility": "off",
2117
"@typescript-eslint/explicit-function-return-type": "off",
2218
"@typescript-eslint/interface-name-prefix": "off",

lib/auth/login.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function checkAuth(credential) {
1616
return __awaiter(this, void 0, void 0, function* () {
1717
const { tmpSecretId, tmpSecretKey, tmpToken } = credential;
1818
tcbService.setCredential(tmpSecretId, tmpSecretKey, tmpToken);
19-
return yield tcbService.request('DescribeEnvs');
19+
return tcbService.request('DescribeEnvs');
2020
});
2121
}
2222
const LoginRes = {
@@ -94,13 +94,8 @@ function loginWithKey(secretId, secretKey) {
9494
exports.loginWithKey = loginWithKey;
9595
function login(options = {}) {
9696
return __awaiter(this, void 0, void 0, function* () {
97-
if (options && options.key) {
98-
const { secretId, secretKey } = options;
99-
return yield loginWithKey(secretId, secretKey);
100-
}
101-
else {
102-
return yield loginWithToken(options);
103-
}
97+
const { secretId, secretKey, key } = options;
98+
return key ? loginWithKey(secretId, secretKey) : loginWithToken(options);
10499
});
105100
}
106101
exports.login = login;

lib/commands/functions/delete.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function deleteFunc(ctx) {
4242
}
4343
if (isBatchDelete) {
4444
const names = functions.map(item => item.name);
45-
return yield function_1.batchDeleteFunctions({
45+
return function_1.batchDeleteFunctions({
4646
names,
4747
envId
4848
});

lib/commands/functions/deploy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function deploy(ctx, commandOptions) {
3535
}
3636
}
3737
if (isBatchCreating) {
38-
return yield function_1.batchCreateFunctions({
38+
return function_1.batchCreateFunctions({
3939
envId,
4040
force,
4141
functions,

lib/commands/functions/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function getFunctionContext(name, envId, configPath) {
3535
if (!assignEnvId) {
3636
throw new error_1.CloudBaseError('未识别到有效的环境 Id 变量,请在项目根目录进行操作或通过 envId 参数指定环境 Id');
3737
}
38-
let { functions } = cloudBaseConfig;
38+
let { functions = [] } = cloudBaseConfig;
3939
const ctx = {
4040
name: name,
4141
functions,

lib/commands/functions/invoke.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const error_1 = require("../../error");
1717
const logger_1 = require("../../logger");
1818
const function_1 = require("../../function");
1919
function invoke(ctx, jsonStringParams) {
20+
var _a;
2021
return __awaiter(this, void 0, void 0, function* () {
2122
const { name, envId, functions } = ctx;
2223
let isBatchInvoke = false;
@@ -43,14 +44,14 @@ function invoke(ctx, jsonStringParams) {
4344
}
4445
}
4546
if (isBatchInvoke) {
46-
return yield function_1.batchInvokeFunctions({
47+
return function_1.batchInvokeFunctions({
4748
envId,
4849
functions,
4950
log: true
5051
});
5152
}
5253
const func = functions.find(item => item.name === name);
53-
const configParams = func && func.params ? func.params : undefined;
54+
const configParams = ((_a = func) === null || _a === void 0 ? void 0 : _a.params) ? func.params : undefined;
5455
const result = yield function_1.invokeFunction({
5556
envId,
5657
functionName: name,

lib/commands/functions/trigger-create.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function triggerCreate(ctx) {
3333
}
3434
}
3535
if (isBatchCreateTrigger) {
36-
return yield function_1.batchCreateTriggers({
36+
return function_1.batchCreateTriggers({
3737
envId,
3838
functions
3939
});

lib/commands/functions/trigger-delete.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const function_1 = require("../../function");
1818
function triggerDelete(ctx, triggerName) {
1919
return __awaiter(this, void 0, void 0, function* () {
2020
const { name, envId, functions } = ctx;
21-
let isBtachDeleteTriggers;
21+
let isBatchDeleteTriggers;
2222
let isBatchDeleteFunctionTriggers = false;
2323
if (!name) {
2424
const answer = yield inquirer_1.default.prompt({
@@ -34,14 +34,14 @@ function triggerDelete(ctx, triggerName) {
3434
message: '确定要删除配置文件中的【全部云函数】的全部触发器?',
3535
default: false
3636
});
37-
isBtachDeleteTriggers = reConfirm;
37+
isBatchDeleteTriggers = reConfirm;
3838
}
39-
if (!isBtachDeleteTriggers) {
39+
if (!isBatchDeleteTriggers) {
4040
throw new error_1.CloudBaseError('请指定云函数名称以及触发器名称!');
4141
}
4242
}
43-
if (isBtachDeleteTriggers) {
44-
return yield function_1.batchDeleteTriggers({
43+
if (isBatchDeleteTriggers) {
44+
return function_1.batchDeleteTriggers({
4545
envId,
4646
functions,
4747
});
@@ -60,7 +60,7 @@ function triggerDelete(ctx, triggerName) {
6060
}
6161
if (isBatchDeleteFunctionTriggers) {
6262
const func = functions.find(item => item.name === name);
63-
return yield function_1.batchDeleteTriggers({
63+
return function_1.batchDeleteTriggers({
6464
envId,
6565
functions: [func],
6666
});

lib/commands/gateway/delete.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function deleteGw(ctx, commandOptions) {
2727
path: servicePath,
2828
gatewayId: serviceId
2929
});
30-
loading.succeed(`HTTP Service 删除成功!`);
30+
loading.succeed('HTTP Service 删除成功!');
3131
}
3232
catch (e) {
3333
loading.stop();

lib/commands/gateway/domain-query.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ function queryGwDomain(ctx, commandOptions) {
2020
throw new error_1.CloudBaseError('请指定需要查询的环境ID或HTTP service域名!');
2121
}
2222
const loading = utils_1.loadingFactory();
23-
loading.start(`查询HTTP service域名中...`);
23+
loading.start('查询HTTP service域名中...');
2424
try {
2525
const res = yield gateway_1.queryGatewayDomain({
2626
envId,
2727
domain: domainName
2828
});
29-
loading.succeed(`查询HTTP service域名成功!`);
29+
loading.succeed('查询HTTP service域名成功!');
3030
const head = ['HTTP service domain', 'CreateTime'];
3131
const tableData = res.ServiceSet.map(item => [
3232
item.Domain,

0 commit comments

Comments
 (0)