Exit or die in main plugin file breaking php standards recommendation

As fuxia says, the most elegant way to adhere to the rule is to just not include that code. If a file is written properly then it’s not required to be safe.

Keep in mind that PSR12 is just one set of standards, and WordPress and many plugins do not follow it. They are more likely to follow the WordPress coding standards, which do not include this rule, I believe (there is a PHP CodeSniffer ruleset for WordPress’s standards available here, if you want to go in that direction). Reasonably well written WordPress code and plugins are not necessarily going to adhere to PSR12, which means that if you follow their style your code will probably not adhere to PSR12.

It’s up to you whether you’d prefer to follow PSR12 strictly, or make use of common WordPress patterns. In the vast majority of cases you will be fine using PSR12, your code will just look different to other code in the WordPress ecosystem.

However, there is an advantage of using the WordPress coding standards, which is that those are aware of WordPress’s functions, so they will recognise things like whether you are properly escaping and sanitising using WordPress’s own functions, for example.