From 78d4394221e14d5ad5d8d4f89dd7172d95fb1575 Mon Sep 17 00:00:00 2001 From: Valentin Perrelle <valentin.perrelle@cea.fr> Date: Wed, 19 Apr 2023 12:24:36 +0200 Subject: [PATCH] [Ivette] one more linting rule for spaces before/after object braces --- ivette/.eslintrc.js | 2 ++ ivette/src/dome/renderer/data/arrays.ts | 2 +- ivette/src/dome/renderer/text/editor.tsx | 2 +- ivette/src/frama-c/kernel/ASTview.tsx | 4 ++-- ivette/src/frama-c/kernel/Globals.tsx | 2 +- ivette/src/frama-c/kernel/SourceCode.tsx | 2 +- ivette/src/frama-c/plugins/dive/index.tsx | 2 +- ivette/src/frama-c/plugins/eva/EvaReady/index.tsx | 2 +- ivette/src/frama-c/plugins/eva/valuetable.tsx | 4 ++-- 9 files changed, 12 insertions(+), 10 deletions(-) diff --git a/ivette/.eslintrc.js b/ivette/.eslintrc.js index 0e6507eab9d..3262f50cf01 100644 --- a/ivette/.eslintrc.js +++ b/ivette/.eslintrc.js @@ -72,6 +72,8 @@ module.exports = { "key-spacing": "error", // Disallow trailing whitespace at the end of lines "no-trailing-spaces": "error", + // Enforce consistent spacing inside braces + "object-curly-spacing": ["error", "always"], // Enforce consistent spacing before and after semicolons "semi-spacing": "error", // Enforce location of semicolons diff --git a/ivette/src/dome/renderer/data/arrays.ts b/ivette/src/dome/renderer/data/arrays.ts index a0db9f45a15..994b261ac70 100644 --- a/ivette/src/dome/renderer/data/arrays.ts +++ b/ivette/src/dome/renderer/data/arrays.ts @@ -59,7 +59,7 @@ export function merge<K, A extends K, B extends K>( f: (x : K) => unknown, ): (A & (object | B))[] { const dict = new Map(a2.map(x2 => [f(x2), x2])); // maps f(x2) to x2 - return a1.map(x1 => ({...x1, ...(dict.get(f(x1)))})); + return a1.map(x1 => ({ ...x1, ...(dict.get(f(x1))) })); } /** Maps a function through an array and returns the first computed value that diff --git a/ivette/src/dome/renderer/text/editor.tsx b/ivette/src/dome/renderer/text/editor.tsx index 17c74c8c895..ea59f699394 100644 --- a/ivette/src/dome/renderer/text/editor.tsx +++ b/ivette/src/dome/renderer/text/editor.tsx @@ -316,7 +316,7 @@ const Highlight = Language.syntaxHighlighting(Language.HighlightStyle.define([ // A language provider based on the [Lezer C++ parser], extended with // highlighting and folding information. Only comments can be folded. // (Source: https://github.com/lezer-parser/cpp) -const comment = (t: SyntaxNode): Range => ({ from: t.from + 2, to: t.to - 2}); +const comment = (t: SyntaxNode): Range => ({ from: t.from + 2, to: t.to - 2 }); const folder = Language.foldNodeProp.add({ BlockComment: comment }); const stringPrefixes = [ "L", "u", "U", "u8", "LR", "UR", "uR", "u8R", "R" ]; const cppLanguage = Language.LRLanguage.define({ diff --git a/ivette/src/frama-c/kernel/ASTview.tsx b/ivette/src/frama-c/kernel/ASTview.tsx index 19342920466..ba08e7a68b2 100644 --- a/ivette/src/frama-c/kernel/ASTview.tsx +++ b/ivette/src/frama-c/kernel/ASTview.tsx @@ -161,7 +161,7 @@ const Text = Editor.createTextField<text>(null, textToString); // This aspect computes the tree representing the currently displayed function's // code, represented by the <Text> field. -const Tree = Editor.createAspect({ t: Text }, ({t}) => rootText(t)); +const Tree = Editor.createAspect({ t: Text }, ({ t }) => rootText(t)); // This aspect computes the markers ranges of the currently displayed function's // tree, represented by the <Tree> aspect. @@ -791,7 +791,7 @@ export default function ASTview(): JSX.Element { /> <Inset /> </TitleBar> - <Component style={{ fontSize: `${fontSize}px`}} /> + <Component style={{ fontSize: `${fontSize}px` }} /> </> ); } diff --git a/ivette/src/frama-c/kernel/Globals.tsx b/ivette/src/frama-c/kernel/Globals.tsx index 299a87d749a..827957171c9 100644 --- a/ivette/src/frama-c/kernel/Globals.tsx +++ b/ivette/src/frama-c/kernel/Globals.tsx @@ -110,7 +110,7 @@ function computeFcts( const arr: functionsData[] = []; ker.forEach((kf) => { const ef = eva.getData(kf.key); - arr.push({...ef, ...kf}); + arr.push({ ...ef, ...kf }); }); return arr.sort((f, g) => alpha(f.name, g.name)); } diff --git a/ivette/src/frama-c/kernel/SourceCode.tsx b/ivette/src/frama-c/kernel/SourceCode.tsx index 7e36a45e925..739f19ba2d5 100644 --- a/ivette/src/frama-c/kernel/SourceCode.tsx +++ b/ivette/src/frama-c/kernel/SourceCode.tsx @@ -276,7 +276,7 @@ export default function SourceCode(): JSX.Element { async function displayShortcuts(): Promise<void> { await Dialogs.showMessageBox({ - buttons: [{label: "Ok"}], + buttons: [{ label: "Ok" }], details: shortcuts, message: 'Useful shortcuts' }); diff --git a/ivette/src/frama-c/plugins/dive/index.tsx b/ivette/src/frama-c/plugins/dive/index.tsx index ff649431bd3..7f035ca2e1e 100644 --- a/ivette/src/frama-c/plugins/dive/index.tsx +++ b/ivette/src/frama-c/plugins/dive/index.tsx @@ -578,7 +578,7 @@ type GraphViewRef = { const GraphView = React.forwardRef<GraphViewRef | undefined, GraphViewProps>( (props: GraphViewProps, ref) => { - const {lock, layout, selectionMode} = props; + const { lock, layout, selectionMode } = props; const [dive, setDive] = useState(() => new Dive()); const [selection, updateSelection] = States.useSelection(); diff --git a/ivette/src/frama-c/plugins/eva/EvaReady/index.tsx b/ivette/src/frama-c/plugins/eva/EvaReady/index.tsx index aacc53e93e9..4fb100582df 100644 --- a/ivette/src/frama-c/plugins/eva/EvaReady/index.tsx +++ b/ivette/src/frama-c/plugins/eva/EvaReady/index.tsx @@ -28,7 +28,7 @@ import Gallery from 'dome/controls/gallery.json'; import gearsIcon from '../images/gears.svg'; import './style.css'; -const EvaReady: React.FC = ({children}) => { +const EvaReady: React.FC = ({ children }) => { const state = States.useSyncValue(Eva.computationState); switch (state) { diff --git a/ivette/src/frama-c/plugins/eva/valuetable.tsx b/ivette/src/frama-c/plugins/eva/valuetable.tsx index d31f94ca99b..2b2490d51ad 100644 --- a/ivette/src/frama-c/plugins/eva/valuetable.tsx +++ b/ivette/src/frama-c/plugins/eva/valuetable.tsx @@ -347,7 +347,7 @@ function ProbeHeader(props: ProbeHeaderProps): JSX.Element { const isPinned = isPinnedMarker(status); const pinText = isPinned ? 'Unpin' : 'Pin'; - const loc: States.SelectionActions = { location: { fct, marker: target} }; + const loc: States.SelectionActions = { location: { fct, marker: target } }; const onClick = (): void => { setSelection(loc); selectProbe(); }; const onDoubleClick = (): void => pinProbe(!isPinned); const onContextMenu = (): void => { @@ -1041,7 +1041,7 @@ function EvaTable(): JSX.Element { /* On meta-selection, pin the selected location. */ React.useEffect(() => { const pin = (loc: States.Location): void => { - const {marker, fct} = loc; + const { marker, fct } = loc; if (marker && fct) setLocPin({ target: marker, fct }, true); }; States.MetaSelection.on(pin); -- GitLab