Read James 2:9 Using Other Translations
But if ye have respect to persons, ye commit sin, and are convinced of the law as transgressors.
But if you show partiality, you are committing sin and are convicted by the law as transgressors.
But if you favor some people over others, you are committing a sin. You are guilty of breaking the law.