Closed wordpure closed 8 months ago
Please avoid starting the function body with a function declaration.
Top-level functions are optional and will be automatically removed if their signature matches the default signature.
If util.isFuncExp('let pattern=...') === false
, the function body will be automatically wrapped with a function declaration when needed. However, if util.isFuncExp('function smartTest(...') === true
, it will not be considered as a function body, which leads to this bug.
But as long as a custom function is added, the main function and its parameter definitions in the rule will become # REMOVABLE after exporting, and the exported rules cannot be used after being re-imported..
//# REMOVABLE
is used internally to prevent indentation from being trimmed, which is the expected behavior.
Thanks for your explanation, I will avoid defining functions at the beginning of function body.
However, I also found that if the Code Editor is not installed when the rules are imported, or the Code Editor installed is disabled after the rules are added, the top-level function containing the custom function will automatically become // # REMOVABLE
.
Although this does not affect the normal use of the rules, it may cause confusion for those who do not understand the situation.
Is it possible to visually hide // #REMOVABLE
when Code Editor is not detected?
Adding a custom function to the code will cause the main function and its parameter definitions to disappear and # REMOVABLE will be displayed.
https://github.com/ichaoX/ext-webRequest/assets/68013962/01c51994-dfa8-4de9-9bac-60a2c5cccbea
The strange thing is that as long as you add any statement in front of the custom function, the problem will not appear in the code editing box, and the rules can be used normally after being saved.
But as long as a custom function is added, the main function and its parameter definitions in the rule will become # REMOVABLE after exporting, and the exported rules cannot be used after being re-imported..