Closed sarayourfriend closed 4 years ago
Currently allowedTerms matches only full words by using includes on the list of words.
allowedTerms
includes
https://github.com/muenzpraeger/eslint-plugin-inclusive-language/blob/primary/lib/rules/use-inclusive-words.js#L37
The intended usage of this feature is to exclude certain terms that are not able to be avoided for one reason or another (like the names of credit card processors). The current behavior doesn't accomplish this. For example, in this repository:
https://github.com/Automattic/wp-calypso/blob/336f26751af6acacd9cede88145d47895f80ebb9/client/components/payment-logo/index.jsx#L23
Even if we add mastercard to the list of allowedTerms, that particular line will continue to cause a rule failure as mastercard isn't the full term. We've run into this issue here: https://github.com/Automattic/wp-calypso/pull/43866#pullrequestreview-441870336
mastercard
If we could change the API of allowedTerms to be objects rather than raw strings, we could do something like the following:
{ "allowedTerms": [ { "term": "mastercard", "allowPartialMatches": true }, ] }
I'm not sure what the best option for the default value of allowPartialMatches (or what a better name could be, there might be something clearer).
allowPartialMatches
It should be realtively easy to preserve backwards compatability with the current API as well.
Currently
allowedTerms
matches only full words by usingincludes
on the list of words.https://github.com/muenzpraeger/eslint-plugin-inclusive-language/blob/primary/lib/rules/use-inclusive-words.js#L37
The intended usage of this feature is to exclude certain terms that are not able to be avoided for one reason or another (like the names of credit card processors). The current behavior doesn't accomplish this. For example, in this repository:
https://github.com/Automattic/wp-calypso/blob/336f26751af6acacd9cede88145d47895f80ebb9/client/components/payment-logo/index.jsx#L23
Even if we add
mastercard
to the list ofallowedTerms
, that particular line will continue to cause a rule failure asmastercard
isn't the full term. We've run into this issue here: https://github.com/Automattic/wp-calypso/pull/43866#pullrequestreview-441870336If we could change the API of
allowedTerms
to be objects rather than raw strings, we could do something like the following:I'm not sure what the best option for the default value of
allowPartialMatches
(or what a better name could be, there might be something clearer).It should be realtively easy to preserve backwards compatability with the current API as well.