eslint-plugin-i18next
Advanced tools
Comparing version 4.1.0 to 4.2.0
@@ -5,2 +5,14 @@ # Changelog | ||
## [4.2.0](https://github.com/edvardchen/eslint-plugin-i18next/compare/v4.1.0...v4.2.0) (2020-07-01) | ||
### Bug Fixes | ||
* remove console ([f361e63](https://github.com/edvardchen/eslint-plugin-i18next/commit/f361e63)) | ||
### Features | ||
* allow ignoring lists of components ([eebb338](https://github.com/edvardchen/eslint-plugin-i18next/commit/eebb338)) | ||
## [4.1.0](https://github.com/edvardchen/eslint-plugin-i18next/compare/v4.0.0...v4.1.0) (2020-06-30) | ||
@@ -7,0 +19,0 @@ |
@@ -45,2 +45,8 @@ /** | ||
}, | ||
ignoreComponent: { | ||
type: 'array', | ||
items: { | ||
type: 'string' | ||
} | ||
}, | ||
markupOnly: { | ||
@@ -139,2 +145,6 @@ type: 'boolean' | ||
// Ignore the Trans component for react-i18next compatibility | ||
let ignoredComponents = ['Trans']; | ||
if (option && option.ignoreComponent) | ||
ignoredComponents = ignoredComponents.concat(option.ignoreComponent); | ||
function hasValidElementName(node) { | ||
@@ -148,3 +158,7 @@ let currentNode = node; | ||
) { | ||
if (currentNode.parent.openingElement.name.name === 'Trans') { | ||
if ( | ||
ignoredComponents.includes( | ||
currentNode.parent.openingElement.name.name | ||
) | ||
) { | ||
return true; | ||
@@ -151,0 +165,0 @@ } |
{ | ||
"name": "eslint-plugin-i18next", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "ESLint plugin for i18n", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -318,1 +318,12 @@ # eslint-plugin-i18next | ||
``` | ||
#### ignoreComponent | ||
The `ignoreComponent` option specifies exceptions not to check for string literals inside a list of named components. It includes `<Trans>` per default. | ||
Examples of correct code for the `{ "ignoreComponent": ["Icon"] }` option: | ||
```jsx | ||
/*eslint i18next/no-literal-string: ["error", { "ignoreComponent": ["Icon"] }]*/ | ||
<Icon>arrow<Icon/> | ||
``` |
@@ -106,2 +106,4 @@ /** | ||
{ code: '<Trans><span>bar</span></Trans>' }, | ||
{ code: '<Trans>foo</Trans>', options: [{ ignoreComponent: ['Icon'] }] }, | ||
{ code: '<Icon>arrow</Icon>', options: [{ ignoreComponent: ['Icon'] }] }, | ||
{ code: 'a + "b"', options: [{ markupOnly: true }] }, | ||
@@ -108,0 +110,0 @@ { code: '<div>{import("abc")}</div>', options: [{ markupOnly: true }] }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45988
873
329