From 02c570d00cdf9e0c55395a9b957624350a6dcab0 Mon Sep 17 00:00:00 2001 From: bre1470 <40056287+bre1470@users.noreply.github.com> Date: Fri, 26 Mar 2021 11:49:55 +0100 Subject: [PATCH 1/3] Fixed no-optional-chaining. --- lib/rules/no-optional-chaining.js | 7 ++++--- package.json | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/rules/no-optional-chaining.js b/lib/rules/no-optional-chaining.js index e674b16..f88109b 100644 --- a/lib/rules/no-optional-chaining.js +++ b/lib/rules/no-optional-chaining.js @@ -34,13 +34,14 @@ module.exports = { //---------------------------------------------------------------------- const program = (node) => { - const match = /\w\?\.\w/.exec(code); + const pattern = /\?\.[\w\[\(]/g; + const match = pattern.exec(code); if (match) { - const codeBefore = code.substr(0, match.lastIndex + 1); + const codeBefore = code.substr(0, pattern.lastIndex - match[0].length); const linesBefore = codeBefore.split('\n'); const line = linesBefore[linesBefore.length - 1]; - + console.log(match, codeBefore, linesBefore, line); context.report({ node: node, loc: { diff --git a/package.json b/package.json index f6019ce..eb38ff2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-highcharts", - "version": "1.0.1", + "version": "1.0.5", "description": "ESLint rules for the Highcharts project", "keywords": [ "eslint", From 26eca5fa79447b061d1276c48e550f37005874c5 Mon Sep 17 00:00:00 2001 From: bre1470 <40056287+bre1470@users.noreply.github.com> Date: Fri, 26 Mar 2021 11:50:27 +0100 Subject: [PATCH 2/3] Fixed no-optional-chaining. --- lib/rules/no-optional-chaining.js | 7 ++++--- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/rules/no-optional-chaining.js b/lib/rules/no-optional-chaining.js index e674b16..f88109b 100644 --- a/lib/rules/no-optional-chaining.js +++ b/lib/rules/no-optional-chaining.js @@ -34,13 +34,14 @@ module.exports = { //---------------------------------------------------------------------- const program = (node) => { - const match = /\w\?\.\w/.exec(code); + const pattern = /\?\.[\w\[\(]/g; + const match = pattern.exec(code); if (match) { - const codeBefore = code.substr(0, match.lastIndex + 1); + const codeBefore = code.substr(0, pattern.lastIndex - match[0].length); const linesBefore = codeBefore.split('\n'); const line = linesBefore[linesBefore.length - 1]; - + console.log(match, codeBefore, linesBefore, line); context.report({ node: node, loc: { diff --git a/package-lock.json b/package-lock.json index f9b5dc8..fbec1a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-highcharts", - "version": "1.0.1", + "version": "1.0.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index f6019ce..eb38ff2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-highcharts", - "version": "1.0.1", + "version": "1.0.5", "description": "ESLint rules for the Highcharts project", "keywords": [ "eslint", From a66c70901265bc8893c331af66399c0847134817 Mon Sep 17 00:00:00 2001 From: bre1470 <40056287+bre1470@users.noreply.github.com> Date: Fri, 26 Mar 2021 11:52:21 +0100 Subject: [PATCH 3/3] Removed debug code. --- lib/rules/no-optional-chaining.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rules/no-optional-chaining.js b/lib/rules/no-optional-chaining.js index f88109b..b8239ce 100644 --- a/lib/rules/no-optional-chaining.js +++ b/lib/rules/no-optional-chaining.js @@ -41,7 +41,7 @@ module.exports = { const codeBefore = code.substr(0, pattern.lastIndex - match[0].length); const linesBefore = codeBefore.split('\n'); const line = linesBefore[linesBefore.length - 1]; - console.log(match, codeBefore, linesBefore, line); + context.report({ node: node, loc: {