Skip to content

Commit 2c196b0

Browse files
committed
[Refactor] no-anonymous-default-export: use object.fromentries
1 parent 66e755f commit 2c196b0

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
1818
- [Docs] [`group-exports`]: fix syntax highlighting ([#2699], thanks [@devinrhode2])
1919
- [Docs] [`extensions`]: reference node ESM behavior ([#2748], thanks [@xM8WVqaG])
2020
- [Refactor] [`exports-last`]: use `array.prototype.findlastindex` (thanks [@ljharb])
21+
- [Refactor] [`no-anonymous-default-export`]: use `object.fromentries` (thanks [@ljharb])
2122

2223
## [2.27.5] - 2023-01-16
2324

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
"is-core-module": "^2.12.1",
114114
"is-glob": "^4.0.3",
115115
"minimatch": "^3.1.2",
116+
"object.fromentries": "^2.0.6",
116117
"object.values": "^1.1.6",
117118
"resolve": "^1.22.3",
118119
"semver": "^6.3.0",

src/rules/no-anonymous-default-export.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
* @author Duncan Beevers
44
*/
55

6-
import docsUrl from '../docsUrl';
76
import has from 'has';
7+
import values from 'object.values';
8+
import fromEntries from 'object.fromentries';
9+
10+
import docsUrl from '../docsUrl';
811

912
const defs = {
1013
ArrayExpression: {
@@ -68,12 +71,7 @@ const schemaProperties = Object.keys(defs)
6871
return acc;
6972
}, {});
7073

71-
const defaults = Object.keys(defs)
72-
.map((key) => defs[key])
73-
.reduce((acc, def) => {
74-
acc[def.option] = has(def, 'default') ? def.default : false;
75-
return acc;
76-
}, {});
74+
const defaults = fromEntries(values(defs).map((def) => [def.option, has(def, 'default') ? def.default : false]));
7775

7876
module.exports = {
7977
meta: {

0 commit comments

Comments
 (0)