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;