-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UIP-3197 Ignore imports in strings #21
Comments
Thanks for reporting this @nickclmb! We currently use a regex to quickly detect imports in files, which is why this is getting picked up. This one might be tough to fix without properly using the analyzer to build the AST... any ideas @Workiva/app-frameworks? |
@evanweible-wf a "real" import would always start with the word dependency_validator/lib/src/utils.dart Lines 20 to 21 in e8e2e7d
final RegExp importExportPackageRegex =
new RegExp(r'''^\s*(import|export)\s+['"]{1,3}package:([a-zA-Z0-9_]+)\/[^;]+''', multiLine: true); Something like that? |
Hi @edwardcupps-wf, the final RegExp importExportPackageRegex =
new RegExp(r'''^(\s*(import|export)\s+['"]{1,3}package:([a-zA-Z0-9_]+)\/[^;]+['"]{1,3};)+'''); it wraps single import into group, so it can handle multiple imports in a row, and ignore strings like 'import "package:name/path.dart"';
// import 'package:name/path.dart'; |
I think Evan is right, the real path forward would be to use the AST |
@evanweible-wf Agreed; we could make adjustments to the Regex to fix this case, but I think our time would be better spent just implementing the AST solution (which I don't foresee taking much time) vs wrestling with edge cases and the Regex. |
This issue has been resolved in #111, and will be included in the |
At the moment dependency validator thinks that this is real import:
The text was updated successfully, but these errors were encountered: