Skip to content

Commit fb57f3e

Browse files
committed
Add expressionTypes instead of raw messages
1 parent f6b60db commit fb57f3e

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ function isPromise (node) {
5858
function create (context) {
5959
const forbiddenNodes = []
6060

61-
const messages = {
62-
promise: 'Unexpected asynchronous action in "{{name}}" computed property.',
63-
await: 'Unexpected await operator in "{{name}}" computed property.',
64-
yield: 'Unexpected yield keyword in "{{name}}" computed property.',
65-
generator: 'Unexpected generator function expression in "{{name}}" computed property.',
66-
async: 'Unexpected async function declaration in "{{name}}" computed property.',
67-
new: 'Unexpected Promise object in "{{name}}" computed property.',
68-
timed: 'Unexpected timed function in "{{name}}" computed property.'
61+
const expressionTypes = {
62+
promise: 'asynchronous action',
63+
await: 'await operator',
64+
yield: 'yield keyword',
65+
generator: 'generator function expression',
66+
async: 'async function declaration',
67+
new: 'Promise object',
68+
timed: 'timed function'
6969
}
7070

7171
function onFunctionEnter (node) {
@@ -142,9 +142,10 @@ function create (context) {
142142
) {
143143
context.report({
144144
node: el.node,
145-
message: messages[el.type],
145+
message: 'Unexpected {{expressionName}} in "{{propertyName}}" computed property.',
146146
data: {
147-
name: cp.key
147+
expressionName: expressionTypes[el.type],
148+
propertyName: cp.key
148149
}
149150
})
150151
}

0 commit comments

Comments
 (0)