Skip to content

Commit

Permalink
feat: remove dependencies for Node built-ins
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed Oct 28, 2024
1 parent 224380f commit 1bab435
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 21 deletions.
3 changes: 1 addition & 2 deletions __tests__/src/eventHandlers-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-env mocha */
import assert from 'assert';
import includes from 'array-includes';
import eventHandlers, { eventHandlersByType } from '../../src/eventHandlers';

describe('eventHandlers', () => {
Expand Down Expand Up @@ -75,7 +74,7 @@ describe('eventHandlers', () => {
'onAnimationEnd',
'onAnimationIteration',
'onTransitionEnd',
].every((handlerName) => includes(eventHandlers, handlerName)));
].every((handlerName) => eventHandlers.includes(handlerName)));
});
});

Expand Down
4 changes: 1 addition & 3 deletions __tests__/src/getProp-parser-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* eslint-env mocha */
import assert from 'assert';
import entries from 'object.entries';
import fromEntries from 'object.fromentries';
import { getOpeningElement, setParserName, fallbackToBabylon } from '../helper';
import getProp from '../../src/getProp';

Expand Down Expand Up @@ -172,5 +170,5 @@ function adjustLocationsRecursively(node, { startOffset, endOffset }) {
}

function mapValues(o, f) {
return fromEntries(entries(o).map(([k, v]) => [k, f(v)]));
return Object.fromEntries(Object.entries(o).map(([k, v]) => [k, f(v)]));
}
8 changes: 0 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
"jest": "^20.0.4",
"jest-cli": "^20.0.4",
"npmignore": "^0.3.0",
"object.entries": "^1.1.6",
"object.fromentries": "^2.0.6",
"rimraf": "^2.7.1",
"safe-publish-latest": "^2.0.0"
},
Expand All @@ -61,12 +59,6 @@
"url": "https://github.com/jsx-eslint/jsx-ast-utils"
},
"license": "MIT",
"dependencies": {
"array-includes": "^3.1.6",
"array.prototype.flat": "^1.3.1",
"object.assign": "^4.1.4",
"object.values": "^1.1.6"
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
Expand Down
5 changes: 1 addition & 4 deletions src/eventHandlers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import flat from 'array.prototype.flat';
import values from 'object.values';

/**
* Common event handlers for JSX element event binding.
*/
Expand Down Expand Up @@ -105,6 +102,6 @@ const eventHandlersByType = {
],
};

export default flat(values(eventHandlersByType));
export default Object.values(eventHandlersByType).flat();

export { eventHandlersByType };
6 changes: 2 additions & 4 deletions src/values/expressions/ObjectExpression.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import assign from 'object.assign';

/**
* Extractor function for an ObjectExpression type value node.
* An object expression is using {}.
Expand All @@ -13,10 +11,10 @@ export default function extractValueFromObjectExpression(value) {
// Support types: SpreadProperty and ExperimentalSpreadProperty
if (/^(?:Experimental)?Spread(?:Property|Element)$/.test(property.type)) {
if (property.argument.type === 'ObjectExpression') {
return assign({}, obj, extractValueFromObjectExpression(property.argument));
return { ...obj, ...extractValueFromObjectExpression(property.argument) };
}
} else {
return assign({}, obj, { [getValue(property.key)]: getValue(property.value) });
return { ...obj, [getValue(property.key)]: getValue(property.value) };
}
return obj;
}, {});
Expand Down

0 comments on commit 1bab435

Please sign in to comment.