From f8cff745af481eb23eec94f3eb5e29286445b3c1 Mon Sep 17 00:00:00 2001 From: Dilip Kola Date: Wed, 16 Oct 2024 14:15:01 +0530 Subject: [PATCH] fix: sonar issues --- src/engine.ts | 2 +- src/parser.ts | 6 +++--- src/reverse_translator.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/engine.ts b/src/engine.ts index f69aa6f..b7f6570 100644 --- a/src/engine.ts +++ b/src/engine.ts @@ -70,7 +70,7 @@ export class JsonTemplateEngine { if ( /^'.*'$/.test(input) || /^".*"$/.test(input) || - /^[a-zA-Z0-9_]*$/.test(input) || + /^\w+$/.test(input) || input.includes('.') ) { return `$.${input}`; diff --git a/src/parser.ts b/src/parser.ts index bb26166..870f152 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -57,11 +57,11 @@ type PathTypeResult = { }; export class JsonTemplateParser { - private lexer: JsonTemplateLexer; + private readonly lexer: JsonTemplateLexer; - private options?: EngineOptions; + private readonly options?: EngineOptions; - private pathTypesStack: PathTypeResult[] = []; + private readonly pathTypesStack: PathTypeResult[] = []; // indicates currently how many loops being parsed private loopCount = 0; diff --git a/src/reverse_translator.ts b/src/reverse_translator.ts index ccaddd8..131a712 100644 --- a/src/reverse_translator.ts +++ b/src/reverse_translator.ts @@ -38,7 +38,7 @@ import { BINDINGS_PARAM_KEY, DATA_PARAM_KEY, EMPTY_EXPR, INDENTATION_SPACES } fr import { escapeStr } from './utils'; export class JsonTemplateReverseTranslator { - private options?: EngineOptions; + private readonly options?: EngineOptions; private level = 0;