Closed dantman closed 2 years ago
This appears to be possible by creating two separate rules with the same target
, the first one with the disallow: '*'
and the second with the allow: 'index.*'
.
Your solution is right @dantman,
As you mentioned, defining both allow
and disallow
in the same rule is not possible. From the docs: "If one rule contains both allow and disallow properties, the disallow one has priority. It will not try to match the allow one if disallow matches. The result for that rule will be disallow in that case."
So, if you have "allow" as default value, and you want to allow only certain pattern only for one element type, you'll first have to disallow everything for that element type, and then allow only the specific pattern in separated rules.
Just in case it is useful also for other users, here is an example:
{
rules: {
"boundaries/entry-point": [2, {
// allow all entry-points by default
default: "allow",
rules: [
{
// Override the default value for the element type
target: ["modules"],
// Disallow everything
disallow: "*"
},
{
// Add another rule for the same type, allowing only some entry point
target: ["modules"],
// only allow index.js
allow: "index.js"
}
]
}
]
}
}
Is your issue related to a problem? Please describe. I want to disallow using anything but
index.js
as an entry point to one type of element (feature in my case, but others may do this for modules). But I do not want to do this for all element types, so the overall default is 'allow'.Describe the issue When the entry-point default is
allow
there is no way to declare "disallow everything except index.js".disallow: '*', allow: 'index.js'
- will not work, because disallow overrides allow meaning thatindex.js
is disallowed.allow: 'index.js'
- will not work because everything else is still allowed.