Skip to content

Commit 437708d

Browse files
authored
Update Lodash, remove usage of deprecated per-function Lodash packages, update readme (#66)
* Update lodash, do some linting, add note about flat config to readme * Add /.idea to gitignore * Fix README.md links * Revert some unwanted code styling changes * Update Changelog
1 parent b702ebf commit 437708d

File tree

10 files changed

+46
-22
lines changed

10 files changed

+46
-22
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ coverage/
44
.DS_Store
55
.vscode
66
package-lock.json
7-
*.lock
7+
*.lock
8+
/.idea

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [4.0.1]
9+
10+
- **security:** Bump Lodash due to [CVE-2020-8203](https://github.com/advisories/GHSA-p6mc-m468-83gw)
11+
- Update readme with instructions on how to use this package with npm `>= 9.0.0` as described in https://github.com/godaddy/eslint-plugin-i18n-json/issues/62
12+
813
## [4.0.0] - 2021-04-13 - MAJOR BUMP
914

1015
- Switch to `@formatjs/icu-messageformat-parser` as `intl-messageformat-parser` is now deprecated. This is a breaking change, the new parser uses icu4j implementation and has stricter validations.

README.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
> Fully extendable eslint plugin for JSON i18n translation files.
77
88
<p align="center">
9-
<img src="assets/logo-transparent.png" width="400"/>
9+
<img src="assets/logo-transparent.png" width="400" alt="logo"/>
1010
</p>
1111

1212
🎉 [**Check out the introductory blog post!**](https://godaddy.github.io/2018/04/02/introducing-eslint-plugin-i18n-json/)
@@ -16,7 +16,8 @@
1616
- [Features](#features-)
1717
- [Getting started](#getting-started)
1818
- [Examples](#examples)
19-
- [Configuring your .eslintrc file](#configuring-your-eslintrc-file)
19+
- [Configuring your .eslintrc file (ESLint version `< 9.0.0`)](#configuring-your-eslintrc-file-eslint-version--900)
20+
- [EsLint version `>= 9.0.0`](#eslint-version--900)
2021
- [Rules](#rules)
2122
- [i18n-json/valid-json](#i18n-jsonvalid-json)
2223
- [i18n-json/valid-message-syntax](#i18n-jsonvalid-message-syntax)
@@ -106,7 +107,7 @@ simple
106107

107108
**In this project directory, do the following:**
108109
1) >npm install --save-dev eslint-plugin-i18n-json
109-
2) Create a `.eslintrc.js` file in the root dir of your project. For this example: `/simple/.eslintrc.js`.
110+
2) If you are using eslint `< 9.0.0` Create a `.eslintrc.js` file in the root dir of your project. For this example: `/simple/.eslintrc.js`.
110111
3) paste in the following:
111112
```javascript
112113
module.exports = {
@@ -138,7 +139,7 @@ simple
138139

139140
![](assets/invalid-icu-syntax-screenshot.png)
140141

141-
## Configuring your .eslintrc file
142+
## Configuring your .eslintrc file (ESLint version `< 9.0.0`)
142143
- Simply update your `.eslintrc.*` with overrides for the individual rules.
143144
- Eslint severities: 2 = error, 1 = warning, 0 = off
144145
- Example of the module's default rule configuration:
@@ -177,6 +178,29 @@ simple
177178
},
178179
};
179180
```
181+
182+
## ESLint version `>= 9.0.0`
183+
184+
- ESLint version `>= 9.0.0` uses flat configuration
185+
186+
```javascript
187+
// eslint.config.(m)js
188+
import i18nJsonPlugin from 'eslint-plugin-i18n-json';
189+
190+
export default {
191+
files: ['**/*.json'],
192+
plugins: { 'i18n-json': i18nJsonPlugin },
193+
processor: {
194+
meta: { name: '.json' },
195+
...i18nJsonPlugin.processors['.json'],
196+
},
197+
rules: {
198+
...i18nJsonPlugin.configs.recommended.rules,
199+
'i18n-json/valid-message-syntax': 'off',
200+
},
201+
};
202+
203+
```
180204
181205
## Rules
182206

package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-i18n-json",
3-
"version": "4.0.0",
3+
"version": "4.0.1",
44
"description": "Fully extendable eslint plugin for JSON i18n translation files.",
55
"main": "index.js",
66
"scripts": {
@@ -27,7 +27,8 @@
2727
],
2828
"author": "GoDaddy Operating Company, LLC",
2929
"contributors": [
30-
"Mayank Jethva <mjethva@godaddy.com>"
30+
"Mayank Jethva <mjethva@godaddy.com>",
31+
"Niko Muukkonen <niko.muukkonen1@gmail.com>"
3132
],
3233
"jest": {
3334
"roots": [
@@ -60,10 +61,7 @@
6061
"chalk": "^2.3.2",
6162
"indent-string": "^3.2.0",
6263
"jest-diff": "^22.0.3",
63-
"lodash.get": "^4.4.2",
64-
"lodash.isequal": "^4.5.0",
65-
"lodash.isplainobject": "^4.0.6",
66-
"lodash.set": "^4.3.2",
64+
"lodash": "^4.17.21",
6765
"log-symbols": "^2.2.0",
6866
"parse-json": "^5.2.0",
6967
"plur": "^2.1.2",

src/identical-placeholders.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const { parse, TYPE } = require('@formatjs/icu-messageformat-parser');
2-
const set = require('lodash.set');
3-
const get = require('lodash.get');
2+
const { set, get } = require('lodash');
43
const diff = require('jest-diff');
54
const requireNoCache = require('./util/require-no-cache');
65
const getTranslationFileSource = require('./util/get-translation-file-source');

src/sorted-keys.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
const set = require('lodash.set');
2-
const equal = require('lodash.isequal');
3-
const isPlainObject = require('lodash.isplainobject');
1+
const { set, isEqual, isPlainObject } = require('lodash');
42
const deepForOwn = require('./util/deep-for-own');
53
const keyTraversals = require('./util/key-traversals');
64
const getTranslationFileSource = require('./util/get-translation-file-source');
@@ -48,7 +46,7 @@ const sortedKeys = ([{ order = 'asc', sortFunctionPath, indentSpaces = 2 } = {}]
4846
originalTranslationPaths.push(path);
4947
});
5048

51-
if (!equal(originalTranslationPaths, sortedTranslationPaths)) {
49+
if (!isEqual(originalTranslationPaths, sortedTranslationPaths)) {
5250
const sortedWithIndent = JSON.stringify(
5351
sortedTranslations,
5452
null,

src/util/compare-translations-structure.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const set = require('lodash.set');
1+
const { set } = require('lodash');
22
const diff = require('jest-diff');
33
const deepForOwn = require('./deep-for-own');
44

src/util/deep-for-own.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const isPlainObject = require('lodash.isplainobject');
1+
const { isPlainObject } = require('lodash');
22

33
/*
44
deep level order traversal.

src/valid-json.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const parseJson = require('parse-json');
2-
const isPlainObject = require('lodash.isplainobject');
2+
const { isPlainObject } = require('lodash');
33
const chalk = require('chalk');
44
const requireNoCache = require('./util/require-no-cache');
55
const getTranslationFileSource = require('./util/get-translation-file-source');

src/valid-message-syntax.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
const set = require('lodash.set');
1+
const { set, isPlainObject } = require('lodash');
22
const diff = require('jest-diff');
3-
const isPlainObject = require('lodash.isplainobject');
43
const prettyFormat = require('pretty-format');
54
const icuValidator = require('./message-validators/icu');
65
const notEmpty = require('./message-validators/not-empty');

0 commit comments

Comments
 (0)