Skip to content

Commit 20235b6

Browse files
authored
chore(dev-deps): upgrade eslint-plugin-unicorn to v36 (#187)
https://github.com/sindresorhus/eslint-plugin-unicorn/releases/tag/v36.0.0
1 parent 4d84aef commit 20235b6

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

lib/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,22 @@ function loadRule (ruleName) {
4343
}
4444

4545
// import all rules in lib/rules
46-
const allRules = fs
46+
const allRules = Object.fromEntries(fs
4747
.readdirSync(`${__dirname}/rules`)
4848
.filter(fileName => fileName.endsWith('.js') && /^[^._]/.test(fileName))
4949
.map(fileName => fileName.replace(/\.js$/, ''))
50-
.reduce((rules, ruleName) => Object.assign(rules, { [ruleName]: loadRule(ruleName) }), {});
50+
.map(ruleName => [ruleName, loadRule(ruleName)]));
5151

5252
module.exports.rules = allRules;
5353

54+
// eslint-disable-next-line unicorn/prefer-object-from-entries
5455
module.exports.configs = Object.keys(configFilters).reduce((configs, configName) => {
5556
return Object.assign(configs, {
5657
[configName]: {
5758
plugins: ['eslint-plugin'],
58-
rules: Object.keys(allRules)
59+
rules: Object.fromEntries(Object.keys(allRules)
5960
.filter(ruleName => configFilters[configName](allRules[ruleName]))
60-
.reduce((rules, ruleName) => Object.assign(rules, { [`${PLUGIN_NAME}/${ruleName}`]: 'error' }), {}),
61+
.map(ruleName => [`${PLUGIN_NAME}/${ruleName}`, 'error'])),
6162
},
6263
});
6364
}, {});

lib/utils.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ module.exports = {
103103
.map(statement => statement.expression)
104104
.filter(expression => expression.type === 'AssignmentExpression')
105105
.filter(expression => expression.left.type === 'MemberExpression')
106+
// eslint-disable-next-line unicorn/prefer-object-from-entries
106107
.reduce((currentExports, node) => {
107108
if (
108109
node.left.object.type === 'Identifier' && node.left.object.name === 'module' &&
@@ -119,6 +120,7 @@ module.exports = {
119120
// Check `module.exports = { create: function () {}, meta: {} }`
120121

121122
exportsIsFunction = false;
123+
// eslint-disable-next-line unicorn/prefer-object-from-entries
122124
return node.right.properties.reduce((parsedProps, prop) => {
123125
const keyValue = module.exports.getKeyName(prop);
124126
if (INTERESTING_KEYS.has(keyValue)) {
@@ -276,6 +278,7 @@ module.exports = {
276278

277279
if (reportArgs.length === 1) {
278280
if (reportArgs[0].type === 'ObjectExpression') {
281+
// eslint-disable-next-line unicorn/prefer-object-from-entries
279282
return reportArgs[0].properties.reduce((reportInfo, property) => {
280283
const propName = module.exports.getKeyName(property);
281284

@@ -308,9 +311,9 @@ module.exports = {
308311
return null;
309312
}
310313

311-
return keys
314+
return Object.fromEntries(keys
312315
.slice(0, reportArgs.length)
313-
.reduce((reportInfo, key, index) => Object.assign(reportInfo, { [key]: reportArgs[index] }), {});
316+
.map((key, index) => [key, reportArgs[index]]));
314317
},
315318

316319
/**
@@ -332,10 +335,8 @@ module.exports = {
332335
identifier.parent.parent === identifier.parent.parent.parent.init &&
333336
identifier.parent.parent.parent.id.type === 'Identifier'
334337
)
335-
.map(identifier => context.getDeclaredVariables(identifier.parent.parent.parent))
336-
.reduce((allVariables, variablesForIdentifier) => [...allVariables, ...variablesForIdentifier], [])
337-
.map(variable => variable.references)
338-
.reduce((allRefs, refsForVariable) => [...allRefs, ...refsForVariable], [])
338+
.flatMap(identifier => context.getDeclaredVariables(identifier.parent.parent.parent))
339+
.flatMap(variable => variable.references)
339340
.map(ref => ref.identifier));
340341
},
341342

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"eslint-plugin-markdown": "^2.0.1",
4848
"eslint-plugin-node": "^11.1.0",
4949
"eslint-plugin-self": "^1.2.1",
50-
"eslint-plugin-unicorn": "^31.0.0",
50+
"eslint-plugin-unicorn": "^36.0.0",
5151
"eslint-scope": "^5.1.1",
5252
"espree": "^7.3.0",
5353
"estraverse": "^5.0.0",

0 commit comments

Comments
 (0)