Add more eslint rules, bump up dependency

This commit is contained in:
Piotr Rogowski 2021-04-06 18:13:13 +02:00
parent 2c4690f7b5
commit 9652b33e4d
No known key found for this signature in database
GPG Key ID: F40F61D5587F5673
17 changed files with 162 additions and 82 deletions

View File

@ -17,7 +17,9 @@ extends:
plugins:
- jsx-a11y
- prettier
- modules-newline
rules:
indent: [2, 2, { "SwitchCase": 1 }]
semi:
- error
- always
@ -35,6 +37,12 @@ rules:
object-curly-spacing:
- error
- always
object-curly-newline: [2, {
"ImportDeclaration": { "multiline": true, "minProperties": 2 },
"ExportDeclaration": { "multiline": true, "minProperties": 1 }
}]
modules-newline/import-declaration-newline: 2
modules-newline/export-declaration-newline: 2
quotes:
- error
- single

51
package-lock.json generated
View File

@ -38,7 +38,7 @@
"@types/react-dom": "^17.0.3",
"@types/react-redux": "^7.1.16",
"@types/react-router-dom": "^5.1.7",
"concurrently": "^6.0.0",
"concurrently": "^6.0.1",
"electron": "^12.0.1",
"eslint": "^7.23.0",
"eslint-config-airbnb": "^18.2.1",
@ -46,6 +46,7 @@
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-modules-newline": "^0.0.6",
"eslint-plugin-prettier": "^3.3.1",
"less-loader": "^6.1.0",
"prettier": "^2.2.1",
@ -6363,9 +6364,9 @@
}
},
"node_modules/concurrently": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/concurrently/-/concurrently-6.0.0.tgz",
"integrity": "sha512-Ik9Igqnef2ONLjN2o/OVx1Ow5tymVvvEwQeYCQdD/oV+CN9oWhxLk7ibcBdOtv0UzBqHCEKRwbKceYoTK8t3fQ==",
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/concurrently/-/concurrently-6.0.1.tgz",
"integrity": "sha512-YCF/Wf31a910hXu7eGN9/SyHKD/usw3Shw4IPYuqIsxxC39v92engYlIlOs/zXnBJtX/6aVuhgzfhZeGJkhU4w==",
"dev": true,
"dependencies": {
"chalk": "^4.1.0",
@ -9212,6 +9213,18 @@
"eslint": "^3 || ^4 || ^5 || ^6 || ^7"
}
},
"node_modules/eslint-plugin-modules-newline": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/eslint-plugin-modules-newline/-/eslint-plugin-modules-newline-0.0.6.tgz",
"integrity": "sha512-69NpBr68U6pmXL+y+KHl/64PwRarceC3/sCNUVxRbe0gPI32SIw8AtdpkqNiJYCa2yMd4lRrkrnU09Yio7KVzA==",
"dev": true,
"dependencies": {
"requireindex": "~1.1.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/eslint-plugin-prettier": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.3.1.tgz",
@ -20632,6 +20645,15 @@
"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg=="
},
"node_modules/requireindex": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/requireindex/-/requireindex-1.1.0.tgz",
"integrity": "sha1-5UBLgVV+91225JxacgBIk/4D4WI=",
"dev": true,
"engines": {
"node": ">=0.10.5"
}
},
"node_modules/requires-port": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
@ -31360,9 +31382,9 @@
}
},
"concurrently": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/concurrently/-/concurrently-6.0.0.tgz",
"integrity": "sha512-Ik9Igqnef2ONLjN2o/OVx1Ow5tymVvvEwQeYCQdD/oV+CN9oWhxLk7ibcBdOtv0UzBqHCEKRwbKceYoTK8t3fQ==",
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/concurrently/-/concurrently-6.0.1.tgz",
"integrity": "sha512-YCF/Wf31a910hXu7eGN9/SyHKD/usw3Shw4IPYuqIsxxC39v92engYlIlOs/zXnBJtX/6aVuhgzfhZeGJkhU4w==",
"dev": true,
"requires": {
"chalk": "^4.1.0",
@ -33638,6 +33660,15 @@
"language-tags": "^1.0.5"
}
},
"eslint-plugin-modules-newline": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/eslint-plugin-modules-newline/-/eslint-plugin-modules-newline-0.0.6.tgz",
"integrity": "sha512-69NpBr68U6pmXL+y+KHl/64PwRarceC3/sCNUVxRbe0gPI32SIw8AtdpkqNiJYCa2yMd4lRrkrnU09Yio7KVzA==",
"dev": true,
"requires": {
"requireindex": "~1.1.0"
}
},
"eslint-plugin-prettier": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.3.1.tgz",
@ -42490,6 +42521,12 @@
"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg=="
},
"requireindex": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/requireindex/-/requireindex-1.1.0.tgz",
"integrity": "sha1-5UBLgVV+91225JxacgBIk/4D4WI=",
"dev": true
},
"requires-port": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",

View File

