Skip to content

Commit cd86f33

Browse files
committed
Apply sugestions from code review
1 parent 2dc3d98 commit cd86f33

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

lib/rules/name-property-casing.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ function create (context) {
5757

5858
return utils.executeOnVue(context, (obj) => {
5959
const node = obj.properties
60-
.filter(item => (
60+
.find(item => (
6161
item.type === 'Property' &&
6262
item.key.name === 'name' &&
6363
item.value.type === 'Literal'
64-
))[0]
64+
))
6565

6666
if (!node) return
6767

lib/rules/require-prop-types.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ function create (context) {
1313

1414
function objectHasType (node) {
1515
const typeProperty = node.properties
16-
.filter(p =>
16+
.find(p =>
1717
utils.getStaticPropertyName(p.key) === 'type' &&
1818
(
1919
p.value.type !== 'ArrayExpression' ||
2020
p.value.elements.length > 0
2121
)
22-
)[0]
22+
)
2323
return Boolean(typeProperty)
2424
}
2525

2626
function checkProperties (items) {
27-
items.map(cp => {
27+
for (const cp of items) {
2828
if (cp.type !== 'Property') {
2929
return
3030
}
@@ -45,7 +45,7 @@ function create (context) {
4545
}
4646
})
4747
}
48-
})
48+
}
4949
}
5050

5151
// ----------------------------------------------------------------------
@@ -54,13 +54,13 @@ function create (context) {
5454

5555
return utils.executeOnVue(context, (obj) => {
5656
const node = obj.properties
57-
.filter(p =>
57+
.find(p =>
5858
p.type === 'Property' &&
5959
p.key.type === 'Identifier' &&
6060
p.key.name === 'props'
61-
)[0]
61+
)
6262

63-
if (!node) return null
63+
if (!node) return
6464

6565
if (node.value.type === 'ObjectExpression') {
6666
checkProperties(node.value.properties)

lib/utils/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,11 @@ module.exports = {
321321
*/
322322
getComputedProperties (componentObject) {
323323
const computedPropertiesNode = componentObject.properties
324-
.filter(p =>
324+
.find(p =>
325325
p.key.type === 'Identifier' &&
326326
p.key.name === 'computed' &&
327327
p.value.type === 'ObjectExpression'
328-
)[0]
328+
)
329329

330330
if (!computedPropertiesNode) { return [] }
331331

0 commit comments

Comments
 (0)