Socket
Socket
Sign inDemoInstall

eslint-plugin-you-dont-need-lodash-underscore

Package Overview
Dependencies
Maintainers
3
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-you-dont-need-lodash-underscore - npm Package Compare versions

Comparing version 6.7.2 to 6.8.0

8

lib/rules/rules.json

@@ -65,7 +65,7 @@ {

"compatible": false,
"alternative": "Array.prototype.forEach()"
"alternative": "Array.prototype.forEach() or Object.entries().forEach()"
},
"forEach": {
"compatible": false,
"alternative": "Array.prototype.forEach()"
"alternative": "Array.prototype.forEach() or Object.entries().forEach()"
},

@@ -266,3 +266,7 @@ "every": {

"ES6": true
},
"flatten": {
"compatible": true,
"alternative": "Array.prototype.reduce((a,b) => a.concat(b), [])"
}
}
{
"name": "eslint-plugin-you-dont-need-lodash-underscore",
"version": "6.7.2",
"version": "6.8.0",
"description": "Check methods you can use natively without lodash/underscore",

@@ -5,0 +5,0 @@ "repository": {

@@ -61,7 +61,8 @@ 'use strict';

valid: [
'[0, 1].forEach()'
'[0, 1].forEach()',
"Object.entries({'one':1,'two':2}).forEach()"
],
invalid: [{
code: 'underscore.forEach()',
errors: ['Consider using the native Array.prototype.forEach()']
errors: ['Consider using the native Array.prototype.forEach() or Object.entries().forEach()']
}]

@@ -144,1 +145,18 @@ });

/*Test for new flatten rule*/
ruleTester.run('_.flatten', rules['flatten'], {
valid: [
`[1,2,[3,4]].reduce((a,b) => a.concat(b), [])`,
`[1,2,[3,4]].flat()`,
`[1,2,[3,4]].flatMap(a => a)`
],
invalid: [{
code: `_.flatten([1,2,[3,4]])`,
errors: [`Consider using the native Array.prototype.reduce((a,b) => a.concat(b), [])`]
},{
code: `_([1,2,[3,4]]).flatten()`,
errors: [`Consider using the native Array.prototype.reduce((a,b) => a.concat(b), [])`]
}]
});

@@ -635,2 +635,60 @@ 'use strict';

describe('flatten', () => {
it('_.flatten(twoLayerArray)', () => {
const testArray = [1,2[3,4]];
assert.deepEqual(_.flatten(testArray),
testArray.reduce((a,b) => a.concat(b), []))
});
it('_.flatten(multiLayerArray)', () => {
const testArray = [1,2[3,4,[5,6,[7,8]]]];
assert.deepEqual(_.flatten(testArray),
testArray.reduce((a,b) => a.concat(b), []))
});
});
describe('forEach', () => {
it('_.forEach(array)', () => {
const testArray = [1,2,3,4];
let lodashOutput = []
let nativeOutput = []
_.forEach(testArray, element => {
lodashOutput.push(element);
});
testArray.forEach(element => {
nativeOutput.push(element);
});
assert.deepEqual(lodashOutput,nativeOutput);
});
it('_.forEach(object)', () => {
const testObject = {
'one':1,
'two':2,
'three':3,
'four':4,
}
let lodashOutput = []
let nativeOutput = []
_.forEach(testObject, value => {
lodashOutput.push(value);
});
Object.entries(testObject).forEach(([key,value]) => {
nativeOutput.push(value);
});
assert.deepEqual(lodashOutput,nativeOutput);
});
});
})

Sorry, the diff of this file is too big to display

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