Socket
Socket
Sign inDemoInstall

eslint-plugin-i18next

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-i18next - npm Package Compare versions

Comparing version 4.4.0 to 4.5.0

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

## [4.5.0](https://github.com/edvardchen/eslint-plugin-i18next/compare/v4.4.0...v4.5.0) (2020-08-11)
### Features
* add option validateTemplate ([ba0ec60](https://github.com/edvardchen/eslint-plugin-i18next/commit/ba0ec60))
## [4.4.0](https://github.com/edvardchen/eslint-plugin-i18next/compare/v4.3.0...v4.4.0) (2020-08-03)

@@ -7,0 +14,0 @@

25

lib/rules/no-literal-string.js

@@ -62,2 +62,5 @@ /**

}
},
validateTemplate: {
type: 'boolean'
}

@@ -401,2 +404,17 @@ },

TemplateLiteral(node) {
if (!option || !option.validateTemplate) {
return;
}
const { quasis = [] } = node;
quasis.some(({ value: { raw } }) => {
const trimed = raw.trim();
if (!trimed) return;
if (match(trimed)) return;
context.report({ node, message });
return true; // break
});
// const trimed = node.value.trim();
},
'Literal:exit'(node) {

@@ -414,4 +432,7 @@ if (markupOnly) {

scriptVisitor[key] = node => {
// make sure node is string literal
if (!isString(node)) return;
// all visitors ends with Literal except TemplateLiteral
if (key !== 'TemplateLiteral') {
// make sure node is string literal
if (!isString(node)) return;
}

@@ -418,0 +439,0 @@ old(node);

2

package.json
{
"name": "eslint-plugin-i18next",
"version": "4.4.0",
"version": "4.5.0",
"description": "ESLint plugin for i18n",

@@ -5,0 +5,0 @@ "keywords": [

@@ -346,1 +346,11 @@ # eslint-plugin-i18next

```
#### validateTemplate
Indicate whether to validate [template strings](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) or not. Default `false`
```js
/*eslint i18next/no-literal-string: ["error", { "validateTemplate": true }]*/
// incorrect
var foo = `hello world`;
```

@@ -124,6 +124,27 @@ /**

{ code: 'const a = "foo";', options: [{ onlyAttribute: ['bar'] }] },
{ code: '<DIV foo="bar" />', options: [{ onlyAttribute: ['bar'] }] }
{ code: '<DIV foo="bar" />', options: [{ onlyAttribute: ['bar'] }] },
{
code: 'var a = `hello world`'
},
{
code: 'var a = `12345`',
options: [{ validateTemplate: true }]
},
{
code: 'var a = ``',
options: [{ validateTemplate: true }]
}
],
invalid: [
{
code: 'var a = `hello ${abc} world`',
options: [{ validateTemplate: true }],
errors
},
{
code: 'var a = `hello world`',
options: [{ validateTemplate: true }],
errors
},
{ code: 'i18nextXt("taa");', errors },

@@ -130,0 +151,0 @@ { code: 'a + "b"', errors },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc