At Azumuta we developed an eslint plugin to detect ‘old’ meteor calls like Collection.find(). It highlights these errors and allows us to get an overview of deprecated functions.
We’re looking to open source it but want to know first if this is something that would be useful… what do you think? Would you use it, or are there be better ways?
@batist that would be awesome. I created a Meteor package for detection of non-async but it’s only working at runtime. A static analysis with ESLINT would be the perfect counterpart for a holistic analysis approach!
Edit: this would also be beneficial for CI workflows that check for 3.0-readiness
2 days ago in this thread I interlinked the other thread that contains the discussion about eslint. More specifically, this is the comment that has the repo:
We should try to differentiate between server and client. All that validation is wrong for the client. These methods are still valid for client-only code. Maybe you want to avoid it in some cases and use async in others, but we definitely should not consider it simply an error.
I want to find a way to get this information from Meteor, but I think that will be hard or impossible inside the eslint plugin as the Meteor compiler decides it on the fly. Maybe for projects using “mainModule” (everybody should be using it), it would be more straightforward.
@zodern, any insights on how to achieve that inside the eslint-plugin?
The basic rules to find all files used on the server isn’t too complicated:
Find eagerly loaded files
a. check if the server has a main file
b. if not, look for any js files outside of folders named imports, client, packages, or folders that start with a .
Parse each of the eagerly loaded files and scan for static imports, dynamic imports, and require calls
Resolve each of those imports, filter out the ones that resolve to a file in a client folder or to a npm or Meteor package. Then parse those files and find the imports…
Repeat step 3 until there are no more files
A few years ago I wrote a tool to find all client files for a company. They gave me permission to open source it, but I have never got around to finishing that. If you think the code would be helpful, I can find it.