We are implementing an access control module in our project. When a user login to the system, his permission will be loaded according to his role. And the software will decide what he can do only based on the permission list instead of who he is or what his role is.
In order to ensure the codes strictly respect the design, I want to add some eslint rule to avoid specific values to appear in specific source files.
For example, the following code should not be allowed
// should throw error because superadmin is in blackist
if(user.isSuperAdmin) {
// do something
}
or
// should throw error because superadmin is in blackist
if(user.role === 'superadmin') {
// do something
}
But it is OK if those text appear in comment.
I find eslint has a powerful mechanism named no-restricted-syntax which may be able to make it works, but I didn't figure out how by myself. Your support will be greatly appreciate!