@ -65,7 +65,7 @@
"@types/react-dom": "^17.0.3",
"@types/react-redux": "^7.1.16",
"@types/react-router-dom": "^5.1.7",
"concurrently": "^6.0.0",
"concurrently": "^6.0.1",
"electron": "^12.0.1",
"eslint": "^7.23.0",
"eslint-config-airbnb": "^18.2.1",
@ -73,6 +73,7 @@
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-modules-newline": "^0.0.6",
"eslint-plugin-prettier": "^3.3.1",
"less-loader": "^6.1.0",
"prettier": "^2.2.1",

View File

@ -1,4 +1,7 @@
import { useEffect, useMemo } from 'react';
import {
useEffect,
useMemo,
} from 'react';
import {
useLocation,
Switch,
@ -7,12 +10,18 @@ import {
Redirect,
generatePath,
} from 'react-router-dom';
import { Layout, Result } from 'antd';
import {
Layout,
Result,
} from 'antd';
import { connect } from 'react-redux';
import Dialog from './components/Dialog';
import { loadAll } from './utils/api';
import SideBar, { DialogMatchedPathType } from './components/SideBar';
import { AppState, UIState } from './types/state';
import {
AppState,
UIState,
} from './types/state';
import BurnButton from './components/BurnButton';
import TopBar from './components/TopBar';
import StatusBar from './components/StatusBar';

View File

@ -1,4 +1,7 @@
import { Button, Grid } from 'antd';
import {
Button,
Grid,
} from 'antd';
import { FireOutlined } from '@ant-design/icons';
const { useBreakpoint } = Grid;

View File

@ -26,13 +26,17 @@ import {
ScalarConstant as ScalarConstantType,
ConstantTypes,
} from '../types/config';
import {
Tune as TuneType,
} from '../types/tune';
import { Tune as TuneType } from '../types/tune';
import { findOnPage } from '../utils/config/find';
import { parseXy, parseZ } from '../utils/tune/table';
import {
parseXy,
parseZ,
} from '../utils/tune/table';
import Map from './Dialog/Map';
import { evaluateExpression, isExpression } from '../utils/tune/expression';
import {
evaluateExpression,
isExpression,
} from '../utils/tune/expression';
import useStorage from '../hooks/useStorage';
interface DialogsAndCurves {
@ -291,7 +295,7 @@ const Dialog = ({
type = PanelTypes.FIELDS;
fields = (currentDialog as DialogType)
.fields
.filter((field) => field.title !== '' );
.filter((field) => field.title !== '');
} else if ('zBins' in currentDialog) {
type = PanelTypes.TABLE;
}
@ -352,21 +356,21 @@ const Dialog = ({
// case ConstantTypes.ARRAY: // TODO: arrays
case ConstantTypes.BITS:
input = <SmartSelect
defaultValue={`${tuneField.value}`}
values={constant.values as string[]}
disabled={!enabled}
/>;
defaultValue={`${tuneField.value}`}
values={constant.values as string[]}
disabled={!enabled}
/>;
break;
case ConstantTypes.SCALAR:
input = <SmartNumber
defaultValue={Number(tuneField.value)}
digits={(constant as ScalarConstantType).digits}
min={((constant as ScalarConstantType).min as number) || 0}
max={(constant as ScalarConstantType).max as number}
disabled={!enabled}
units={(constant as ScalarConstantType).units}
/>;
defaultValue={Number(tuneField.value)}
digits={(constant as ScalarConstantType).digits}
min={((constant as ScalarConstantType).min as number) || 0}
max={(constant as ScalarConstantType).max as number}
disabled={!enabled}
units={(constant as ScalarConstantType).units}
/>;
break;
default:

View File

@ -26,24 +26,24 @@ const SmartSelect = ({
)
) {
return <Switch
defaultChecked={[Switches.ON, Switches.YES].includes(defaultValue as Switches)}
checkedChildren={<CheckOutlined />}
unCheckedChildren={<CloseOutlined />}
/>;
defaultChecked={[Switches.ON, Switches.YES].includes(defaultValue as Switches)}
checkedChildren={<CheckOutlined />}
unCheckedChildren={<CloseOutlined />}
/>;
}
if (values.length < 3) {
return (
<Radio.Group
<Radio.Group
defaultValue={values.indexOf(defaultValue)}
optionType="button"
buttonStyle="solid"
disabled={disabled}
>
{values.map((val: string, index) =>
{values.map((val: string, index) =>
<Radio key={val} value={index}>{val}</Radio>,
)}
</Radio.Group>
)}
</Radio.Group>
);
}

View File

@ -24,16 +24,25 @@ import {
import { CheckboxValueType } from 'antd/lib/checkbox/Group';
import useBreakpoint from 'antd/lib/grid/hooks/useBreakpoint';
import { connect } from 'react-redux';
import { Field, Result as ParserResult } from 'mlg-converter/dist/types';
import {
Field,
Result as ParserResult,
} from 'mlg-converter/dist/types';
import PerfectScrollbar from 'react-perfect-scrollbar';
// eslint-disable-next-line import/no-unresolved
import MlgParserWorker from 'worker-loader!../workers/mlgParser.worker';
import { loadLogs } from '../utils/api';
import Canvas, { LogEntry } from './Log/Canvas';
import { AppState, UIState } from '../types/state';
import {
AppState,
UIState,
} from '../types/state';
import { Config } from '../types/config';
import store from '../store';
import { formatBytes, msToTime } from '../utils/number';
import {
formatBytes,
msToTime,
} from '../utils/number';
const { TabPane } = Tabs;
const { Content } = Layout;
@ -139,11 +148,11 @@ const Log = ({ ui, config }: { ui: UIState, config: Config }) => {
<TabPane tab={<FileTextOutlined />} key="files">
<PerfectScrollbar options={{ suppressScrollX: true }}>
Files
</PerfectScrollbar>
</PerfectScrollbar>
</TabPane>
<TabPane tab={<DashboardOutlined />} key="gauges">
Gauges
</TabPane>
</TabPane>
</Tabs>
}
</Sider>

View File

@ -19,9 +19,7 @@ import {
Config as ConfigType,
Menus as MenusType,
} from '../types/config';
import {
Tune as TuneType,
} from '../types/tune';
import { Tune as TuneType } from '../types/tune';
import Icon from './SideBar/Icon';
import { evaluateExpression } from '../utils/tune/expression';
import { Routes } from '../routes';

View File

@ -1,8 +1,20 @@
import { Layout, Space, Row, Col } from 'antd';
import { CarOutlined, InfoCircleOutlined } from '@ant-design/icons';
import {
Layout,
Space,
Row,
Col,
} from 'antd';
import {
CarOutlined,
InfoCircleOutlined,
} from '@ant-design/icons';
import { connect } from 'react-redux';
import { AppState, ConfigState, StatusState } from '../types/state';
import {
AppState,
ConfigState,
StatusState,
} from '../types/state';
const { Footer } = Layout;

View File

@ -1,6 +1,4 @@
import {
Help as HelpType,
} from '../types/config';
import { Help as HelpType } from '../types/config';
export const help: HelpType = {
reqFuel: 'The base reference pulse width required to achieve stoichiometric at 100% VE and a manifold absolute pressure (MAP) of 100kPa using current settings.',

View File

@ -1,6 +1,4 @@
import {
Dialogs as DialogsType,
} from '../types/config';
import { Dialogs as DialogsType } from '../types/config';
const standardDialogs: DialogsType = {
std_injection: {

View File

@ -1,4 +1,7 @@
import { app, BrowserWindow } from 'electron';
import {
app,
BrowserWindow,
} from 'electron';
import path from 'path';
const isDev = !app.isPackaged;

View File

@ -815,7 +815,7 @@ class INI {
val.startsWith('$')
? this.result.defines[val.slice(1)]
: val
)).flat();
)).flat();
this.result.defines[result.name] = resolved;
}
@ -869,7 +869,7 @@ class INI {
size: result.size,
length: Number(result.length),
};
break;
break;
default:
break;
}

View File

@ -1,6 +1,10 @@
/* eslint-disable no-param-reassign */
import { configureStore, createAction, createReducer } from '@reduxjs/toolkit';
import {
configureStore,
createAction,
createReducer,
} from '@reduxjs/toolkit';
import * as Types from './types/state';
// tune and config

View File

@ -1,7 +1,5 @@
import store from '../store';
import {
Config as ConfigType,
} from '../types/config';
import { Config as ConfigType } from '../types/config';
import stdDialogs from '../data/standardDialogs';
import help from '../data/help';
import { divider } from '../data/constants';

View File

@ -1,6 +1,4 @@
import {
Constants as TuneConstantsType,
} from '../../types/tune';
import { Constants as TuneConstantsType } from '../../types/tune';
import {
Config as ConfigType,
@ -19,29 +17,29 @@ export const isNumber = (val: any) => !Number.isNaN(Number(val));
// ochGetCommand
export const prepareConstDeclarations = (tuneConstants: TuneConstantsType, configPages: ConfigPageType[]) => (
Object.keys(tuneConstants).map((constName: string) => {
let val = tuneConstants[constName].value;
let val = tuneConstants[constName].value;
// TODO: skip 2D and 3D maps for now
if (typeof val === 'string' && val.includes('\n')) {
return null;
}
// TODO: skip 2D and 3D maps for now
if (typeof val === 'string' && val.includes('\n')) {
return null;
}
// TODO: check whether we can limit this to a single page
const constant = configPages
.find((page: ConfigPageType) => constName in page.data)
?.data[constName];
// TODO: check whether we can limit this to a single page
const constant = configPages
.find((page: ConfigPageType) => constName in page.data)
?.data[constName];
// we need array index instead of a display value
if (constant?.type === 'bits') {
val = (constant.values as string[]).indexOf(`${val}`);
}
// we need array index instead of a display value
if (constant?.type === 'bits') {
val = (constant.values as string[]).indexOf(`${val}`);
}
// escape string values
if (typeof val === 'string') {
val = `'${val}'`;
}
// escape string values
if (typeof val === 'string') {
val = `'${val}'`;
}
return `const ${constName} = ${val};`;
return `const ${constName} = ${val};`;
})
);