eslint: follow unicorn plugin rules in project

This commit is contained in:
Chika 2022-05-29 21:24:14 +03:00
parent 05f9a1ce5f
commit b62e31e6ef
14 changed files with 189 additions and 197 deletions

View File

@ -8,36 +8,36 @@ import type { ElementsProps } from '../types/elements-props';
const props: Partial<ElementsProps> = {
tbxLeaseObjectPrice: {
min: 0.0,
max: 1000000000.0,
step: 10000.0,
min: 0,
max: 1_000_000_000,
step: 10_000,
precision: 2,
formatter: formatNumber,
},
tbxLeaseObjectPriceWthtVAT: {
min: 0.0,
max: 1000000000.0,
step: 10000.0,
min: 0,
max: 1_000_000_000,
step: 10_000,
precision: 2,
formatter: formatNumber,
},
tbxVATInLeaseObjectPrice: {
min: 0.0,
max: 1000000000.0,
step: 10000.0,
min: 0,
max: 1_000_000_000,
step: 10_000,
precision: 2,
formatter: formatNumber,
},
tbxEngineHours: {
min: 0.0,
step: 10.0,
min: 0,
step: 10,
precision: 2,
formatter: formatNumber,
},
tbxSupplierDiscountRub: {
min: 0,
max: 1000000000,
step: 10000.0,
max: 1_000_000_000,
step: 10_000,
precision: 2,
formatter: formatNumber,
},
@ -52,7 +52,7 @@ const props: Partial<ElementsProps> = {
buttonStyle: 'solid',
},
tbxSaleBonus: {
min: 0.0,
min: 0,
// max: 1.30,
step: 0.1,
precision: 2,
@ -66,29 +66,29 @@ const props: Partial<ElementsProps> = {
},
tbxFirstPaymentRub: {
min: 0,
max: 1000000000,
step: 10000.0,
max: 1_000_000_000,
step: 10_000,
precision: 2,
formatter: formatNumber,
},
tbxLastPaymentPerc: {
min: 0,
max: 70,
step: 1.0,
step: 1,
precision: 6,
formatter: formatNumber,
},
tbxLastPaymentRub: {
min: 0,
max: 1000000000,
step: 10000.0,
max: 1_000_000_000,
step: 10_000,
precision: 2,
formatter: formatNumber,
},
tbxRedemptionPaymentSum: {
min: 1000,
max: 2000,
step: 1000.0,
step: 1000,
precision: 2,
formatter: formatNumber,
},
@ -106,8 +106,8 @@ const props: Partial<ElementsProps> = {
},
tbxComissionRub: {
min: 0,
max: 1000000000,
step: 10000.0,
max: 1_000_000_000,
step: 10_000,
},
selectLeaseObjectType: {
showSearch: true,
@ -143,14 +143,14 @@ const props: Partial<ElementsProps> = {
showSearch: true,
},
tbxLeaseObjectMotorPower: {
min: 0.0,
max: 20000.0,
step: 10.0,
min: 0,
max: 20_000,
step: 10,
precision: 2,
formatter: formatNumber,
},
tbxEngineVolume: {
min: 0.0,
min: 0,
max: 99.9999,
step: 0.5,
precision: 4,
@ -158,7 +158,7 @@ const props: Partial<ElementsProps> = {
},
tbxMaxMass: {
min: 0,
max: 999999,
max: 999_999,
step: 100,
formatter: formatNumber,
},
@ -174,43 +174,43 @@ const props: Partial<ElementsProps> = {
showSearch: true,
},
tbxDealerRewardSumm: {
min: 0.0,
max: 20.0,
min: 0,
max: 20,
step: 0.1,
precision: 2,
formatter: formatNumber,
},
tbxDealerBrokerRewardSumm: {
min: 0.0,
max: 20.0,
min: 0,
max: 20,
step: 0.1,
precision: 2,
formatter: formatNumber,
},
tbxIndAgentRewardSumm: {
min: 0.0,
max: 20.0,
min: 0,
max: 20,
step: 0.1,
precision: 2,
formatter: formatNumber,
},
tbxCalcDoubleAgentRewardSumm: {
min: 0.0,
max: 20.0,
min: 0,
max: 20,
step: 0.1,
precision: 2,
formatter: formatNumber,
},
tbxCalcBrokerRewardSum: {
min: 0.0,
max: 20.0,
min: 0,
max: 20,
step: 0.1,
precision: 2,
formatter: formatNumber,
},
tbxFinDepartmentRewardSumm: {
min: 0.0,
max: 20.0,
min: 0,
max: 20,
step: 0.1,
precision: 2,
formatter: formatNumber,
@ -222,7 +222,7 @@ const props: Partial<ElementsProps> = {
tbxInsFranchise: {
min: 0,
max: MAX_FRANCHISE,
step: 10000.0,
step: 10_000,
precision: 2,
formatter: formatNumber,
},
@ -249,30 +249,30 @@ const props: Partial<ElementsProps> = {
text: 'Создать КП',
},
tbxCreditRate: {
min: 0.0,
min: 0,
max: 99.99,
step: 0.1,
},
tbxMaxPriceChange: {
min: 0,
max: 34999990,
step: 10000.0,
max: 34_999_990,
step: 10_000,
},
tbxMinPriceChange: {
min: 0,
max: 34999990,
step: 10000.0,
max: 34_999_990,
step: 10_000,
},
tbxImporterRewardPerc: {
min: 0.0,
min: 0,
max: 99.99,
step: 0.1,
precision: 2,
},
tbxImporterRewardRub: {
min: 0.0,
max: 1000000000.0,
step: 10000.0,
min: 0,
max: 1_000_000_000,
step: 10_000,
precision: 2,
},
selectLead: {
@ -289,8 +289,8 @@ const props: Partial<ElementsProps> = {
type: 'primary',
},
tbxIRR_Perc: {
min: 0.0,
max: 500.0,
min: 0,
max: 500,
step: 0.0001,
precision: 6,
formatter: formatNumber,
@ -302,7 +302,7 @@ const props: Partial<ElementsProps> = {
},
tbxMileage: {
min: 0,
step: 100.0,
step: 100,
precision: 2,
formatter: formatNumber,
},
@ -325,13 +325,13 @@ const props: Partial<ElementsProps> = {
tbxVehicleTaxInYear: {
min: 0,
step: 100,
max: 9999999,
max: 9_999_999,
precision: 2,
},
tbxVehicleTaxInLeasingPeriod: {
min: 0,
step: 100,
max: 9999999,
max: 9_999_999,
precision: 2,
},
selectObjectRegionRegistration: {
@ -356,51 +356,47 @@ const props: Partial<ElementsProps> = {
},
};
const moneyResultElementsProps = (
[
'labelResultTotalGraphwithNDS',
'labelResultPlPrice',
'labelResultInsKasko',
'labelResultInsOsago',
'labelResultDopProdSum',
'labelResultFirstPayment',
'labelResultLastPayment',
'labelResultAB_FL',
'labelResultAB_UL',
'labelResultBonusMPL',
'labelResultDopMPLLeasing',
'labelResultBonusDopProd',
'labelSubsidySum',
'labelResultBonusSafeFinance',
] as (keyof ElementsProps)[]
).reduce(
(ac, a) => ({
...ac,
[a]: {
const moneyResultElementsProps = Object.fromEntries(
(
[
'labelResultTotalGraphwithNDS',
'labelResultPlPrice',
'labelResultInsKasko',
'labelResultInsOsago',
'labelResultDopProdSum',
'labelResultFirstPayment',
'labelResultLastPayment',
'labelResultAB_FL',
'labelResultAB_UL',
'labelResultBonusMPL',
'labelResultDopMPLLeasing',
'labelResultBonusDopProd',
'labelSubsidySum',
'labelResultBonusSafeFinance',
] as (keyof ElementsProps)[]
).map((a) => [
a,
{
middleware: (value: number) => pipe(round, formatMoney)(value),
},
}),
// eslint-disable-next-line object-curly-newline
{}
])
);
const numberResultElementsProps = (
[
'labelResultPriceUpPr',
'labelResultIRRGraphPerc',
'labelResultIRRNominalPerc',
'labelResultTerm',
'labelResultFirstPaymentRiskPolicy',
] as (keyof ElementsProps)[]
).reduce(
(ac, a) => ({
...ac,
[a]: {
const numberResultElementsProps = Object.fromEntries(
(
[
'labelResultPriceUpPr',
'labelResultIRRGraphPerc',
'labelResultIRRNominalPerc',
'labelResultTerm',
'labelResultFirstPaymentRiskPolicy',
] as (keyof ElementsProps)[]
).map((a) => [
a,
{
middleware: (value: number) => pipe(round)(value),
},
}),
// eslint-disable-next-line object-curly-newline
{}
])
);
export default Object.assign(props, moneyResultElementsProps, numberResultElementsProps);

View File

@ -1,4 +1,3 @@
import type { InputProps } from 'antd';
import { Form, Input as AntInput } from 'antd';
import type { ChangeEvent } from 'react';
import type { BaseElementProps } from './types';
@ -24,4 +23,4 @@ export default function Input({
);
}
export type { InputProps };
export { type InputProps } from 'antd';

View File

@ -1,4 +1,4 @@
import type { RadioChangeEvent, RadioGroupProps } from 'antd';
import type { RadioChangeEvent } from 'antd';
import { Form, Radio as AntRadio } from 'antd';
import type { BaseElementProps, BaseOption } from './types';
@ -34,4 +34,4 @@ export default function Radio({
);
}
export type { RadioGroupProps as RadioProps };
export { type RadioGroupProps as RadioProps } from 'antd';

View File

@ -1,4 +1,3 @@
import type { SelectProps } from 'antd';
import { Form, Select as AntSelect } from 'antd';
import { useMemo } from 'react';
import type { BaseElementProps, BaseOption } from './types';
@ -44,4 +43,4 @@ export default function Select({
);
}
export type { SelectProps };
export { type SelectProps } from 'antd';

View File

@ -1,4 +1,3 @@
import type { SwitchProps } from 'antd';
import { Form, Switch as AntSwitch } from 'antd';
import type { BaseElementProps } from './types';
@ -19,4 +18,4 @@ export default function Switch({
);
}
export type { SwitchProps };
export { type SwitchProps } from 'antd';

View File

@ -1,3 +1 @@
import { Box, Flex } from 'rebass/styled-components';
export { Box, Flex };
export { Box, Flex } from 'rebass/styled-components';

View File

@ -5,84 +5,84 @@ const defaultOptions: Partial<CalculationOptions> = {
radioLastPaymentRule: [
{
label: 'равен платежу',
value: 100000002,
value: 100_000_002,
},
{
label: 'в рублях',
value: 100000000,
value: 100_000_000,
},
{
label: 'в %',
value: 100000001,
value: 100_000_001,
},
],
radioBalanceHolder: [
{
label: 'Лизингополучатель',
value: 100000000,
value: 100_000_000,
},
{
label: 'Лизингодатель',
value: 100000001,
value: 100_000_001,
},
],
radioGraphType: [
{
label: 'аннуитет',
value: 100000000,
value: 100_000_000,
},
{
label: 'дегрессия (ступенчатая)',
value: 100000001,
value: 100_000_001,
},
{
label: 'равноубывающий',
value: 100000002,
value: 100_000_002,
},
{
label: 'сезонный',
value: 100000003,
value: 100_000_003,
},
{
label: 'легкий старт',
value: 100000004,
value: 100_000_004,
},
],
selectSeasonType: [
{
label: '6/6',
value: 100000000,
value: 100_000_000,
},
{
label: '8/4',
value: 100000001,
value: 100_000_001,
},
{
label: '4/4/4',
value: 100000002,
value: 100_000_002,
},
{
label: 'Гибкая дегрессия',
value: 100000007,
value: 100_000_007,
},
{
label: '100.50.25',
value: 100000003,
value: 100_000_003,
},
{
label: '100.30.10',
value: 100000004,
value: 100_000_004,
},
{
label: '100.70.40',
value: 100000005,
value: 100_000_005,
},
{
label: '100.7.3',
value: 100000006,
value: 100_000_006,
},
],
@ -92,64 +92,64 @@ const defaultOptions: Partial<CalculationOptions> = {
},
(_, i) => ({
label: `${i + 2}`,
value: 100000000 + i,
value: 100_000_000 + i,
})
),
radioDeliveryTime: [
{
label: 'В наличии',
value: 100000000,
value: 100_000_000,
},
{
label: 'В поставке',
value: 100000001,
value: 100_000_001,
},
],
selectEngineType: [
{
label: 'Бензин',
value: 100000000,
value: 100_000_000,
},
{
label: 'Дизель',
value: 100000001,
value: 100_000_001,
},
{
label: 'Газ',
value: 100000002,
value: 100_000_002,
},
{
label: 'Электрический',
value: 100000003,
value: 100_000_003,
},
{
label: 'Гибрид',
value: 100000004,
value: 100_000_004,
},
],
selectLeaseObjectCategory: [
{
label: 'A',
value: 100000000,
value: 100_000_000,
},
{
label: 'B',
value: 100000001,
value: 100_000_001,
},
{
label: 'C',
value: 100000002,
value: 100_000_002,
},
{
label: 'D',
value: 100000003,
value: 100_000_003,
},
{
label: 'Прицеп',
value: 100000004,
value: 100_000_004,
},
],
@ -157,83 +157,83 @@ const defaultOptions: Partial<CalculationOptions> = {
[
{
label: 'Для представительских целей',
value: 100000000,
value: 100_000_000,
},
{
label: 'Для использования в качестве «такси»',
value: 100000001,
value: 100_000_001,
},
{
label: 'Для передачи третьим лицам (прокат; аренда)',
value: 100000002,
value: 100_000_002,
},
{
label: 'Каршеринг',
value: 100000003,
value: 100_000_003,
},
{
label: 'Тест-драйв',
value: 100000004,
value: 100_000_004,
},
{
label: 'Для доставки продуктов конечному потребителю',
value: 100000005,
value: 100_000_005,
},
{
label: 'Для обучения вождению',
value: 100000006,
value: 100_000_006,
},
{
label: 'Маршрутные такси / Рейсовые автобусы',
value: 100000007,
value: 100_000_007,
},
{
label: 'Междугородние перевозки',
value: 100000008,
value: 100_000_008,
},
{
label: 'Для перевозки крупногабаритных грузов',
value: 100000009,
value: 100_000_009,
},
{
label: 'Для перевозки малогабаритных грузов',
value: 100000010,
value: 100_000_010,
},
{
label: 'Для перевозки сотрудников других организаций (водитель ЛП)',
value: 100000011,
value: 100_000_011,
},
{
label: 'Для перевозки сотрудников ЛП',
value: 100000012,
value: 100_000_012,
},
{
label: 'Для экскурсионных перевозок в т.ч. на торжества; трансфер в аэропорт и пр.',
value: 100000013,
value: 100_000_013,
},
{
label: 'Дорожно-строительная техника',
value: 100000014,
value: 100_000_014,
},
{
label: 'Жилищно-коммунальное хозяйство',
value: 100000015,
value: 100_000_015,
},
{
label: 'Лесное хозяйство',
value: 100000016,
value: 100_000_016,
},
{
label: 'Подъёмно-транспортная отрасль',
value: 100000017,
value: 100_000_017,
},
{
label: 'Сельское хозяйство',
value: 100000018,
value: 100_000_018,
},
{
label: 'Строительство',
value: 100000019,
value: 100_000_019,
},
],
(objectUseFor) => objectUseFor.label.toLowerCase(),
@ -243,98 +243,98 @@ const defaultOptions: Partial<CalculationOptions> = {
radioInfuranceOPF: [
{
label: 'ЮЛ',
value: 100000000,
value: 100_000_000,
},
{
label: 'ИП',
value: 100000001,
value: 100_000_001,
},
],
radioInsKaskoType: [
{
label: 'Полное',
value: 100000000,
value: 100_000_000,
},
{
label: 'Усеченное',
value: 100000001,
value: 100_000_001,
},
],
radioQuoteContactGender: [
{
label: 'Мужской',
value: 100000000,
value: 100_000_000,
},
{
label: 'Женский',
value: 100000001,
value: 100_000_001,
},
],
radioRequirementTelematic: [
{
label: 'Не требуется',
value: 100000004,
value: 100_000_004,
},
{
label: 'START',
value: 100000000,
value: 100_000_000,
},
{
label: 'START+',
value: 100000001,
value: 100_000_001,
},
{
label: 'COMFORT',
value: 100000002,
value: 100_000_002,
},
{
label: 'COMFORT+',
value: 100000003,
value: 100_000_003,
},
{
label: 'Omnicomm_1',
value: 100000005,
value: 100_000_005,
},
{
label: 'Omnicomm_2',
value: 100000006,
value: 100_000_006,
},
{
label: 'Omnicomm_3',
value: 100000007,
value: 100_000_007,
},
],
radioCalcType: [
{
label: 'IRR',
value: 100000000,
value: 100_000_000,
},
{
label: 'Суммы',
value: 100000001,
value: 100_000_001,
},
],
radioObjectRegistration: [
{
label: 'Лизингополучатель',
value: 100000000,
value: 100_000_000,
},
{
label: 'Лизингодатель',
value: 100000001,
value: 100_000_001,
},
],
radioTypePTS: [
{
label: 'Бумажный',
value: 100000000,
value: 100_000_000,
},
{
label: 'Электронный',
value: 100000001,
value: 100_000_001,
},
],
selectObjectCategoryTax: [
@ -361,7 +361,7 @@ const defaultOptions: Partial<CalculationOptions> = {
'L5',
].map((label, i) => ({
label,
value: 100000000 + i,
value: 100_000_000 + i,
})),
selectObjectTypeTax: [
{
@ -386,7 +386,7 @@ const defaultOptions: Partial<CalculationOptions> = {
},
].map((v, i) => ({
...v,
value: 100000000 + i,
value: 100_000_000 + i,
})),
};

View File

@ -7,7 +7,7 @@ const defaultValues: CalculationValues = {
opportunity: null,
quote: null,
recalcWithRevision: false,
leaseObjectPrice: 1000000,
leaseObjectPrice: 1_000_000,
VATInLeaseObjectPrice: 0,
leaseObjectPriceWthtVAT: 0,
engineHours: 0,
@ -18,13 +18,13 @@ const defaultValues: CalculationValues = {
firstPaymentPerc: 25,
firstPaymentRub: 0,
lastPaymentPerc: 1,
lastPaymentRule: 100000001,
lastPaymentRule: 100_000_001,
redemptionPaymentSum: 1000,
balanceHolder: 100000001,
graphType: 100000000,
balanceHolder: 100_000_001,
graphType: 100_000_000,
parmentsDecreasePercent: 94,
seasonType: 100000000,
highSeasonStart: 100000000,
seasonType: 100_000_000,
highSeasonStart: 100_000_000,
comissionPerc: 0,
comissionRub: 0,
saleBonus: 1.3,
@ -32,7 +32,7 @@ const defaultValues: CalculationValues = {
brand: null,
model: null,
configuration: null,
deliveryTime: 100000000,
deliveryTime: 100_000_000,
leaseObjectCount: 1,
withTrailer: false,
leaseObjectUsed: false,
@ -40,7 +40,7 @@ const defaultValues: CalculationValues = {
countSeats: 0,
maxSpeed: 0,
leaseObjectYear: date().year(),
engineType: 100000000,
engineType: 100_000_000,
leaseObjectCategory: null,
leaseObjectMotorPower: 0,
engineVolume: 0,
@ -57,7 +57,7 @@ const defaultValues: CalculationValues = {
calcDoubleAgentRewardSumm: 0,
calcBrokerRewardSum: 0,
finDepartmentRewardSumm: 0,
insKaskoType: 100000000,
insKaskoType: 100_000_000,
insDecentral: false,
insUnlimitDrivers: true,
insAgeDrivers: 0,
@ -70,23 +70,23 @@ const defaultValues: CalculationValues = {
registrationQuote: true,
technicalCardQuote: true,
NSIB: true,
quoteContactGender: 100000000,
quoteContactGender: 100_000_000,
quoteRedemptionGraph: true,
showFinGAP: true,
creditRate: RATE,
requirementTelematic: 100000000,
requirementTelematic: 100_000_000,
maxPriceChange: 0,
importerRewardPerc: 0,
importerRewardRub: 0,
disableChecks: false,
insFranchise: 0,
rate: 'BASE',
calcType: 100000000,
calcType: 100_000_000,
totalPayments: 0,
vehicleTaxInYear: 0,
vehicleTaxInLeasingPeriod: 0,
objectRegistration: 100000000,
typePTS: 100000001,
objectRegistration: 100_000_000,
typePTS: 100_000_001,
insNSIB: null,
regionRegistration: null,
legalClientRegion: null,

View File

@ -1,5 +1,5 @@
export const MAX_FRANCHISE = 75000;
export const MAX_INSURANCE = 2500000;
export const MAX_FRANCHISE = 75_000;
export const MAX_INSURANCE = 2_500_000;
export const MIN_INSURANCE = 3000;
export const RATE = 7.75;

View File

@ -3,7 +3,7 @@ import type { GetServerSideProps } from 'next';
import { fetchUser } from 'services/user';
import type { BasePageProps } from 'types/page';
interface PageProps extends BasePageProps {}
type PageProps = BasePageProps;
function Home() {
return <div>Home</div>;

View File

@ -1,5 +1,5 @@
/* eslint-disable import/no-cycle */
import RootStore from 'stores/root';
import type RootStore from 'stores/root';
import OptionsStore from './options';
import StatusStore from './statuses';
import ValidationStore from './validation';

View File

@ -1,3 +1,4 @@
/* eslint-disable unicorn/prefer-set-has */
/* eslint-disable function-paren-newline */
/* eslint-disable implicit-arrow-linebreak */
/* eslint-disable no-confusing-arrow */

View File

@ -1,3 +1,4 @@
/* eslint-disable unicorn/prefer-export-from */
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';

View File

@ -1,4 +1,3 @@
/* eslint-disable import/prefer-default-export */
import { round } from 'lodash';
export { round };
export { round } from 'lodash';