Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove dependencies for Node built-ins #142

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions .github/workflows/node-aught.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: 'Tests: node.js >= 10'
name: 'Tests: node.js 18+'

on: [pull_request, push]

jobs:
tests:
uses: ljharb/actions/.github/workflows/node.yml@main
with:
range: '>= 10'
range: '^18.18.0 || ^20.9.0 || >=21.1.0'
type: minors
command: npm run tests-only

node:
name: 'node >= 10'
name: 'node 18+'
needs: [tests]
runs-on: ubuntu-latest
steps:
Expand Down
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)]));
}
10 changes: 1 addition & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@
"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"
},
"engines": {
"node": ">=4.0"
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"keywords": [
"jsx",
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
Loading