New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-no-array-reduce

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-no-array-reduce - npm Package Compare versions

Comparing version 1.0.45 to 1.0.46

16

package.json
{
"name": "eslint-plugin-no-array-reduce",
"version": "1.0.45",
"version": "1.0.46",
"description": "ESLint rule to disallow Array.reduce() method.",

@@ -26,12 +26,12 @@ "main": "./dist/index.js",

"@types/estree": "0.0.51",
"@types/node": "^17.0.19",
"@typescript-eslint/eslint-plugin": "^5.12.0",
"@typescript-eslint/parser": "^5.12.0",
"@types/node": "^17.0.21",
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/parser": "^5.13.0",
"commitizen": "^4.2.4",
"eslint": "^8.9.0",
"eslint-config-prettier": "^8.4.0",
"eslint": "^8.10.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.4",
"lint-staged": "^12.3.4",
"lint-staged": "^12.3.5",
"prettier": "^2.5.1",

@@ -41,3 +41,3 @@ "pretty-quick": "^3.1.3",

"tsup": "^5.11.13",
"typescript": "^4.5.5"
"typescript": "^4.6.2"
},

@@ -44,0 +44,0 @@ "peerDependencies": {

@@ -42,10 +42,21 @@ # eslint-plugin-no-array-reduce

```js
const groceries = [
const products = [
{ name: 'milk', type: 'dairy' },
{ name: 'cheese', type: 'dairy' },
{ name: 'beef', type: 'meat' },
{ name: 'chicken', type: 'meat' },
];
// Add price to each product
const productsWithPrices = products.reduce((acc, product) => acc.concat({ ...product, price: 2.7 }), []);
// Filter dairy products
const dairy = groceries.reduce((acc, grocery) => (grocery.type === 'dairy' ? acc.concat(grocery) : acc), []);
const dairies = products.reduce((acc, product) => (product.type === 'dairy' ? acc.concat(product) : acc), []);
// Group products by type
const productsByType = products.reduce(
(acc, product) => ({
...acc,
[product.type]: [...(acc[product.type] || []), product],
}),
[],
);
```

@@ -56,6 +67,12 @@

```js
// Add price to each product
const productsWithPrices = products.map((product) => ({ ...product, price: 2.7 }));
// Filter dairy products
const dairy = groceries.filter((grocery) => grocery.type === 'dairy');
const dairies = products.filter((product) => product.type === 'dairy');
// Group products by type (ECMA stage 3 - https://github.com/tc39/proposal-array-grouping)
const productsByType = products.groupBy((product) => product.type);
```
<sub>[CodeSandbox](https://codesandbox.io/s/eslint-plugin-no-array-reduce-4cyc1i?file=/index.js)</sub>
## Contributing

@@ -62,0 +79,0 @@

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