Skip to content

unfunctional jsx-components include #144

@ArthurLCW

Description

@ArthurLCW

Hi there,
Thanks for your wonderful package!

I met some problems when using the 'include' of 'jsx-components'. From my perspective, the keyword 'include' implies what kind of strings should be validated. However, the 'include' in jsx-components doesn't work like this.

This is my code in .eslintrc.js:
`const i18nextLinterConfig = {
mode: 'all',
'should-validate-template': true,
'jsx-components': {
include: ['TestJSX'],
exclude: [],
},
'jsx-attributes': {
include: ['styleName'],
exclude: [
'className',
'type',
'key',
'id',
'width',
'height',
'dfsdd'
],
},
}

module.exports = {
extends: [..., "plugin:i18next/recommended"],
rules: {
...,
'i18next/no-literal-string': ['error', i18nextLinterConfig],
},
globals: {
JSX: true,
ClientRect: true,
Spread: true,
},
}
`
The 'TestJSX' does NOT display any warning when translation is missing. Both warning for the JSX attributes and the string as JSX children stop displaying warning. The other jsx also stop displaying warning.

Image

Based on my testing, the include for jsx-attributes works just fine. Is this a bug?

Also, could you please add some examples in readme to illustrate how the linter works when both include and exclude are configured?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions