Skip to content

Commit

Permalink
[Refactor] no-anonymous-default-export: use object.fromentries
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 4, 2023
1 parent 66e755f commit 2c196b0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -18,6 +18,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
- [Docs] [`group-exports`]: fix syntax highlighting ([#2699], thanks [@devinrhode2])
- [Docs] [`extensions`]: reference node ESM behavior ([#2748], thanks [@xM8WVqaG])
- [Refactor] [`exports-last`]: use `array.prototype.findlastindex` (thanks [@ljharb])
- [Refactor] [`no-anonymous-default-export`]: use `object.fromentries` (thanks [@ljharb])

## [2.27.5] - 2023-01-16

Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -113,6 +113,7 @@
"is-core-module": "^2.12.1",
"is-glob": "^4.0.3",
"minimatch": "^3.1.2",
"object.fromentries": "^2.0.6",
"object.values": "^1.1.6",
"resolve": "^1.22.3",
"semver": "^6.3.0",
Expand Down
12 changes: 5 additions & 7 deletions src/rules/no-anonymous-default-export.js
Expand Up @@ -3,8 +3,11 @@
* @author Duncan Beevers
*/

import docsUrl from '../docsUrl';
import has from 'has';
import values from 'object.values';
import fromEntries from 'object.fromentries';

import docsUrl from '../docsUrl';

const defs = {
ArrayExpression: {
Expand Down Expand Up @@ -68,12 +71,7 @@ const schemaProperties = Object.keys(defs)
return acc;
}, {});

const defaults = Object.keys(defs)
.map((key) => defs[key])
.reduce((acc, def) => {
acc[def.option] = has(def, 'default') ? def.default : false;
return acc;
}, {});
const defaults = fromEntries(values(defs).map((def) => [def.option, has(def, 'default') ? def.default : false]));

module.exports = {
meta: {
Expand Down

0 comments on commit 2c196b0

Please sign in to comment.