-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DO NOT REVIEW] Migrate to eslint 9 and flat config #2192
base: main
Are you sure you want to change the base?
Conversation
…ncies on postinstall
0c3ea53
to
e1083ef
Compare
e1083ef
to
8c6621d
Compare
## Proposed change <!-- Please include a summary of the changes and the related issue. Please also include relevant motivation and context. --> ## Related issues <!-- Please make sure to follow the [contribution guidelines](https://github.com/amadeus-digital/Otter/blob/main/CONTRIBUTING.md) --> *- No issue associated -* <!-- * 🐛 Fix #issue --> <!-- * 🐛 Fix resolves #issue --> <!-- * 🚀 Feature #issue --> <!-- * 🚀 Feature resolves #issue --> <!-- * Pull Request #issue -->
@@ -42,27 +52,27 @@ | |||
*/ | |||
private parseCssVariable(name: string, value = ''): CssVariable { | |||
const defaultValue = value.trim(); | |||
const res = defaultValue.match(/^var\( *([^,)]*) *(?:, *([^,()]*(\(.*\))?))*\)$/); | |||
const res = defaultValue.match(/^var\( *([^),]*) *(?:, *([^(),]*(\(.*\))?))*\)$/); |
Check failure
Code scanning / CodeQL
Inefficient regular expression High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 5 days ago
To fix the problem, we need to modify the regular expression to remove the ambiguity that causes exponential backtracking. This can be achieved by making the sub-expressions more specific and avoiding nested quantifiers.
- The original regular expression on line 55 is:
^var\( *([^),]*) *(?:, *([^(),]*(\(.*\))?))*\)$
- We will modify it to:
^var\(\s*([^),\s]+)\s*(?:,\s*([^(),\s]+(?:\(.*\))?))*\s*\)$
This change ensures that the sub-expressions are more specific and reduces the risk of catastrophic backtracking.
-
Copy modified line R55 -
Copy modified line R66
@@ -54,3 +54,3 @@ | ||
const defaultValue = value.trim(); | ||
const res = defaultValue.match(/^var\( *([^),]*) *(?:, *([^(),]*(\(.*\))?))*\)$/); | ||
const res = defaultValue.match(/^var\(\s*([^),\s]+)\s*(?:,\s*([^(),\s]+(?:\(.*\))?))*\s*\)$/); | ||
const ret: CssVariable = { name, defaultValue }; | ||
@@ -65,3 +65,3 @@ | ||
do { | ||
ref = /var\( *([^),]*) *(?:, *([^(),]*(\(.*\))?))*\)/.exec(findRef); | ||
ref = /var\(\s*([^),\s]+)\s*(?:,\s*([^(),\s]+(?:\(.*\))?))*\s*\)/.exec(findRef); | ||
if (ref) { |
@@ -42,27 +52,27 @@ | |||
*/ | |||
private parseCssVariable(name: string, value = ''): CssVariable { | |||
const defaultValue = value.trim(); | |||
const res = defaultValue.match(/^var\( *([^,)]*) *(?:, *([^,()]*(\(.*\))?))*\)$/); | |||
const res = defaultValue.match(/^var\( *([^),]*) *(?:, *([^(),]*(\(.*\))?))*\)$/); |
Check failure
Code scanning / CodeQL
Inefficient regular expression High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 5 days ago
To fix the problem, we need to modify the regular expression to avoid the use of ambiguous patterns that can cause exponential backtracking. Specifically, we should replace the .*
pattern with a more precise pattern that matches the expected characters without causing ambiguity.
- The original regular expression on line 55 is:
^var\( *([^),]*) *(?:, *([^(),]*(\(.*\))?))*\)$
- We will replace
.*
with a more specific pattern that matches any character except for parentheses, commas, and spaces, which are the delimiters in this context.
-
Copy modified line R55 -
Copy modified line R66
@@ -54,3 +54,3 @@ | ||
const defaultValue = value.trim(); | ||
const res = defaultValue.match(/^var\( *([^),]*) *(?:, *([^(),]*(\(.*\))?))*\)$/); | ||
const res = defaultValue.match(/^var\( *([^),]*) *(?:, *([^(),]*\([^()]*\))?)*\)$/); | ||
const ret: CssVariable = { name, defaultValue }; | ||
@@ -65,3 +65,3 @@ | ||
do { | ||
ref = /var\( *([^),]*) *(?:, *([^(),]*(\(.*\))?))*\)/.exec(findRef); | ||
ref = /var\( *([^),]*) *(?:, *([^(),]*\([^()]*\))?)*\)/.exec(findRef); | ||
if (ref) { |
let findRef = defaultValue; | ||
let ref: RegExpExecArray | null; | ||
const references: Record<string, CssVariable> = {}; | ||
do { | ||
ref = /var\( *([^,)]*) *(?:, *([^,()]*(\(.*\))?))*\)/.exec(findRef); | ||
ref = /var\( *([^),]*) *(?:, *([^(),]*(\(.*\))?))*\)/.exec(findRef); |
Check failure
Code scanning / CodeQL
Inefficient regular expression High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 5 days ago
To fix the problem, we need to modify the regular expression to remove the ambiguity that causes exponential backtracking. This can be achieved by making the sub-expressions more specific and avoiding nested quantifiers that can match the same string in multiple ways.
The best way to fix the problem is to rewrite the regular expression to ensure that each part of the pattern is unambiguous. Specifically, we can replace the ambiguous parts with more precise patterns that do not overlap in their matching capabilities.
-
Copy modified line R55 -
Copy modified line R66
@@ -54,3 +54,3 @@ | ||
const defaultValue = value.trim(); | ||
const res = defaultValue.match(/^var\( *([^),]*) *(?:, *([^(),]*(\(.*\))?))*\)$/); | ||
const res = defaultValue.match(/^var\(\s*([^),\s]+)\s*(?:,\s*([^(),\s]+(?:\([^)]*\))?))*\s*\)$/); | ||
const ret: CssVariable = { name, defaultValue }; | ||
@@ -65,3 +65,3 @@ | ||
do { | ||
ref = /var\( *([^),]*) *(?:, *([^(),]*(\(.*\))?))*\)/.exec(findRef); | ||
ref = /var\(\s*([^),\s]+)\s*(?:,\s*([^(),\s]+(?:\([^)]*\))?))*\s*\)/.exec(findRef); | ||
if (ref) { |
let findRef = defaultValue; | ||
let ref: RegExpExecArray | null; | ||
const references: Record<string, CssVariable> = {}; | ||
do { | ||
ref = /var\( *([^,)]*) *(?:, *([^,()]*(\(.*\))?))*\)/.exec(findRef); | ||
ref = /var\( *([^),]*) *(?:, *([^(),]*(\(.*\))?))*\)/.exec(findRef); |
Check failure
Code scanning / CodeQL
Inefficient regular expression High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 5 days ago
To fix the problem, we need to modify the regular expression to remove the ambiguity that causes exponential backtracking. Specifically, we should replace the .*
pattern with a more specific pattern that avoids matching in multiple ways. In this case, we can replace .*
with [^()]*
to ensure that the pattern matches any character except parentheses, which are the delimiters in the context of this regular expression.
- Modify the regular expression on line 55 and line 66 to replace
.*
with[^()]*
. - Ensure that the new pattern maintains the existing functionality of matching CSS variable references.
-
Copy modified line R55 -
Copy modified line R66
@@ -54,3 +54,3 @@ | ||
const defaultValue = value.trim(); | ||
const res = defaultValue.match(/^var\( *([^),]*) *(?:, *([^(),]*(\(.*\))?))*\)$/); | ||
const res = defaultValue.match(/^var\( *([^),]*) *(?:, *([^(),]*(\([^()]*\))?))*\)$/); | ||
const ret: CssVariable = { name, defaultValue }; | ||
@@ -65,3 +65,3 @@ | ||
do { | ||
ref = /var\( *([^),]*) *(?:, *([^(),]*(\(.*\))?))*\)/.exec(findRef); | ||
ref = /var\( *([^),]*) *(?:, *([^(),]*(\([^()]*\))?))*\)/.exec(findRef); | ||
if (ref) { |
…lugins packages (#2504)
62acf90
to
cd54143
Compare
Proposed change
Migrate to eslint 9 and flat config
Missing in this PR:
@o3r/eslint-config
jsdoc/check-examples