fix: Fix word spell

1. Add eslint plugin spellcheck to check word spell
2. Fix word spell

Change-Id: I73d39cf797ef5bdf993b0154816134a1e93f2ed4
This commit is contained in:
Jingwei.Zhang
2022-01-17 17:17:30 +08:00
parent 6e5ffc72fb
commit f81ac5651a
167 changed files with 607 additions and 577 deletions

File diff suppressed because one or more lines are too long

View File

@@ -109,7 +109,7 @@ export const firstUpperCase = (str) => {
return first.toUpperCase() + rest.join('');
};
export const bytesFitler = (input) => {
export const bytesFilter = (input) => {
const { kb, mb, gb, tb } = SIZE_VALUE;
if (isNaN(input) || isUndefined(input) || input === null || input < 0) {
return '';
@@ -183,7 +183,7 @@ export const renderFilterMap = {
yesNo: getYesNo,
GBValue: getGBValue,
noValue: getNoValue,
bytes: bytesFitler,
bytes: bytesFilter,
uppercase: uppercaseFilter,
formatSize,
toLocalTime: toLocalTimeFilter,
@@ -214,7 +214,7 @@ export const generateArray = (start, end) => {
export const NoSetValue = 'noSelect';
export const getOptionsWithNoset = (options) => {
export const getOptionsWithNoSet = (options) => {
const newOptions = isArray(options) ? options : getOptions(options);
const noSet = {
value: NoSetValue,

View File

@@ -2,7 +2,7 @@ import moment from 'moment';
import { timeFormatStr } from 'utils/time';
import {
groupArray,
bytesFitler,
bytesFilter,
computePercentage,
firstUpperCase,
formatSize,
@@ -12,7 +12,7 @@ import {
getGBValue,
getNoValue,
getOptions,
getOptionsWithNoset,
getOptionsWithNoSet,
getQueryString,
getYesNo,
getYesNoList,
@@ -106,18 +106,18 @@ describe('test utils index.js', () => {
expect(firstUpperCase(0)).toBe(0);
});
it('bytesFitler', () => {
expect(bytesFitler(-1)).toBe('');
expect(bytesFitler(NaN)).toBe('');
expect(bytesFitler(100)).toBe(t('{ size } bytes', { size: '100' }));
expect(bytesFitler(1024)).toBe(t('{ size } KB', { size: '1.00' }));
expect(bytesFitler(10 * 1024 ** 2)).toBe(
it('bytesFilter', () => {
expect(bytesFilter(-1)).toBe('');
expect(bytesFilter(NaN)).toBe('');
expect(bytesFilter(100)).toBe(t('{ size } bytes', { size: '100' }));
expect(bytesFilter(1024)).toBe(t('{ size } KB', { size: '1.00' }));
expect(bytesFilter(10 * 1024 ** 2)).toBe(
t('{ size } MB', { size: '10.00' })
);
expect(bytesFitler(1024 ** 2)).toBe(t('{ size } MB', { size: '1.00' }));
expect(bytesFitler(1024 ** 3)).toBe(t('{ size } GB', { size: '1.00' }));
expect(bytesFitler(1024 ** 4)).toBe(t('{ size } TB', { size: '1.00' }));
expect(bytesFitler(3.15 * 1024 ** 4)).toBe(
expect(bytesFilter(1024 ** 2)).toBe(t('{ size } MB', { size: '1.00' }));
expect(bytesFilter(1024 ** 3)).toBe(t('{ size } GB', { size: '1.00' }));
expect(bytesFilter(1024 ** 4)).toBe(t('{ size } TB', { size: '1.00' }));
expect(bytesFilter(3.15 * 1024 ** 4)).toBe(
t('{ size } TB', { size: '3.15' })
);
});
@@ -182,9 +182,9 @@ describe('test utils index.js', () => {
expect(generateArray(-2, 2)).toEqual([-2, -1, 0, 1]);
});
it('getOptionsWithNoset', () => {
it('getOptionsWithNoSet', () => {
expect(
getOptionsWithNoset({
getOptionsWithNoSet({
key1: 'Key1',
key2: 'Key2',
})

View File

@@ -45,8 +45,8 @@ describe('test route map', () => {
});
it('getPath', () => {
const overivewPath = getPath({ key: 'overview' });
expect(overivewPath).toBe('/base/overview');
const overviewPath = getPath({ key: 'overview' });
expect(overviewPath).toBe('/base/overview');
const detailPath = getPath({ key: 'instanceDetail', params: { id: 1 } });
expect(detailPath).toBe('/compute/instance/detail/1');
const queryPath = getPath({ key: 'instance', query: { status: 'stop' } });

View File

@@ -195,13 +195,13 @@ class SLI18n {
return new Promise((resolve) => {
// init() will not load external common locale data anymore.
// But, it still return a Promise for abckward compatibility.
// But, it still return a Promise for backward compatibility.
resolve();
});
}
/**
* Get the inital options
* Get the initial options
*/
getInitOptions() {
return this.options;

View File

@@ -128,20 +128,20 @@ describe('test translate', () => {
it('HTML Message with XSS attack', () => {
intl.init({ locales, currentLocale: 'en-US' });
const reactEl = intl.getHTML('TIP_VAR', {
message: '<sctipt>alert(1)</script>',
message: '<script>alert(1)</script>',
});
expect(reactEl.props.dangerouslySetInnerHTML.__html).toBe(
'This is<span>&lt;sctipt&gt;alert(1)&lt;/script&gt;</span>'
'This is<span>&lt;script&gt;alert(1)&lt;/script&gt;</span>'
);
});
it('HTML Message with disable escape html', () => {
intl.init({ locales, currentLocale: 'en-US', escapeHtml: false });
const reactEl = intl.getHTML('TIP_VAR', {
message: '<sctipt>alert(1)</script>',
message: '<script>alert(1)</script>',
});
expect(reactEl.props.dangerouslySetInnerHTML.__html).toBe(
'This is<span><sctipt>alert(1)</script></span>'
'This is<span><script>alert(1)</script></span>'
);
});

View File

@@ -19,12 +19,6 @@ import { isValidPhoneNumber } from 'libphonenumber-js';
const { v4, v6 } = cidrRegex;
// const ip = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[.](25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[.](25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[.](25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
// const ipv6 = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/;
// const cidr = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[.](25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[.](25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[.](25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[\/](([0-9])|([1-2][0-9])|(3[1-2]))$/; // eslint-disable-line
// const ipCidr = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[.](25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[.](25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[.](25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)([\/](([0-9])|([1-2][0-9])|(3[1-2])))?$/; // eslint-disable-line
// const ipv6Cidr = /^((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*(\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))?$/;
const cidr = cidrRegex({ exact: true });
const ipCidr = v4({ exact: true });
const ipv6Cidr = v6({ exact: true });
@@ -90,8 +84,8 @@ function zfill(num, len) {
const isIpWithMask = (value) => ipWithMask.test(value);
const ipFull = (ipadd) =>
ipadd
const ipFull = (ipAdd) =>
ipAdd
.split('.')
.map((item) => zfill(item, 3))
.join('.');