Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ci): resolve lint failures #354

Merged
merged 1 commit into from
Aug 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
};
}
};
38 changes: 24 additions & 14 deletions src/components/PluginForm/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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': '总请求次数',
Expand Down Expand Up @@ -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': '故障注入插件,用来模拟各种后端故障和高延迟',
Expand All @@ -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': '状态码',
Expand Down Expand Up @@ -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 插件',
Expand All @@ -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 请求,合并结果后再返回客户端,这在客户端需要访问多个接口时可以显著地提升请求性能',
};
38 changes: 24 additions & 14 deletions src/components/PluginForm/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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': '总请求次数',
Expand Down Expand Up @@ -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': '故障注入插件,用来模拟各种后端故障和高延迟',
Expand All @@ -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': '状态码',
Expand Down Expand Up @@ -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 插件',
Expand All @@ -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 请求,合并结果后再返回客户端,这在客户端需要访问多个接口时可以显著地提升请求性能',
};
4 changes: 2 additions & 2 deletions src/components/PluginPage/PluginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const PluginPage: React.FC<Props> = ({ 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);
Expand All @@ -132,7 +132,7 @@ const PluginPage: React.FC<Props> = ({ data = {}, disabled, onChange }) => {
if (!onChange) {
throw new Error('请提供 onChange 方法');
}
onChange(Object.assign({}, data, { [pluginName]: value }));
onChange({ ...data, [pluginName]: value });
setPluginName(undefined);
}}
/>
Expand Down
22 changes: 18 additions & 4 deletions src/pages/Consumer/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -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);
Expand All @@ -81,7 +89,13 @@ const Page: React.FC = (props) => {

return (
<>
<PageContainer title={`${(props as any).match.params.id ? formatMessage({ id: 'consumer.create.edit' }) : formatMessage({ id: 'consumer.create.create' })} Consumer`}>
<PageContainer
title={`${
(props as any).match.params.id
? formatMessage({ id: 'consumer.create.edit' })
: formatMessage({ id: 'consumer.create.create' })
} Consumer`}
>
<Card bordered={false}>
<Steps current={step - 1} style={{ marginBottom: 30 }}>
<Steps.Step title={formatMessage({ id: 'consumer.create.basic.information' })} />
Expand All @@ -99,4 +113,4 @@ const Page: React.FC = (props) => {
);
};

export default Page;
export default Page;
4 changes: 3 additions & 1 deletion src/pages/Consumer/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
6 changes: 4 additions & 2 deletions src/pages/Route/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand All @@ -92,7 +94,7 @@ const Page: React.FC = () => {
cancelText={formatMessage({ id: 'route.list.cancel' })}
>
<Button type="primary" danger>
{formatMessage({ id: 'route.list.delete' })}
{formatMessage({ id: 'route.list.delete' })}
</Button>
</Popconfirm>
</>
Expand Down
1 change: 1 addition & 0 deletions src/pages/Route/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ({
Expand Down
5 changes: 4 additions & 1 deletion src/pages/SSL/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ const Page: React.FC = (props) => {
<PageHeaderWrapper title={formatMessage({ id: 'ssl.create' })}>
<Card bordered={false}>
<Steps current={step - 1} className={styles.steps}>
{[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) => (
<Steps.Step title={item} key={item} />
))}
</Steps>
Expand Down
6 changes: 2 additions & 4 deletions src/pages/SSL/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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}`,
Expand Down
Loading