eslint-plugin-parentheses-around-await
Version:
The ESLint plugin to ensure you don't try to use properties on a not-yet-awaited values.
39 lines • 1.25 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const eslint_1 = require("eslint");
const parentheses_around_await_1 = __importDefault(require("./parentheses-around-await"));
const tester = new eslint_1.RuleTester({ parserOptions: { ecmaVersion: 2017 } });
tester.run('parentheses-around-await', parentheses_around_await_1.default, {
valid: [
{
code: `
(async () => {
const method = async () => ({ property: 'prop' });
const a = (await method()).property;
})();
`,
},
],
invalid: [
{
code: `
(async () => {
const method = async () => ({ property: 'prop' });
const a = await method().property;
})();
`,
errors: [
{
message: `If you want to access properties on an awaited value,
you should wrap the value with parantheses. If not,
you may get undefined which will lead to bugs.
`,
},
],
},
],
});
//# sourceMappingURL=parentheses-around-await.test.js.map