That is an interesting idea. There are pros and cons:
If you put an autodock routine in the ship files, it will always be there and running. If you put it in the game rule, you can play with or without them; it is also possible to enable/disable it during a game by binding the routine to a key.
You can set a maximum distance to carrier in either game rule or the ship files.
If you want to add specific conditions for the squadron such as being under attack, using ship files look best.
I doubt a distance check would really solve dock queing. But it is possible to stop docking orders to the carriers that are too busy.