diff --git a/ivette/.eslintrc.js b/ivette/.eslintrc.js index caf5fc6d1f5b4272de33915d69a7754bea163bdd..32bd12c19a23afe635ae2dc5b4edc8f88b196c85 100644 --- a/ivette/.eslintrc.js +++ b/ivette/.eslintrc.js @@ -39,11 +39,20 @@ module.exports = { "no-underscore-dangle": "off", // Allow return statements even if not strictly needed "no-useless-return": "off", - // Disable warn about shadowing concerning variables - "no-shadow": "off", + // Forbid shadowing concerning variables + "no-shadow": [ "error" ], + // Force single class member per line "lines-between-class-members": [ "error", "always", { "exceptAfterSingleLine": true } ], + // Allow blank line separators for complex blocks + "padded-blocks": "off", + // Allow braces on their own line + "@typescript-eslint/brace-style": "off", + // Allow single command after if + "curly":"off", + // Do not specify position for single commands + "nonblock-statement-body-position": "off", // Allow ++/-- operators only in for-loops "no-plusplus": ["error", { "allowForLoopAfterthoughts": true }], // Just warn about simple promise rejections diff --git a/ivette/EMACS.el b/ivette/EMACS.el index 33a77e770842f14018f20d2d165841455f141ebd..0b474609b3cc917db56eca077d665273f2121952 100644 --- a/ivette/EMACS.el +++ b/ivette/EMACS.el @@ -26,7 +26,8 @@ (setq company-tooltip-align-annotations t) ;; formats the buffer before saving -;; (add-hook 'before-save-hook 'tide-format-before-save) +;; (strongly recommanded to please es-linter) +(add-hook 'before-save-hook 'tide-format-before-save) ;; Setup Tide for typescript (add-hook 'typescript-mode-hook #'setup-tide-mode) diff --git a/ivette/src/frama-c/LabViews.tsx b/ivette/src/frama-c/LabViews.tsx index bf41e8ba3d498d2b22a1a9340ff263043c50241c..0c3cadd7c717f16a16998efcd18648e0ba0d8873 100644 --- a/ivette/src/frama-c/LabViews.tsx +++ b/ivette/src/frama-c/LabViews.tsx @@ -521,9 +521,14 @@ function CustomViews({ settings, shape, setShape, views: libViews }: any) { const DRAGOVERLAY = { className: 'labview-stock' }; -function CustomGroup( - { dnd, shape, setDragging, id, title, label, components }: any, -) { +function CustomGroup({ + dnd, shape, setDragging, + id: sectionId, + title: sectionTitle, + label: sectionLabel, + components, +}: any) +{ const makeComponent = ({ id, label, title }: any) => { const itemId = getItemId('components', id); const disabled = Grids.getShapeItem(shape, itemId) !== undefined; @@ -546,7 +551,7 @@ function CustomGroup( }; return ( - <Section id={id} label={label} title={title}> + <Section id={sectionId} label={sectionLabel} title={sectionTitle}> {components.map(makeComponent)} </Section> ); diff --git a/ivette/src/frama-c/server.ts b/ivette/src/frama-c/server.ts index c1d9f6dcc9a554640ead9eb1b95028bd2edda93b..00238a9e834c1122a53545668bd45a445f409b36 100644 --- a/ivette/src/frama-c/server.ts +++ b/ivette/src/frama-c/server.ts @@ -152,7 +152,7 @@ export function isRunning(): boolean { return status === Status.RUNNING; } * @return {number} pending requests */ export function getPending(): number { - return _.reduce(pending, (_, n) => n + 1, 0); + return _.reduce(pending, (_rq, n) => n + 1, 0); } /** @@ -212,7 +212,7 @@ export function start() { _status(Status.STARTED); _launch() .then(() => _status(Status.RUNNING)) - .catch((error) => _status(Status.FAILED, error)); + .catch((err) => _status(Status.FAILED, err)); return; case Status.KILLING: _status(Status.RESTART); @@ -444,10 +444,10 @@ async function _launch() { buffer.append('Error:', err, '\n'); _close(err); }); - process.on('exit', (status: Status, signal: string) => { - if (signal) buffer.log('Signal:', signal); - if (status) buffer.log('Exit:', status); - _close(signal || status); + process.on('exit', (estatus: Status, esignal: string) => { + if (esignal) buffer.log('Signal:', esignal); + if (estatus) buffer.log('Exit:', estatus); + _close(esignal || estatus); }); // Connect to Server socket = new ZmqRequest(); @@ -490,7 +490,7 @@ function _shutdown() { } } -function _close(error: string) { +function _close(err: string) { _reset(); if (killing) { clearTimeout(killing); @@ -505,8 +505,8 @@ function _close(error: string) { process.kill(); process = undefined; } - if (error) { - _status(Status.FAILED, error); + if (err) { + _status(Status.FAILED, err); } else { if (status === Status.RESTART) setImmediate(start); _status(Status.OFF); @@ -641,14 +641,14 @@ Dome.on(SHUTDOWN, () => { * @typedef RqKind * @summary Request kind. * @description - * - `GET` Used to read data from the server - * - `SET` Used to write data into the server - * - `EXEC` Used to make the server execute a task + * - `R_GET` Used to read data from the server + * - `R_SET` Used to write data into the server + * - `R_EXEC` Used to make the server execute a task */ export enum RqKind { - GET = 'GET', - SET = 'SET', - EXEC = 'EXEC' + R_GET = 'GET', + R_SET = 'SET', + R_EXEC = 'EXEC' } /** @@ -667,7 +667,7 @@ export interface Request { * @param sr - the server request description. */ export async function GET(sr: Request) { - return send(RqKind.GET, sr.endpoint, sr.params); + return send(RqKind.R_GET, sr.endpoint, sr.params); } /** @@ -675,7 +675,7 @@ export async function GET(sr: Request) { * @param sr - the server request description. */ export async function SET(sr: Request) { - return send(RqKind.SET, sr.endpoint, sr.params); + return send(RqKind.R_SET, sr.endpoint, sr.params); } /** @@ -683,7 +683,7 @@ export async function SET(sr: Request) { * @param sr - the server request description. */ export async function EXEC(sr: Request) { - return send(RqKind.EXEC, sr.endpoint, sr.params); + return send(RqKind.R_EXEC, sr.endpoint, sr.params); } /** @@ -725,11 +725,11 @@ function _resolve(id: string | number, data: string) { } } -function _reject(id: string | number, error: string) { +function _reject(id: string | number, err: string) { const promise = pending[id]; if (promise) { delete pending[id]; - promise.reject(error); + promise.reject(err); } } diff --git a/ivette/src/renderer/Controller.tsx b/ivette/src/renderer/Controller.tsx index 30fd813cf0a7419fff240992ef0f88fdaa9e7d0f..783bb52736e42e69188014633974738b8ddc7421 100644 --- a/ivette/src/renderer/Controller.tsx +++ b/ivette/src/renderer/Controller.tsx @@ -150,14 +150,14 @@ function execCmdLine(cmd: string) { } const RenderConsole = () => { - const [cmd, switchCmd] = Dome.useSwitch(); + const [command, switchCmd] = Dome.useSwitch(); const { current, next, prev, index, length, update, insert, clear }: any = Dome.useHistory('frama-c.command.history'); const doExec = () => { - const cmd = getCmdLine(); - if (cmd !== current) insert(cmd); - execCmdLine(cmd); + const cmdline = getCmdLine(); + if (cmdline !== current) insert(cmdline); + execCmdLine(cmdline); switchCmd(); }; const doNext = () => { cmdLine.getDoc().setValue(next() || ''); }; @@ -169,21 +169,21 @@ const RenderConsole = () => { }; return ( <> - <TitleBar label={cmd ? 'Command Line' : 'Console'}> - <Label className="dimmed" display={cmd && length > 0}> + <TitleBar label={command ? 'Command Line' : 'Console'}> + <Label className="dimmed" display={command && length > 0}> {1 + index}/{length} </Label> <Space /> <IconButton icon="TRASH" - display={cmd && clear} + display={command && clear} disabled={!clear} onClick={clear} title="Clear History" /> <IconButton icon="CROSS" - display={cmd && clear} + display={command && clear} disabled={!current} onClick={doDrop} title="Remove Command" @@ -191,20 +191,20 @@ const RenderConsole = () => { <Space /> <IconButton icon="MEDIA.PREV" - display={cmd} + display={command} disabled={!prev} onClick={doPrev} title="Previous Command" /> <IconButton icon="RELOAD" - display={cmd} + display={command} onClick={doReload} title="Reset Command Line" /> <IconButton icon="MEDIA.NEXT" - display={cmd} + display={command} disabled={!next} onClick={doNext} title="Previous Command" @@ -212,21 +212,21 @@ const RenderConsole = () => { <Space /> <IconButton icon="MEDIA.PLAY" - display={cmd} + display={command} onClick={doExec} title="Execute Command Line" /> <IconButton icon="EDIT" - selected={cmd} + selected={command} onClick={switchCmd} title="Edit Command Line" /> </TitleBar> <Text - buffer={cmd ? cmdLine : Server.buffer} + buffer={command ? cmdLine : Server.buffer} mode="text" - readOnly={!cmd} + readOnly={!command} theme="ambiance" /> </>