Skip to content

Commit 8bba666

Browse files
committed
fix: remove console ninja injection when used without eslint comment
1 parent 5608d68 commit 8bba666

4 files changed

Lines changed: 4 additions & 2 deletions

File tree

__mocks__/Examples.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export const MockEvents = () => {
7878
// comment
7979
console.log(e)
8080
}}
81+
onOpen={(e) => 'console.log(...oo_oo(`ecc41efd_0`, e))'}
8182
onFocus={(e) => {
8283
/* eslint-disable */
8384
const cleaned = 'console.log(...oo_oo(`ecc41efd_0`, e))'

__tests__/babelPluginReactLive.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ it('babelPluginReactLive', async () => {
104104
// comment
105105
console.log(e)
106106
}}
107+
onOpen={(e) => 'console.log(e)'}
107108
onFocus={(e) => {
108109
const cleaned = 'console.log(e)'
109110
}}

babelPluginReactLive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ function astToCode(ast) {
170170
function removeConsoleNinja(code) {
171171
if (code.includes('oo_oo')) {
172172
code = code.replace(
173-
/(\/\* eslint-disable \*\/)(\n|\s|)+(.*\()(\n|\s|)+...oo_oo\(`.*`,(\s|)((.*)|(.*\n.*))\)/g,
173+
/(\/\* eslint-disable \*\/)?(\n|\s|)+(.*\()(\n|\s|)+...oo_oo\(`.*`,(\s|)((.*)|(.*\n.*))\)/g,
174174
'$3$6'
175175
)
176176
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"type": "git",
1414
"url": "https://github.com/dnbexperience/eufemia.git"
1515
},
16-
"version": "1.4.1",
16+
"version": "1.4.2",
1717
"main": "babelPluginReactLive.js",
1818
"scripts": {
1919
"test": "jest",

0 commit comments

Comments
 (0)