From 5d1ac22fd10f5179c1b20e7fbf1f3269c020e61a Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Fri, 5 Apr 2024 17:17:01 +0530 Subject: [PATCH] add eslint rule consistent-type-definations --- .eslintrc.cjs | 1 + packages/mermaid/src/diagrams/sequence/sequenceDb.ts | 7 ++++--- packages/mermaid/src/diagrams/sequence/types.ts | 7 +++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index dceb314c8e..d0bb27bc9e 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -53,6 +53,7 @@ module.exports = { '@typescript-eslint/no-floating-promises': 'error', '@typescript-eslint/no-misused-promises': 'error', '@typescript-eslint/no-unused-vars': 'warn', + '@typescript-eslint/consistent-type-definitions': 'warn', '@typescript-eslint/ban-ts-comment': [ 'error', { diff --git a/packages/mermaid/src/diagrams/sequence/sequenceDb.ts b/packages/mermaid/src/diagrams/sequence/sequenceDb.ts index 80638e1807..03f095fb6e 100644 --- a/packages/mermaid/src/diagrams/sequence/sequenceDb.ts +++ b/packages/mermaid/src/diagrams/sequence/sequenceDb.ts @@ -11,8 +11,9 @@ import { setDiagramTitle, } from '../common/commonDb.js'; import { ImperativeState } from '../../utils/imperativeState.js'; -import type { Actor, AddMessageParams, Box, Message } from './types.js'; +import type { Actor, AddMessageParams, Box, Message, Note } from './types.js'; +// eslint-disable-next-line @typescript-eslint/consistent-type-definitions type State = { prevActor?: string; actors: Record; @@ -20,7 +21,7 @@ type State = { destroyedActors: Record; boxes: Box[]; messages: Message[]; - notes: unknown[]; + notes: Note[]; sequenceNumbersEnabled: boolean; wrapEnabled?: boolean; currentBox?: Box; @@ -343,7 +344,7 @@ export const addNote = function ( placement: Message['placement'], message: { text: string; wrap?: boolean } ) { - const note = { + const note: Note = { actor: actor, placement: placement, message: message.text, diff --git a/packages/mermaid/src/diagrams/sequence/types.ts b/packages/mermaid/src/diagrams/sequence/types.ts index b307751601..5cc6ae249c 100644 --- a/packages/mermaid/src/diagrams/sequence/types.ts +++ b/packages/mermaid/src/diagrams/sequence/types.ts @@ -83,3 +83,10 @@ export interface AddMessageParams { activate: boolean; } + +export interface Note { + actor: { actor: string }; + placement: Message['placement']; + message: string; + wrap: boolean; +}