From b9e3950282f45857e15cb3aa87e44240933065b0 Mon Sep 17 00:00:00 2001 From: Rapiz Date: Sat, 1 Aug 2020 20:23:07 +0800 Subject: [PATCH] fix(ci): resolve lint failures --- src/access.ts | 4 +-- src/components/PluginForm/locales/en-US.ts | 38 ++++++++++++++-------- src/components/PluginForm/locales/zh-CN.ts | 38 ++++++++++++++-------- src/components/PluginPage/PluginPage.tsx | 4 +-- src/pages/Consumer/Create.tsx | 22 ++++++++++--- src/pages/Consumer/List.tsx | 4 ++- src/pages/Route/List.tsx | 6 ++-- src/pages/Route/transform.ts | 1 + src/pages/SSL/Create.tsx | 5 ++- src/pages/SSL/service.ts | 6 ++-- src/pages/Upstream/Create.tsx | 8 ++++- src/pages/Upstream/List.tsx | 2 +- 12 files changed, 92 insertions(+), 46 deletions(-) diff --git a/src/access.ts b/src/access.ts index cdda4f574d..860d0a989d 100644 --- a/src/access.ts +++ b/src/access.ts @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export default function (initialState: { currentUser?: API.CurrentUser | undefined }) { +export default (initialState: { currentUser?: API.CurrentUser | undefined }) => { const { currentUser } = initialState || {}; return { canAdmin: currentUser && currentUser.access === 'admin', }; -} +}; diff --git a/src/components/PluginForm/locales/en-US.ts b/src/components/PluginForm/locales/en-US.ts index 722c25a9eb..3efc2055eb 100644 --- a/src/components/PluginForm/locales/en-US.ts +++ b/src/components/PluginForm/locales/en-US.ts @@ -14,18 +14,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable no-template-curly-in-string */ export default { 'PluginForm.plugin.limit-conn.desc': '限制并发连接数', 'PluginForm.plugin.limit-conn.property.conn': 'conn', 'PluginForm.plugin.limit-conn.property.conn.extra': '最大并发连接数', 'PluginForm.plugin.limit-conn.property.burst': 'burst', - 'PluginForm.plugin.limit-conn.property.burst.extra': '并发连接数超过 conn,但是低于 conn + burst 时,请求将被延迟处理', + 'PluginForm.plugin.limit-conn.property.burst.extra': + '并发连接数超过 conn,但是低于 conn + burst 时,请求将被延迟处理', 'PluginForm.plugin.limit-conn.property.default_conn_delay': '延迟时间', - 'PluginForm.plugin.limit-conn.property.default_conn_delay.extra': '被延迟处理的请求,需要等待多少秒', + 'PluginForm.plugin.limit-conn.property.default_conn_delay.extra': + '被延迟处理的请求,需要等待多少秒', 'PluginForm.plugin.limit-conn.property.key': 'key', 'PluginForm.plugin.limit-conn.property.key.extra': '用来做限制的依据', 'PluginForm.plugin.limit-conn.property.rejected_code': '拒绝状态码', - 'PluginForm.plugin.limit-conn.property.rejected_code.extra': '当并发连接数超过 conn + burst 的限制时,返回给终端的 HTTP 状态码', + 'PluginForm.plugin.limit-conn.property.rejected_code.extra': + '当并发连接数超过 conn + burst 的限制时,返回给终端的 HTTP 状态码', 'PluginForm.plugin.limit-count.desc': '在指定的时间范围内,限制总的请求次数', 'PluginForm.plugin.limit-count.property.count': '总请求次数', @@ -59,8 +63,7 @@ export default { 'PluginForm.plugin.cors.desc': 'CORS 插件可以为服务端启用 CORS 的返回头', 'PluginForm.plugin.cors.property.allow_origins': '允许跨域访问的 Origin', - 'PluginForm.plugin.cors.property.allow_origins.extra': - '比如 https://somehost.com:8081', + 'PluginForm.plugin.cors.property.allow_origins.extra': '比如 https://somehost.com:8081', 'PluginForm.plugin.cors.property.allow_methods': '允许跨域访问的 Method', 'PluginForm.plugin.fault-injection.desc': '故障注入插件,用来模拟各种后端故障和高延迟', @@ -85,21 +88,27 @@ export default { 'PluginForm.plugin.proxy-cache.desc': '代理缓存插件,缓存后端服务的响应数据', 'PluginForm.plugin.proxy-cache.property.cache_zone': '缓存区域名', - 'PluginForm.plugin.proxy-cache.property.cache_zone.extra': ' 本地目录为 /tmp/${区域名},修改默认区域名必须同时修改 config.yaml', + 'PluginForm.plugin.proxy-cache.property.cache_zone.extra': + ' 本地目录为 /tmp/${区域名},修改默认区域名必须同时修改 config.yaml', 'PluginForm.plugin.proxy-cache.property.cache_key': '缓存 key', - 'PluginForm.plugin.proxy-cache.property.cache_key.extra': '可以使用 Nginx 变量,例如:$host, $uri', + 'PluginForm.plugin.proxy-cache.property.cache_key.extra': + '可以使用 Nginx 变量,例如:$host, $uri', 'PluginForm.plugin.proxy-cache.property.cache_bypass': '跳过缓存检索', - 'PluginForm.plugin.proxy-cache.property.cache_bypass.extra': '这里可以使用 Nginx 变量,当此参数的值不为空或非0时将会跳过缓存的检索', + 'PluginForm.plugin.proxy-cache.property.cache_bypass.extra': + '这里可以使用 Nginx 变量,当此参数的值不为空或非0时将会跳过缓存的检索', 'PluginForm.plugin.proxy-cache.property.cache_method': '缓存 Method', 'PluginForm.plugin.proxy-cache.property.cache_http_status': '缓存响应状态码', 'PluginForm.plugin.proxy-cache.property.hide_cache_headers': '隐藏缓存头', - 'PluginForm.plugin.proxy-cache.property.hide_cache_headers.extra': '是否将 Expires 和 Cache-Control 响应头返回给客户端', + 'PluginForm.plugin.proxy-cache.property.hide_cache_headers.extra': + '是否将 Expires 和 Cache-Control 响应头返回给客户端', 'PluginForm.plugin.proxy-cache.property.no_cache': '不缓存的数据', - 'PluginForm.plugin.proxy-cache.property.no_cache.extra': '这里可以使用 Nginx 变量, 当此参数的值不为空或非0时将不会缓存数据', + 'PluginForm.plugin.proxy-cache.property.no_cache.extra': + '这里可以使用 Nginx 变量, 当此参数的值不为空或非0时将不会缓存数据', 'PluginForm.plugin.proxy-mirror.desc': 'proxy mirror 代理镜像插件,提供了镜像客户端请求的能力', 'PluginForm.plugin.proxy-mirror.property.host': '镜像服务地址', - 'PluginForm.plugin.proxy-mirror.property.host.extra': '例如:http://127.0.0.1:9797。地址中需要包含 http 或 https,不能包含 URI 部分', + 'PluginForm.plugin.proxy-mirror.property.host.extra': + '例如:http://127.0.0.1:9797。地址中需要包含 http 或 https,不能包含 URI 部分', 'PluginForm.plugin.response-rewrite.desc': '该插件支持修改上游服务返回的 body 和 header 信息', 'PluginForm.plugin.response-rewrite.property.status_code': '状态码', @@ -152,7 +161,6 @@ export default { 'PluginForm.plugin.serverless-post-function.property.phase': '运行阶段', 'PluginForm.plugin.serverless-post-function.property.functions': '运行的函数集', - 'PluginForm.plugin.basic-auth.desc': 'basic auth 插件', 'PluginForm.plugin.jwt-auth.desc': 'JWT 认证插件', 'PluginForm.plugin.key-auth.desc': 'key auth 插件', @@ -161,8 +169,10 @@ export default { 'PluginForm.plugin.redirect.desc': '重定向插件', 'PluginForm.plugin.proxy-rewrite.desc': 'proxy rewrite 代理改写插件,可以改写客户端请求', - 'PluginForm.plugin.mqtt-proxy.desc': 'mqtt-proxy 插件可以帮助你根据 MQTT 的 client_id 实现动态负载均衡', - 'PluginForm.plugin.grpc-transcoding.desc': 'gRPC 转换插件,实现 HTTP(s) -> APISIX -> gRPC server 的转换', + 'PluginForm.plugin.mqtt-proxy.desc': + 'mqtt-proxy 插件可以帮助你根据 MQTT 的 client_id 实现动态负载均衡', + 'PluginForm.plugin.grpc-transcoding.desc': + 'gRPC 转换插件,实现 HTTP(s) -> APISIX -> gRPC server 的转换', 'PluginForm.plugin.batch-requests.desc': 'batch-requests 插件可以一次接受多个请求并以 http pipeline 的方式在网关发起多个 http 请求,合并结果后再返回客户端,这在客户端需要访问多个接口时可以显著地提升请求性能', }; diff --git a/src/components/PluginForm/locales/zh-CN.ts b/src/components/PluginForm/locales/zh-CN.ts index 722c25a9eb..3efc2055eb 100644 --- a/src/components/PluginForm/locales/zh-CN.ts +++ b/src/components/PluginForm/locales/zh-CN.ts @@ -14,18 +14,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable no-template-curly-in-string */ export default { 'PluginForm.plugin.limit-conn.desc': '限制并发连接数', 'PluginForm.plugin.limit-conn.property.conn': 'conn', 'PluginForm.plugin.limit-conn.property.conn.extra': '最大并发连接数', 'PluginForm.plugin.limit-conn.property.burst': 'burst', - 'PluginForm.plugin.limit-conn.property.burst.extra': '并发连接数超过 conn,但是低于 conn + burst 时,请求将被延迟处理', + 'PluginForm.plugin.limit-conn.property.burst.extra': + '并发连接数超过 conn,但是低于 conn + burst 时,请求将被延迟处理', 'PluginForm.plugin.limit-conn.property.default_conn_delay': '延迟时间', - 'PluginForm.plugin.limit-conn.property.default_conn_delay.extra': '被延迟处理的请求,需要等待多少秒', + 'PluginForm.plugin.limit-conn.property.default_conn_delay.extra': + '被延迟处理的请求,需要等待多少秒', 'PluginForm.plugin.limit-conn.property.key': 'key', 'PluginForm.plugin.limit-conn.property.key.extra': '用来做限制的依据', 'PluginForm.plugin.limit-conn.property.rejected_code': '拒绝状态码', - 'PluginForm.plugin.limit-conn.property.rejected_code.extra': '当并发连接数超过 conn + burst 的限制时,返回给终端的 HTTP 状态码', + 'PluginForm.plugin.limit-conn.property.rejected_code.extra': + '当并发连接数超过 conn + burst 的限制时,返回给终端的 HTTP 状态码', 'PluginForm.plugin.limit-count.desc': '在指定的时间范围内,限制总的请求次数', 'PluginForm.plugin.limit-count.property.count': '总请求次数', @@ -59,8 +63,7 @@ export default { 'PluginForm.plugin.cors.desc': 'CORS 插件可以为服务端启用 CORS 的返回头', 'PluginForm.plugin.cors.property.allow_origins': '允许跨域访问的 Origin', - 'PluginForm.plugin.cors.property.allow_origins.extra': - '比如 https://somehost.com:8081', + 'PluginForm.plugin.cors.property.allow_origins.extra': '比如 https://somehost.com:8081', 'PluginForm.plugin.cors.property.allow_methods': '允许跨域访问的 Method', 'PluginForm.plugin.fault-injection.desc': '故障注入插件,用来模拟各种后端故障和高延迟', @@ -85,21 +88,27 @@ export default { 'PluginForm.plugin.proxy-cache.desc': '代理缓存插件,缓存后端服务的响应数据', 'PluginForm.plugin.proxy-cache.property.cache_zone': '缓存区域名', - 'PluginForm.plugin.proxy-cache.property.cache_zone.extra': ' 本地目录为 /tmp/${区域名},修改默认区域名必须同时修改 config.yaml', + 'PluginForm.plugin.proxy-cache.property.cache_zone.extra': + ' 本地目录为 /tmp/${区域名},修改默认区域名必须同时修改 config.yaml', 'PluginForm.plugin.proxy-cache.property.cache_key': '缓存 key', - 'PluginForm.plugin.proxy-cache.property.cache_key.extra': '可以使用 Nginx 变量,例如:$host, $uri', + 'PluginForm.plugin.proxy-cache.property.cache_key.extra': + '可以使用 Nginx 变量,例如:$host, $uri', 'PluginForm.plugin.proxy-cache.property.cache_bypass': '跳过缓存检索', - 'PluginForm.plugin.proxy-cache.property.cache_bypass.extra': '这里可以使用 Nginx 变量,当此参数的值不为空或非0时将会跳过缓存的检索', + 'PluginForm.plugin.proxy-cache.property.cache_bypass.extra': + '这里可以使用 Nginx 变量,当此参数的值不为空或非0时将会跳过缓存的检索', 'PluginForm.plugin.proxy-cache.property.cache_method': '缓存 Method', 'PluginForm.plugin.proxy-cache.property.cache_http_status': '缓存响应状态码', 'PluginForm.plugin.proxy-cache.property.hide_cache_headers': '隐藏缓存头', - 'PluginForm.plugin.proxy-cache.property.hide_cache_headers.extra': '是否将 Expires 和 Cache-Control 响应头返回给客户端', + 'PluginForm.plugin.proxy-cache.property.hide_cache_headers.extra': + '是否将 Expires 和 Cache-Control 响应头返回给客户端', 'PluginForm.plugin.proxy-cache.property.no_cache': '不缓存的数据', - 'PluginForm.plugin.proxy-cache.property.no_cache.extra': '这里可以使用 Nginx 变量, 当此参数的值不为空或非0时将不会缓存数据', + 'PluginForm.plugin.proxy-cache.property.no_cache.extra': + '这里可以使用 Nginx 变量, 当此参数的值不为空或非0时将不会缓存数据', 'PluginForm.plugin.proxy-mirror.desc': 'proxy mirror 代理镜像插件,提供了镜像客户端请求的能力', 'PluginForm.plugin.proxy-mirror.property.host': '镜像服务地址', - 'PluginForm.plugin.proxy-mirror.property.host.extra': '例如:http://127.0.0.1:9797。地址中需要包含 http 或 https,不能包含 URI 部分', + 'PluginForm.plugin.proxy-mirror.property.host.extra': + '例如:http://127.0.0.1:9797。地址中需要包含 http 或 https,不能包含 URI 部分', 'PluginForm.plugin.response-rewrite.desc': '该插件支持修改上游服务返回的 body 和 header 信息', 'PluginForm.plugin.response-rewrite.property.status_code': '状态码', @@ -152,7 +161,6 @@ export default { 'PluginForm.plugin.serverless-post-function.property.phase': '运行阶段', 'PluginForm.plugin.serverless-post-function.property.functions': '运行的函数集', - 'PluginForm.plugin.basic-auth.desc': 'basic auth 插件', 'PluginForm.plugin.jwt-auth.desc': 'JWT 认证插件', 'PluginForm.plugin.key-auth.desc': 'key auth 插件', @@ -161,8 +169,10 @@ export default { 'PluginForm.plugin.redirect.desc': '重定向插件', 'PluginForm.plugin.proxy-rewrite.desc': 'proxy rewrite 代理改写插件,可以改写客户端请求', - 'PluginForm.plugin.mqtt-proxy.desc': 'mqtt-proxy 插件可以帮助你根据 MQTT 的 client_id 实现动态负载均衡', - 'PluginForm.plugin.grpc-transcoding.desc': 'gRPC 转换插件,实现 HTTP(s) -> APISIX -> gRPC server 的转换', + 'PluginForm.plugin.mqtt-proxy.desc': + 'mqtt-proxy 插件可以帮助你根据 MQTT 的 client_id 实现动态负载均衡', + 'PluginForm.plugin.grpc-transcoding.desc': + 'gRPC 转换插件,实现 HTTP(s) -> APISIX -> gRPC server 的转换', 'PluginForm.plugin.batch-requests.desc': 'batch-requests 插件可以一次接受多个请求并以 http pipeline 的方式在网关发起多个 http 请求,合并结果后再返回客户端,这在客户端需要访问多个接口时可以显著地提升请求性能', }; diff --git a/src/components/PluginPage/PluginPage.tsx b/src/components/PluginPage/PluginPage.tsx index 6bcc0e111b..7ecce9e0f1 100644 --- a/src/components/PluginPage/PluginPage.tsx +++ b/src/components/PluginPage/PluginPage.tsx @@ -119,7 +119,7 @@ const PluginPage: React.FC = ({ data = {}, disabled, onChange }) => { if (!onChange) { throw new Error('请提供 onChange 方法'); } - onChange(omit(Object.assign({}, data), name)); + onChange(omit({ ...data }, name)); setInactiveList(inactiveList.concat({ name, ...PLUGIN_MAPPER_SOURCE[name] })); setActiveList(activeList.filter((item) => item.name !== name)); setPluginName(undefined); @@ -132,7 +132,7 @@ const PluginPage: React.FC = ({ data = {}, disabled, onChange }) => { if (!onChange) { throw new Error('请提供 onChange 方法'); } - onChange(Object.assign({}, data, { [pluginName]: value })); + onChange({ ...data, [pluginName]: value }); setPluginName(undefined); }} /> diff --git a/src/pages/Consumer/Create.tsx b/src/pages/Consumer/Create.tsx index 32f816bf4c..28ccd2f5f8 100644 --- a/src/pages/Consumer/Create.tsx +++ b/src/pages/Consumer/Create.tsx @@ -49,7 +49,13 @@ const Page: React.FC = (props) => { const { id } = (props as any).match.params; (id ? update(id, data) : create(data)) .then(() => { - notification.success({ message: `${id ? formatMessage({ id: 'consumer.create.edit' }) : formatMessage({ id: 'consumer.create.create' })} Consumer ${formatMessage({ id: 'consumer.create.success' })}` }); + notification.success({ + message: `${ + id + ? formatMessage({ id: 'consumer.create.edit' }) + : formatMessage({ id: 'consumer.create.create' }) + } Consumer ${formatMessage({ id: 'consumer.create.success' })}`, + }); history.push('/consumer/list'); }) .catch(() => { @@ -68,7 +74,9 @@ const Page: React.FC = (props) => { .map((item) => item[0]); const isValid = Object.keys(plugins).some((name) => authPluginNames.includes(name)); if (!isValid) { - notification.warning({ message: formatMessage({ id: 'consumer.create.enable.authentication.plugin' }) }); + notification.warning({ + message: formatMessage({ id: 'consumer.create.enable.authentication.plugin' }), + }); return; } setStep(3); @@ -81,7 +89,13 @@ const Page: React.FC = (props) => { return ( <> - + @@ -99,4 +113,4 @@ const Page: React.FC = (props) => { ); }; -export default Page; \ No newline at end of file +export default Page; diff --git a/src/pages/Consumer/List.tsx b/src/pages/Consumer/List.tsx index 278c4ea13b..cf25f6ecac 100644 --- a/src/pages/Consumer/List.tsx +++ b/src/pages/Consumer/List.tsx @@ -61,7 +61,9 @@ const Page: React.FC = () => { cancelText={formatMessage({ id: 'consumer.list.cancel' })} onConfirm={() => { remove(record.id).then(() => { - notification.success({ message: formatMessage({ id: 'consumer.list.delete.success' }) }); + notification.success({ + message: formatMessage({ id: 'consumer.list.delete.success' }), + }); /* eslint-disable no-unused-expressions */ ref.current?.reload(); }); diff --git a/src/pages/Route/List.tsx b/src/pages/Route/List.tsx index 49a0975e12..df2a899181 100644 --- a/src/pages/Route/List.tsx +++ b/src/pages/Route/List.tsx @@ -83,7 +83,9 @@ const Page: React.FC = () => { title={formatMessage({ id: 'route.list.delete.confrim' })} onConfirm={() => { remove(record.id!).then(() => { - notification.success({ message: formatMessage({ id: 'route.list.delete.success' }) }); + notification.success({ + message: formatMessage({ id: 'route.list.delete.success' }), + }); /* eslint-disable no-unused-expressions */ ref.current?.reload(); }); @@ -92,7 +94,7 @@ const Page: React.FC = () => { cancelText={formatMessage({ id: 'route.list.cancel' })} > diff --git a/src/pages/Route/transform.ts b/src/pages/Route/transform.ts index c301479930..26b292c39c 100644 --- a/src/pages/Route/transform.ts +++ b/src/pages/Route/transform.ts @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable @typescript-eslint/naming-convention */ import { omit, pick } from 'lodash'; export const transformStepData = ({ diff --git a/src/pages/SSL/Create.tsx b/src/pages/SSL/Create.tsx index 331e8d3062..8838fb74c3 100644 --- a/src/pages/SSL/Create.tsx +++ b/src/pages/SSL/Create.tsx @@ -80,7 +80,10 @@ const Page: React.FC = (props) => { - {[formatMessage({ id: 'ssl.create.complete.cert.info' }), formatMessage({ id: 'ssl.create.preview' })].map((item) => ( + {[ + formatMessage({ id: 'ssl.create.complete.cert.info' }), + formatMessage({ id: 'ssl.create.preview' }), + ].map((item) => ( ))} diff --git a/src/pages/SSL/service.ts b/src/pages/SSL/service.ts index cd5879e51f..c1e9d4d395 100644 --- a/src/pages/SSL/service.ts +++ b/src/pages/SSL/service.ts @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable @typescript-eslint/naming-convention */ import { request } from 'umi'; import querystring from 'querystring'; import { identity, pickBy, omit } from 'lodash'; @@ -24,10 +25,7 @@ export const fetchList = ( ) => { const [expire_start, expire_end] = (props.expire_range || '').split(':'); let queryObj = omit(props, 'expire_range', '_timestamp'); - queryObj = pickBy( - Object.assign({}, queryObj, { expire_start, expire_end, sni: search }), - identity, - ); + queryObj = pickBy({ ...queryObj, expire_start, expire_end, sni: search }, identity); const query = querystring.encode(queryObj); return request<{ count: number; list: SSLModule.ResSSL[] }>( `/ssls?page=${current}&size=${pageSize}&${query}`, diff --git a/src/pages/Upstream/Create.tsx b/src/pages/Upstream/Create.tsx index 65472982ac..dc824c4781 100644 --- a/src/pages/Upstream/Create.tsx +++ b/src/pages/Upstream/Create.tsx @@ -45,7 +45,13 @@ const Page: React.FC = (props) => { const data = transformCreate({ ...form1.getFieldsValue() } as UpstreamModule.Body); const { id } = (props as any).match.params; (id ? update(id, data) : create(data)).then(() => { - notification.success({ message: `${id ? formatMessage({ id: 'upstream.create.edit' }) : formatMessage({ id: 'upstream.create.create' })} ` + formatMessage({ id: 'upstream.create.upstream.successfully' }) }); + notification.success({ + message: `${ + id + ? formatMessage({ id: 'upstream.create.edit' }) + : formatMessage({ id: 'upstream.create.create' }) + } ${formatMessage({ id: 'upstream.create.upstream.successfully' })}`, + }); history.replace('/upstream/list'); }); }; diff --git a/src/pages/Upstream/List.tsx b/src/pages/Upstream/List.tsx index 3e71ea5843..5a073a81fb 100644 --- a/src/pages/Upstream/List.tsx +++ b/src/pages/Upstream/List.tsx @@ -103,7 +103,7 @@ const Page: React.FC = () => { + , ]} />