Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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 3.5.0 to 3.6.0

7

CHANGELOG.md

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

## [3.6.0](https://github.com/edvardchen/eslint-plugin-i18next/compare/v3.5.0...v3.6.0) (2020-04-17)
### Features
* support to access enum value through string like Enum['key'] ([db68147](https://github.com/edvardchen/eslint-plugin-i18next/commit/db68147))
## [3.5.0](https://github.com/edvardchen/eslint-plugin-i18next/compare/v3.4.0...v3.5.0) (2020-04-16)

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

7

lib/rules/no-literal-string.js

@@ -55,3 +55,3 @@ /**

create: function(context) {
create(context) {
// variables should be defined here

@@ -260,2 +260,7 @@ const {

'MemberExpression > Literal'(node) {
// allow Enum['value']
visited.add(node);
},
'Literal:exit'(node) {

@@ -262,0 +267,0 @@ // visited and passed linting

2

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

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

@@ -7,5 +7,5 @@ # eslint-plugin-i18next

```bash
npm install eslint-plugin-i18next --save-dev
```
$ npm install eslint-plugin-i18next --save-dev
```

@@ -49,3 +49,3 @@ ## Usage

It will find out all literal strings and validate them.
**It will find out all literal strings and validate them.**

@@ -129,4 +129,11 @@ Examples of **incorrect** code for this rule:

#### Redux/Vuex
It would allow most reasonable usages of string that would rarely be shown to user, like following examples.
Click on them to see details.
<details>
<summary>
Redux/Vuex
</summary>
This rule also works with those state managers like

@@ -138,3 +145,2 @@ [Redux](https://redux.js.org/) and [Vuex](https://vuex.vuejs.org/).

```js
/*eslint i18next/no-literal-string: "error"*/
var bar = store.dispatch('bar');

@@ -144,12 +150,20 @@ var bar2 = store.commit('bar');

#### Typescript
</details>
The following cases are **correct**:
<details>
<summary>
Typescript
</summary>
This plugin would not complain on those reasonable usages of string.
The following cases are considered as **correct**:
```typescript
// skip TSLiteralType
var a: Type['member'];
var a: Omit<T, 'key'>;
// skip literal with LiteralType
enum E {
A = 1
}
var a = E['A'];
var a: { t: 'button' } = { t: 'button' };

@@ -172,6 +186,12 @@ var a: 'abc' | 'name' = 'abc';

#### Import/Export
</details>
The following cases are **correct**:
<details>
<summary>
Import/Export
</summary>
The following cases are **allowed**:
```typescript

@@ -186,4 +206,9 @@ import mod from 'm';

#### Comparison
</details>
<details>
<summary>
String Comparison
</summary>
String comparison is fine.

@@ -196,4 +221,9 @@

#### SwithCase
</details>
<details>
<summary>
SwithCase
</summary>
Skip switchcase statement:

@@ -211,2 +241,4 @@

</details>
### Options

@@ -213,0 +245,0 @@

@@ -173,2 +173,3 @@ /**

{ code: "type T = {name: 'b'} ; var a: T = {name: 'b'}" },
{ code: "enum T {howard=1} ; var a = T['howard']" },
{ code: "function Button({ t= 'name' }: {t: 'name'}){} " },

@@ -175,0 +176,0 @@ { code: "type T ={t?:'name'|'abc'};function Button({t='name'}:T){}" }

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