[EXTERNAL] Improved checking for import, moved removeComments#1765
Open
sagarishere wants to merge 1 commit into01-edu:masterfrom
Open
[EXTERNAL] Improved checking for import, moved removeComments#1765sagarishere wants to merge 1 commit into01-edu:masterfrom
sagarishere wants to merge 1 commit into01-edu:masterfrom
Conversation
sagarishere
commented
Jan 24, 2023
Contributor
Author
sagarishere
left a comment
There was a problem hiding this comment.
Trying best to get the commit approved as it is really a very slow process.
| } | ||
| return { code: sanitizedCode, rawCode, path } | ||
| } catch (error) { | ||
| console.error(error) |
Contributor
Author
There was a problem hiding this comment.
the maintainer may replace the console.log(error) with fatal(error)
as fatal does precisely that plus whatever is required to be done on top of it
| } | ||
| } | ||
|
|
||
| const removeComments = (code) => { |
Contributor
Author
There was a problem hiding this comment.
the maintainer may replace this as const removeComments = (code, lang='JavaScript') =>
this helps in further direction to improve implementation
| const removeComments = (code) => { | ||
| // removes JS single line and multi-line comments only. Not for bash files etc. | ||
| // for use with multiple file-types, I suggest writing a removeComments function with language-type as input and then handling accordingly | ||
| return code.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, "").trim() |
Contributor
Author
There was a problem hiding this comment.
a condition could be added, something like if (lang === 'JavaScript') || (lang === 'JS') {
36f1c07 to
c698e50
Compare
Improved checking of imports and moved removeComments to separate function, clearly explaining that it's limited to javascript type of comments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improved checking of imports and moved removeComments to separate function, clearly explaining that it's limited to javascript type of comments.
Why?
Solution Overview
Implementation Details