I have a super secret variable SUPERBASE_PRIVATE_SERVICE_ROLE
which I don't want my devs to use anywhere except for specific location.
I am trying to use this rule:
"no-restricted-properties": [
"error",
{
"object": "process",
"property": "env.SUPERBASE_PRIVATE_SERVICE_ROLE",
"message": "Usage of process.env.SUPERBASE_PRIVATE_SERVICE_ROLE is not allowed."
}
]
But this fails, can someone tell me what is going wrong or what is the way to restrict the same?
Use no-restricted-syntax
instead:
"rules": {
"no-restricted-syntax": [
"error",
"MemberExpression[type=MemberExpression][object.type=MemberExpression][object.object.type=Identifier][object.object.name=process][object.property.type=Identifier][object.property.name=env][property.type=Identifier][property.name=SUPERBASE_PRIVATE_SERVICE_ROLE]"
],
}
You can evaluate the AST to reproduce rules like this using AST Explorer. There are also similar examples at https://github.com/eslint/eslint/issues/8505.