Skip to content

Commit 71fdbf3

Browse files
committed
Cleanup messages
1 parent 3a4b4be commit 71fdbf3

File tree

1 file changed

+15
-28
lines changed

1 file changed

+15
-28
lines changed

lib/rules/no-async-in-computed-properties.js

+15-28
Original file line numberDiff line numberDiff line change
@@ -129,42 +129,29 @@ function create (context) {
129129
el.node.loc.start.line >= cp.value.loc.start.line &&
130130
el.node.loc.end.line <= cp.value.loc.end.line
131131
) {
132+
let message = `Unexpected asynchronous action in "{{name}}" computed property.`
132133
if (el.type === 'await') {
133-
context.report({
134-
node: el.node,
135-
message: `Unexpected await operator in "${cp.key}" computed property.`
136-
})
134+
message = `Unexpected await operator in "{{name}}" computed property.`
137135
} else if (el.type === 'yield') {
138-
context.report({
139-
node: el.node,
140-
message: `Unexpected yield keyword in "${cp.key}" computed property.`
141-
})
136+
message = `Unexpected yield keyword in "{{name}}" computed property.`
142137
} else if (el.type === 'yield*') {
143-
context.report({
144-
node: el.node,
145-
message: `Unexpected yield* expression in "${cp.key}" computed property.`
146-
})
138+
message = `Unexpected yield* expression in "{{name}}" computed property.`
147139
} else if (el.type === 'async') {
148-
context.report({
149-
node: el.node,
150-
message: `Unexpected async function declaration in "${cp.key}" computed property.`
151-
})
140+
message = `Unexpected async function declaration in "{{name}}" computed property.`
152141
} else if (el.type === 'promise') {
153-
context.report({
154-
node: el.node,
155-
message: `Unexpected asynchronous action in "${cp.key}" computed property.`
156-
})
157142
} else if (el.type === 'new') {
158-
context.report({
159-
node: el.node,
160-
message: `Unexpected Promise object in "${cp.key}" computed property.`
161-
})
143+
message = `Unexpected Promise object in "{{name}}" computed property.`
162144
} else if (el.type === 'timed') {
163-
context.report({
164-
node: el.node,
165-
message: `Unexpected timed function in "${cp.key}" computed property.`
166-
})
145+
message = `Unexpected timed function in "{{name}}" computed property.`
167146
}
147+
148+
context.report({
149+
node: el.node,
150+
message,
151+
data: {
152+
name: cp.key
153+
}
154+
})
168155
}
169156
})
170157
})

0 commit comments

Comments
 (0)