Skip to content

Commit

Permalink
Update Lodash, remove usage of deprecated per-function Lodash package…
Browse files Browse the repository at this point in the history
…s, 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
  • Loading branch information
laveez authored Dec 19, 2024
1 parent b702ebf commit 437708d
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ coverage/
.DS_Store
.vscode
package-lock.json
*.lock
*.lock
/.idea
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [4.0.1]

- **security:** Bump Lodash due to [CVE-2020-8203](https://github.com/advisories/GHSA-p6mc-m468-83gw)
- 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

## [4.0.0] - 2021-04-13 - MAJOR BUMP

- 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.
Expand Down
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
> Fully extendable eslint plugin for JSON i18n translation files.
<p align="center">
<img src="assets/logo-transparent.png" width="400"/>
<img src="assets/logo-transparent.png" width="400" alt="logo"/>
</p>

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

**In this project directory, do the following:**
1) >npm install --save-dev eslint-plugin-i18n-json
2) Create a `.eslintrc.js` file in the root dir of your project. For this example: `/simple/.eslintrc.js`.
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`.
3) paste in the following:
```javascript
module.exports = {
Expand Down Expand Up @@ -138,7 +139,7 @@ simple

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

## Configuring your .eslintrc file
## Configuring your .eslintrc file (ESLint version `< 9.0.0`)
- Simply update your `.eslintrc.*` with overrides for the individual rules.
- Eslint severities: 2 = error, 1 = warning, 0 = off
- Example of the module's default rule configuration:
Expand Down Expand Up @@ -177,6 +178,29 @@ simple
},
};
```
## ESLint version `>= 9.0.0`
- ESLint version `>= 9.0.0` uses flat configuration
```javascript
// eslint.config.(m)js
import i18nJsonPlugin from 'eslint-plugin-i18n-json';
export default {
files: ['**/*.json'],
plugins: { 'i18n-json': i18nJsonPlugin },
processor: {
meta: { name: '.json' },
...i18nJsonPlugin.processors['.json'],
},
rules: {
...i18nJsonPlugin.configs.recommended.rules,
'i18n-json/valid-message-syntax': 'off',
},
};
```
## Rules
Expand Down
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-i18n-json",
"version": "4.0.0",
"version": "4.0.1",
"description": "Fully extendable eslint plugin for JSON i18n translation files.",
"main": "index.js",
"scripts": {
Expand All @@ -27,7 +27,8 @@
],
"author": "GoDaddy Operating Company, LLC",
"contributors": [
"Mayank Jethva <[email protected]>"
"Mayank Jethva <[email protected]>",
"Niko Muukkonen <[email protected]>"
],
"jest": {
"roots": [
Expand Down Expand Up @@ -60,10 +61,7 @@
"chalk": "^2.3.2",
"indent-string": "^3.2.0",
"jest-diff": "^22.0.3",
"lodash.get": "^4.4.2",
"lodash.isequal": "^4.5.0",
"lodash.isplainobject": "^4.0.6",
"lodash.set": "^4.3.2",
"lodash": "^4.17.21",
"log-symbols": "^2.2.0",
"parse-json": "^5.2.0",
"plur": "^2.1.2",
Expand Down
3 changes: 1 addition & 2 deletions src/identical-placeholders.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { parse, TYPE } = require('@formatjs/icu-messageformat-parser');
const set = require('lodash.set');
const get = require('lodash.get');
const { set, get } = require('lodash');
const diff = require('jest-diff');
const requireNoCache = require('./util/require-no-cache');
const getTranslationFileSource = require('./util/get-translation-file-source');
Expand Down
6 changes: 2 additions & 4 deletions src/sorted-keys.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const set = require('lodash.set');
const equal = require('lodash.isequal');
const isPlainObject = require('lodash.isplainobject');
const { set, isEqual, isPlainObject } = require('lodash');
const deepForOwn = require('./util/deep-for-own');
const keyTraversals = require('./util/key-traversals');
const getTranslationFileSource = require('./util/get-translation-file-source');
Expand Down Expand Up @@ -48,7 +46,7 @@ const sortedKeys = ([{ order = 'asc', sortFunctionPath, indentSpaces = 2 } = {}]
originalTranslationPaths.push(path);
});

if (!equal(originalTranslationPaths, sortedTranslationPaths)) {
if (!isEqual(originalTranslationPaths, sortedTranslationPaths)) {
const sortedWithIndent = JSON.stringify(
sortedTranslations,
null,
Expand Down
2 changes: 1 addition & 1 deletion src/util/compare-translations-structure.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const set = require('lodash.set');
const { set } = require('lodash');
const diff = require('jest-diff');
const deepForOwn = require('./deep-for-own');

Expand Down
2 changes: 1 addition & 1 deletion src/util/deep-for-own.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const isPlainObject = require('lodash.isplainobject');
const { isPlainObject } = require('lodash');

/*
deep level order traversal.
Expand Down
2 changes: 1 addition & 1 deletion src/valid-json.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const parseJson = require('parse-json');
const isPlainObject = require('lodash.isplainobject');
const { isPlainObject } = require('lodash');
const chalk = require('chalk');
const requireNoCache = require('./util/require-no-cache');
const getTranslationFileSource = require('./util/get-translation-file-source');
Expand Down
3 changes: 1 addition & 2 deletions src/valid-message-syntax.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const set = require('lodash.set');
const { set, isPlainObject } = require('lodash');
const diff = require('jest-diff');
const isPlainObject = require('lodash.isplainobject');
const prettyFormat = require('pretty-format');
const icuValidator = require('./message-validators/icu');
const notEmpty = require('./message-validators/not-empty');
Expand Down

0 comments on commit 437708d

Please sign in to comment.