Describe the bug
When using @wordpress/eslint-plugin if no text domain is configured in eslintrc, 'default' should be the chosen text domain and there should be no text-domain linting errors with a supplied domain string or empty param.
To reproduce
Steps to reproduce the behavior:
__( ) function in a javascript file with a text domain (e.f. __( 'some string', 'some domain' )@wordpress/i18n-text-domain: Invalid text domain 'some domain'Expected behavior
Giving no preferred text domain in the eslintrc should allow any string text domain. OR Text domain rule should be outlined as required in the eslint plugin documentation.
Additional context
Good timing, I was thinking about a fix for it. I had to workaround it in WordPress/gutenberg-examples this way:
https://github.com/WordPress/gutenberg-examples/blob/c4d83b1dbd9c46de9028db10c3206446ed084b18/01-basic-esnext/package.json#L24
However, we need to find a more robust solution that works for all projects out of the box.
I think the easiest solution would be to remove the default text domain:
So when the text domain is not explicitly specified (allowedTextDomain === undefined), the rule would do nothing
Thoughts?
cc @aduth
@swissspidy, I tried what you shared in #21928. It works but I guess it can be simplified :)
I'd be motivated toward anything which ensures the default configuration can be used out-of-the-box without additional action required.
I guess https://github.com/WordPress/gutenberg/issues/21920#issuecomment-620011646 can be a solution toward that, but it's unclear to me: Is there any difference between removing this default value, and simply removing the rule from the configuration altogether? If the rule isn't doing anything in its default state, then I don't think it should run at all.
@aduth The rule also checks whether the text domain is a valid string literal and not a variable, for example. That's still valuable.
@aduth The rule also checks whether the text domain is a valid string literal and not a variable, for example. That's still valuable.
Okay, in that case, it seems sensible then.
Most helpful comment
I think the easiest solution would be to remove the default text domain:
https://github.com/WordPress/gutenberg/blob/3b8965e197ba5bbcc24d9b8dfa1f759601416a52/packages/eslint-plugin/rules/i18n-text-domain.js#L51
https://github.com/WordPress/gutenberg/blob/3b8965e197ba5bbcc24d9b8dfa1f759601416a52/packages/eslint-plugin/rules/i18n-text-domain.js#L71
So when the text domain is not explicitly specified (
allowedTextDomain === undefined), the rule would do nothingThoughts?
cc @aduth