Skip to content

Commit

Permalink
Add support for the optional chaining operator (babel#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubennorte authored and existentialism committed Jun 15, 2018
1 parent ebc46e1 commit e802577
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/patch-eslint-scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ function monkeypatch(modules) {
// visit ClassPrivateProperty as a Property.
referencer.prototype.ClassPrivateProperty = visitClassProperty;

// visit OptionalMemberExpression as a MemberExpression.
referencer.prototype.OptionalMemberExpression =
referencer.prototype.MemberExpression;

// visit flow type in FunctionDeclaration, FunctionExpression, ArrowFunctionExpression
var visitFunction = referencer.prototype.visitFunction;
referencer.prototype.visitFunction = function(node) {
Expand Down
12 changes: 12 additions & 0 deletions test/non-regression.js
Original file line number Diff line number Diff line change
Expand Up @@ -1651,6 +1651,18 @@ describe("verify", () => {
});
});

describe("optional chaining operator", () => {
it("should not be undefined #595", () => {
verifyAndAssertMessages(
`
const foo = {};
foo?.bar;
`,
{ "no-undef": 1 }
);
});
});

it("flow types on class method should be visited correctly", () => {
verifyAndAssertMessages(
`
Expand Down

0 comments on commit e802577

Please sign in to comment.