Reputation: 13
As part of the centralized component library I need to build, I want to instate a rule so that engineers are unable to morph the styles of the component using ::ng-deep
. Does angular/scss/stylelint provide any safeguards to prevent this behavior?
I would prefer an scss/angular approach as opposed to a linting approach.
Most qns so far only refer to using ::ng-deep
or avoiding ::ng-deep
to manipulate styles of a component. Mine is the inverse.
I tried using ViewEncapsulation.ShadowDom
in angular's playground to see if adding this to a component would help. But so far it doesn't seem helpful (refer to screenshot) - screenshot of trying ViewEncapsulation.ShadowDom
Upvotes: 1
Views: 62
Reputation: 56600
I am not aware of any in-built rules in eslint or tslint, but you can use a regex
to match this word and throw an invalid error. You can experiment with the below package, which will warn the user, and prevent occurrences of its usage.
{
"plugins": [
"regex"
],
"rules": {
"regex/invalid": [
"error", [
"::ng-deep", // <- something like this.
]
],
}
}
Upvotes: 0