Kant called this the categorical imperative: https://en.wikipedia.org/wiki/Categorical_imperative - a philosophical statement about morality:
"Act only according to that maxim whereby you can, at the same time, will that it should become a universal law."