diff --git a/.eslintrc.json b/.eslintrc.json index a2495852f..8d58bdb49 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -25,6 +25,7 @@ "no-prototype-builtins": "off", "no-inner-declarations": "off", "no-constant-condition": "off", + "no-useless-escape": "off", "@nrwl/nx/enforce-module-boundaries": [ "error", { diff --git a/packages/core/css/parser.ts b/packages/core/css/parser.ts index c6725ca5d..1de8de2f2 100644 --- a/packages/core/css/parser.ts +++ b/packages/core/css/parser.ts @@ -237,7 +237,7 @@ export function parseRepeat(value: string, start = 0, keyword = parseKeyword(val return null; } -const unitRegEx = /\s*([+-]?(?:\d+\.\d+|\d+|\.\d+)(?:[eE][+-]?\d+)?)([a-zA-Z]+|%)?\s*/gy; +const unitRegEx = /\s*([\+\-]?(?:\d+\.\d+|\d+|\.\d+)(?:[eE][\+\-]?\d+)?)([a-zA-Z]+|%)?\s*/gy; export function parseUnit(text: string, start = 0): Parsed> { unitRegEx.lastIndex = start; const result = unitRegEx.exec(text); @@ -743,7 +743,7 @@ export function parseSimpleIdentifierSelector(text: string, start = 0): Parsed { attributeSelectorRegEx.lastIndex = start; const result = attributeSelectorRegEx.exec(text); @@ -852,13 +852,13 @@ export interface QualifiedRule { const whitespaceRegEx = /[\s\t\n\r\f]*/gmy; -const singleQuoteStringRegEx = /'((?:[^\n\r\f']|\\(?:\$|\n|[0-9a-fA-F]{1,6}\s?))*)(:?'|$)/gmy; // Besides $n, parse escape -const doubleQuoteStringRegEx = /"((?:[^\n\r\f"]|\\(?:\$|\n|[0-9a-fA-F]{1,6}\s?))*)(:?"|$)/gmy; // Besides $n, parse escape +const singleQuoteStringRegEx = /'((?:[^\n\r\f\']|\\(?:\$|\n|[0-9a-fA-F]{1,6}\s?))*)(:?'|$)/gmy; // Besides $n, parse escape +const doubleQuoteStringRegEx = /"((?:[^\n\r\f\"]|\\(?:\$|\n|[0-9a-fA-F]{1,6}\s?))*)(:?"|$)/gmy; // Besides $n, parse escape -const commentRegEx = /(\/\*(?:[^*]|\*[^/])*\*\/)/gmy; -const numberRegEx = /[+-]?(?:\d+\.\d+|\d+|\.\d+)(?:[eE][+-]?\d+)?/gmy; +const commentRegEx = /(\/\*(?:[^\*]|\*[^\/])*\*\/)/gmy; +const numberRegEx = /[\+\-]?(?:\d+\.\d+|\d+|\.\d+)(?:[eE][\+\-]?\d+)?/gmy; // eslint-disable-next-line no-control-regex -const nameRegEx = /-?(?:(?:[a-zA-Z_]|[^\x00-\x7F]|\\(?:\$|\n|[0-9a-fA-F]{1,6}\s?))(?:[a-zA-Z_0-9-]*|\\(?:\$|\n|[0-9a-fA-F]{1,6}\s?))*)/gmy; +const nameRegEx = /-?(?:(?:[a-zA-Z_]|[^\x00-\x7F]|\\(?:\$|\n|[0-9a-fA-F]{1,6}\s?))(?:[a-zA-Z_0-9\-]*|\\(?:\$|\n|[0-9a-fA-F]{1,6}\s?))*)/gmy; // const nonQuoteURLRegEx = /(:?[^\)\s\t\n\r\f\'\"\(]|\\(?:\$|\n|[0-9a-fA-F]{1,6}\s?))*/gym; // TODO: non-printable code points omitted type InputToken = '(' | ')' | '{' | '}' | '[' | ']' | ':' | ';' | ',' | ' ' | '^=' | '|=' | '$=' | '*=' | '~=' | '' | undefined | /* */ InputTokenObject | FunctionInputToken | FunctionToken | SimpleBlock | AtKeywordToken; diff --git a/packages/core/ui/builder/binding-builder.ts b/packages/core/ui/builder/binding-builder.ts index 404df5682..b07613510 100644 --- a/packages/core/ui/builder/binding-builder.ts +++ b/packages/core/ui/builder/binding-builder.ts @@ -1,5 +1,5 @@ // regex that contains all symbols applicable for expression used to AI detect an expression. -const expressionSymbolsRegex = /[+-*/%?:<>=!|&()^~]/; +const expressionSymbolsRegex = /[\+\-\*\/%\?:<>=!\|&\(\)^~]/; export namespace bindingConstants { export const sourceProperty = 'sourceProperty'; diff --git a/packages/core/utils/utils-common.ts b/packages/core/utils/utils-common.ts index b453d19c9..991ae0dbb 100644 --- a/packages/core/utils/utils-common.ts +++ b/packages/core/utils/utils-common.ts @@ -11,7 +11,7 @@ export const RESOURCE_PREFIX = 'res://'; export const FILE_PREFIX = 'file:///'; export function escapeRegexSymbols(source: string): string { - const escapeRegex = /[-[]\/{}()*+?.\\^$|]/g; + const escapeRegex = /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g; return source.replace(escapeRegex, '\\$&'); }