From 4b87d20b9351155fe551567bb747996ebefff154 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 24 Dec 2017 08:51:38 -0500 Subject: [PATCH] tweak error wording slightly --- src/validate/js/propValidators/computed.ts | 4 ++-- src/validate/js/propValidators/helpers.ts | 2 +- .../samples/computed-purify-check-no-this/errors.json | 8 -------- .../samples/computed-purify-check-this-get/errors.json | 8 -------- .../samples/computed-purity-check-no-this/errors.json | 8 ++++++++ .../input.html | 0 .../samples/computed-purity-check-this-get/errors.json | 8 ++++++++ .../input.html | 0 .../samples/helper-purity-check-this-get/errors.json | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) delete mode 100644 test/validator/samples/computed-purify-check-no-this/errors.json delete mode 100644 test/validator/samples/computed-purify-check-this-get/errors.json create mode 100644 test/validator/samples/computed-purity-check-no-this/errors.json rename test/validator/samples/{computed-purify-check-no-this => computed-purity-check-no-this}/input.html (100%) create mode 100644 test/validator/samples/computed-purity-check-this-get/errors.json rename test/validator/samples/{computed-purify-check-this-get => computed-purity-check-this-get}/input.html (100%) diff --git a/src/validate/js/propValidators/computed.ts b/src/validate/js/propValidators/computed.ts index a1b9afa937..644043ddb1 100644 --- a/src/validate/js/propValidators/computed.ts +++ b/src/validate/js/propValidators/computed.ts @@ -34,14 +34,14 @@ export default function computed(validator: Validator, prop: Node) { walkThroughTopFunctionScope(body, (node: Node) => { if (isThisGetCallExpression(node) && !node.callee.property.computed) { validator.error( - `Cannot use this.get(...) — it must be passed into the computed function as an argument`, + `Cannot use this.get(...) — values must be passed into the function as arguments`, node.start ); } if (node.type === 'ThisExpression') { validator.error( - `Computed should be pure functions — they do not have access to the component instance and cannot use 'this'. Did you mean to put this in 'methods'?`, + `Computed properties should be pure functions — they do not have access to the component instance and cannot use 'this'. Did you mean to put this in 'methods'?`, node.start ); } diff --git a/src/validate/js/propValidators/helpers.ts b/src/validate/js/propValidators/helpers.ts index d4960d9e1e..7c0cc4dcc1 100644 --- a/src/validate/js/propValidators/helpers.ts +++ b/src/validate/js/propValidators/helpers.ts @@ -25,7 +25,7 @@ export default function helpers(validator: Validator, prop: Node) { walkThroughTopFunctionScope(prop.value.body, (node: Node) => { if (isThisGetCallExpression(node) && !node.callee.property.computed) { validator.error( - `Cannot use this.get(...) — it must be passed into the helper function as an argument`, + `Cannot use this.get(...) — values must be passed into the helper function as arguments`, node.start ); } diff --git a/test/validator/samples/computed-purify-check-no-this/errors.json b/test/validator/samples/computed-purify-check-no-this/errors.json deleted file mode 100644 index e1a5e392de..0000000000 --- a/test/validator/samples/computed-purify-check-no-this/errors.json +++ /dev/null @@ -1,8 +0,0 @@ -[{ - "message": "Computed should be pure functions — they do not have access to the component instance and cannot use 'this'. Did you mean to put this in 'methods'?", - "pos": 83, - "loc": { - "line": 7, - "column": 4 - } -}] diff --git a/test/validator/samples/computed-purify-check-this-get/errors.json b/test/validator/samples/computed-purify-check-this-get/errors.json deleted file mode 100644 index f5cb473ed2..0000000000 --- a/test/validator/samples/computed-purify-check-this-get/errors.json +++ /dev/null @@ -1,8 +0,0 @@ -[{ - "message": "Cannot use this.get(...) — it must be passed into the computed function as an argument", - "pos": 73, - "loc": { - "line": 7, - "column": 11 - } -}] diff --git a/test/validator/samples/computed-purity-check-no-this/errors.json b/test/validator/samples/computed-purity-check-no-this/errors.json new file mode 100644 index 0000000000..1da0787734 --- /dev/null +++ b/test/validator/samples/computed-purity-check-no-this/errors.json @@ -0,0 +1,8 @@ +[{ + "message": "Computed properties should be pure functions — they do not have access to the component instance and cannot use 'this'. Did you mean to put this in 'methods'?", + "pos": 83, + "loc": { + "line": 7, + "column": 4 + } +}] diff --git a/test/validator/samples/computed-purify-check-no-this/input.html b/test/validator/samples/computed-purity-check-no-this/input.html similarity index 100% rename from test/validator/samples/computed-purify-check-no-this/input.html rename to test/validator/samples/computed-purity-check-no-this/input.html diff --git a/test/validator/samples/computed-purity-check-this-get/errors.json b/test/validator/samples/computed-purity-check-this-get/errors.json new file mode 100644 index 0000000000..428251ed1c --- /dev/null +++ b/test/validator/samples/computed-purity-check-this-get/errors.json @@ -0,0 +1,8 @@ +[{ + "message": "Cannot use this.get(...) — values must be passed into the function as arguments", + "pos": 73, + "loc": { + "line": 7, + "column": 11 + } +}] \ No newline at end of file diff --git a/test/validator/samples/computed-purify-check-this-get/input.html b/test/validator/samples/computed-purity-check-this-get/input.html similarity index 100% rename from test/validator/samples/computed-purify-check-this-get/input.html rename to test/validator/samples/computed-purity-check-this-get/input.html diff --git a/test/validator/samples/helper-purity-check-this-get/errors.json b/test/validator/samples/helper-purity-check-this-get/errors.json index 51801fe8dd..9a13771658 100644 --- a/test/validator/samples/helper-purity-check-this-get/errors.json +++ b/test/validator/samples/helper-purity-check-this-get/errors.json @@ -1,5 +1,5 @@ [{ - "message": "Cannot use this.get(...) — it must be passed into the helper function as an argument", + "message": "Cannot use this.get(...) — values must be passed into the helper function as arguments", "pos": 74, "loc": { "line": 7,