Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Transforming string concatenations to template strings#10

Draft
julian-schneider wants to merge1 commit intoRTVision:master
base:master
Choose a base branch
Loading
fromjulian-schneider:allow-string-concat

Conversation

@julian-schneider
Copy link

@julian-schneiderjulian-schneider commentedJul 24, 2023
edited
Loading

Addresses#8.

Draft PR with hacky code that transforms any line containingimport(...) to a template string as a preprocessing step, but without checking the original content.
If the original line was not even a string concatenation, but e.g. part of a regexas happening here, it breaks the regex.

If the user is aware of this risk, the code can be used in combination with thefilter option, as to not break other module code. But it would be nicer to be able to prevent the issue entirely:

Normally,this line does a final check if the import statement contains a template string. But since the new code has transformeddestinationFile to a template string already, the check is now useless. If this condition was changed to effectively check whether the original line was either a template string, or a valid import statement containing simple string concatenation, this code should work fine. But I did not find a robust way to check that.

An alternative to using this code would be to let ESLint do the job: Theprefer-template rule can be enforced via the--fix option, which might be a robust preprocessing step for string concatenation.

warning: this code transforms any line containing `import(...)` to a template string without checking the original content. If the original line was not even a string concatenation, but e.g. part of a regex, it breaks it.
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@julian-schneider

[8]ページ先頭

©2009-2025 Movatter.jp