Skip to content

Commit 404c42d

Browse files
renovate[bot]renovate-botcalebeby
authored
Update dependency eslint-plugin-unicorn to v23 (#176)
Co-authored-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: Caleb Eby <caleb.eby01@gmail.com>
1 parent b98718a commit 404c42d

9 files changed

Lines changed: 71 additions & 83 deletions

File tree

.changeset/five-moles-destroy.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@cloudfour/eslint-plugin': major
3+
---
4+
5+
Update `eslint-plugin-unicorn` to [`23.0.0`](https://github.com/sindresorhus/eslint-plugin-unicorn/releases/tag/v23.0.0)
6+
7+
- New rule: [`unicorn/prefer-math-trunc`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v23.0.0/docs/rules/prefer-math-trunc.md) (enabled by default)
8+
- New rule: [`unicorn/prefer-ternary`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v23.0.0/docs/rules/prefer-ternary.md) (enabled by default)
9+
- New rule: [`numeric-separators-style`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v23.0.0/docs/rules/numeric-separators-style.md) (not enabled by default yet)

fixtures/babel/packages/babel-plugin-transform-for-of/src/index.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,25 +171,18 @@ export default declare((api, options) => {
171171

172172
const { node, parent, scope } = path;
173173
const left = node.left;
174-
let declar;
175174

176175
const stepKey = scope.generateUid('step');
177176
const stepValue = t.memberExpression(
178177
t.identifier(stepKey),
179178
t.identifier('value')
180179
);
181180

182-
if (t.isVariableDeclaration(left)) {
183-
// For (let i of test)
184-
declar = t.variableDeclaration(left.kind, [
185-
t.variableDeclarator(left.declarations[0].id, stepValue),
186-
]);
187-
} else {
188-
// For (i of test), for ({ i } of test)
189-
declar = t.expressionStatement(
190-
t.assignmentExpression('=', left, stepValue)
191-
);
192-
}
181+
const declar = t.isVariableDeclaration(left)
182+
? t.variableDeclaration(left.kind, [
183+
t.variableDeclarator(left.declarations[0].id, stepValue),
184+
])
185+
: t.expressionStatement(t.assignmentExpression('=', left, stepValue));
193186

194187
// Ensure that it's a block so we can take all its statements
195188
path.ensureBlock();

fixtures/babel/packages/babel-plugin-transform-modules-commonjs/src/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,19 +199,17 @@ export default declare((api, options) => {
199199
const init =
200200
wrapInterop(path, loadExpr, metadata.interop) || loadExpr;
201201

202-
if (metadata.lazy) {
203-
header = template.ast`
202+
header = metadata.lazy
203+
? template.ast`
204204
function ${metadata.name}() {
205205
const data = ${init};
206206
${metadata.name} = function(){ return data; };
207207
return data;
208208
}
209-
`;
210-
} else {
211-
header = template.ast`
209+
`
210+
: template.ast`
212211
var ${metadata.name} = ${init};
213212
`;
214-
}
215213
}
216214

217215
header.loc = metadata.loc;

fixtures/cloudfour.com-patterns/gulpfile.js/theo-formats/stories.mdx.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,9 @@ function mdxProps(props) {
7575
*/
7676
function categoryToMdx(category, props) {
7777
const categoryTitle = startCase(category);
78-
let categoryBody;
79-
if (category.includes('color')) {
80-
categoryBody = mdxColors(props);
81-
} else {
82-
categoryBody = mdxProps(props);
83-
}
78+
const categoryBody = category.includes('color')
79+
? mdxColors(props)
80+
: mdxProps(props);
8481

8582
return `
8683
## ${categoryTitle}

fixtures/dom-testing-library/src/queries/role.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,12 @@ const getMissingError = (
108108
let roleMessage;
109109

110110
if (roles.length === 0) {
111-
if (hidden === false) {
112-
roleMessage =
113-
'There are no accessible roles. But there might be some inaccessible roles. ' +
114-
'If you wish to access them, then set the `hidden` option to `true`. ' +
115-
'Learn more about this here: https://testing-library.com/docs/dom-testing-library/api-queries#byrole';
116-
} else {
117-
roleMessage = 'There are no available roles.';
118-
}
111+
roleMessage =
112+
hidden === false
113+
? 'There are no accessible roles. But there might be some inaccessible roles. ' +
114+
'If you wish to access them, then set the `hidden` option to `true`. ' +
115+
'Learn more about this here: https://testing-library.com/docs/dom-testing-library/api-queries#byrole'
116+
: 'There are no available roles.';
119117
} else {
120118
roleMessage = `
121119
Here are the ${hidden === false ? 'accessible' : 'available'} roles:

fixtures/downshift/src/hooks/useCombobox/reducer.js

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -22,51 +22,47 @@ export default function downshiftUseComboboxReducer(state, action) {
2222
};
2323
break;
2424
case stateChangeTypes.InputKeyDownArrowDown:
25-
if (state.isOpen) {
26-
changes = {
27-
highlightedIndex: getNextWrappingIndex(
28-
shiftKey ? 5 : 1,
29-
state.highlightedIndex,
30-
props.items.length,
31-
action.getItemNodeFromIndex,
32-
props.circularNavigation
33-
),
34-
};
35-
} else {
36-
changes = {
37-
highlightedIndex: getHighlightedIndexOnOpen(
38-
props,
39-
state,
40-
1,
41-
action.getItemNodeFromIndex
42-
),
43-
isOpen: true,
44-
};
45-
}
25+
changes = state.isOpen
26+
? {
27+
highlightedIndex: getNextWrappingIndex(
28+
shiftKey ? 5 : 1,
29+
state.highlightedIndex,
30+
props.items.length,
31+
action.getItemNodeFromIndex,
32+
props.circularNavigation
33+
),
34+
}
35+
: {
36+
highlightedIndex: getHighlightedIndexOnOpen(
37+
props,
38+
state,
39+
1,
40+
action.getItemNodeFromIndex
41+
),
42+
isOpen: true,
43+
};
4644

4745
break;
4846
case stateChangeTypes.InputKeyDownArrowUp:
49-
if (state.isOpen) {
50-
changes = {
51-
highlightedIndex: getNextWrappingIndex(
52-
shiftKey ? -5 : -1,
53-
state.highlightedIndex,
54-
props.items.length,
55-
action.getItemNodeFromIndex,
56-
props.circularNavigation
57-
),
58-
};
59-
} else {
60-
changes = {
61-
highlightedIndex: getHighlightedIndexOnOpen(
62-
props,
63-
state,
64-
-1,
65-
action.getItemNodeFromIndex
66-
),
67-
isOpen: true,
68-
};
69-
}
47+
changes = state.isOpen
48+
? {
49+
highlightedIndex: getNextWrappingIndex(
50+
shiftKey ? -5 : -1,
51+
state.highlightedIndex,
52+
props.items.length,
53+
action.getItemNodeFromIndex,
54+
props.circularNavigation
55+
),
56+
}
57+
: {
58+
highlightedIndex: getHighlightedIndexOnOpen(
59+
props,
60+
state,
61+
-1,
62+
action.getItemNodeFromIndex
63+
),
64+
isOpen: true,
65+
};
7066

7167
break;
7268
case stateChangeTypes.InputKeyDownEnter:

fixtures/mocha/browser-entry.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,8 @@ function timeslice() {
8181
immediateQueue.shift()();
8282
}
8383

84-
if (immediateQueue.length > 0) {
85-
immediateTimeout = setTimeout(timeslice, 0);
86-
} else {
87-
immediateTimeout = null;
88-
}
84+
immediateTimeout =
85+
immediateQueue.length > 0 ? setTimeout(timeslice, 0) : null;
8986
}
9087

9188
/**

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"eslint-plugin-jsdoc": "^30.0.0",
3737
"eslint-plugin-node": "^11.0.0",
3838
"eslint-plugin-promise": "^4.0.1",
39-
"eslint-plugin-unicorn": "^22.0.0"
39+
"eslint-plugin-unicorn": "^23.0.0"
4040
},
4141
"peerDependencies": {
4242
"eslint": "^5.9.0 || ^6.0.0 || ^7.0.0"

0 commit comments

Comments
 (0)