-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
n/no-sync does not work with named import #102
Comments
mmm, there are a couple of ways to go about this 🤔 The main issue is that we only check for a MemberExpression ( eg: // These match
fs.magicSync('path')
fs.readFileSync.call(null, 'path')
// These do not match
readFileSync('path')
readFileSync.call(null, 'path') Option 1 We can just change the selector a little bit (lib/rules/no-sync.js:36) [
// fs.readFileSync()
"MemberExpression[property.name=/.*Sync$/]",
// readFileSync.call(null, 'path')
"MemberExpression[object.name=/.*Sync$/]",
// readFileSync()
":not(MemberExpression) > Identifier[name=/Sync$/]",
] Option 2 We can try to detect the "Sync" imports from the built modules as they're imported. Also, if I remember correctly This would be done using the import/require declarations, then we'd traverse to the variable usage to see whether a Sync method was used. I created a quick gist here: |
fixed by #127 and released in |
When
'n/no-sync': ['error', { allowAtRootLevel: false }],
works
but
is reported as espected
The text was updated successfully, but these errors were encountered: