Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable optional chaining by default in @babel/parser #10817

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
73afad3
enable optional chaining by default
jackisherwood Dec 5, 2019
e9dc74e
fix: Promise.any requires global.AggregateError (#10930)
JLHwung Dec 27, 2019
b91720c
helper-module-transforms: dereference imported template tag (#10934)
ajafff Dec 28, 2019
3145133
chore: update test262 (#10943)
JLHwung Dec 30, 2019
197a8da
Remove unused parser methods (#10942)
JLHwung Dec 30, 2019
86245a8
TSTypeCastExpression should not be inside call parameters (#10939)
JLHwung Dec 30, 2019
30449fe
Refactor parseSubscript (#10937)
JLHwung Dec 30, 2019
2f3f779
refactor: remove unused invalidTemplateEscapePosition tokenizer state…
JLHwung Dec 30, 2019
0238244
refactor: remove unecessary checkYieldAwaitInDefaultParams (#10936)
JLHwung Dec 30, 2019
26eb891
fix: Class Field Initializer should not allow await expression as imm…
JLHwung Dec 31, 2019
daaa206
Override toString in case this function is printed (#10949)
jayenashar Jan 1, 2020
9f832c2
@babel/eslint-parser: Fix ClassPrivateMethods (#10913)
kaicataldo Jan 2, 2020
e504805
Add integration test: e2e-vue-cli (#10919)
JLHwung Jan 3, 2020
6ee8c97
Fix: TopLevelAwait should respect await identifiers defined in… (#10947)
JLHwung Jan 3, 2020
467667a
When reading a new string, U+2028/2029 should correctly set th… (#10944)
JLHwung Jan 3, 2020
a283537
fix: check await when parsing AsyncArrowBindingIdentifier (#10953)
JLHwung Jan 3, 2020
455d782
test: add invalid-lone-import test (#10950)
JLHwung Jan 3, 2020
a11281f
enable optional chaining by default
jackisherwood Dec 5, 2019
7665a54
Merge branch 'master' of https://github.com/jackisherwood/babel
jackisherwood Jan 3, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions .circleci/config.yml
Expand Up @@ -48,6 +48,11 @@ executors:
docker:
- image: circleci/node:13
working_directory: ~/babel
# e2e-vue-cli test requires chromium
node-browsers-executor:
docker:
- image: circleci/node:13-browsers
working_directory: ~/babel

jobs:
build-standalone:
Expand Down Expand Up @@ -153,6 +158,14 @@ jobs:
at: /tmp/verdaccio-workspace
- run: ./scripts/integration-tests/e2e-create-react-app.sh

e2e-vue-cli:
executor: node-browsers-executor
steps:
- checkout
- attach_workspace:
at: /tmp/verdaccio-workspace
- run: ./scripts/integration-tests/e2e-vue-cli.sh

workflows:
version: 2
build-standalone:
Expand Down Expand Up @@ -189,3 +202,7 @@ workflows:
- e2e-create-react-app:
requires:
- publish-verdaccio
- e2e-vue-cli:
requires:
- publish-verdaccio

4 changes: 2 additions & 2 deletions Makefile
@@ -1,5 +1,5 @@
FLOW_COMMIT = 09669846b7a7ca5a6c23c12d56bb3bebdafd67e9
TEST262_COMMIT = 8688c4ab79059c3097098605e69f1ee5eda6c409
TEST262_COMMIT = 157b18d16b5d52501c4d75ac422d3a80bfad1c17
TYPESCRIPT_COMMIT = 038d95144d8b93c2799d1732181c89c3d84362d5

FORCE_PUBLISH = "@babel/runtime,@babel/runtime-corejs2,@babel/runtime-corejs3,@babel/standalone,@babel/preset-env-standalone"
Expand Down Expand Up @@ -189,7 +189,7 @@ test-typescript-update-whitelist:
bootstrap-test262:
rm -rf build/test262
mkdir -p build
git clone --branch=master --single-branch --shallow-since=2019-09-01 https://github.com/tc39/test262.git build/test262
git clone --branch=master --single-branch --shallow-since=2019-12-01 https://github.com/tc39/test262.git build/test262
cd build/test262 && git checkout $(TEST262_COMMIT)

test-test262:
Expand Down
1 change: 1 addition & 0 deletions eslint/babel-eslint-parser/package.json
Expand Up @@ -34,6 +34,7 @@
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
"@babel/plugin-proposal-pipeline-operator": "^7.0.0",
"@babel/plugin-proposal-private-methods": "^7.7.4",
"@babel/plugin-syntax-bigint": "^7.7.4",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-export-default-from": "^7.0.0",
Expand Down
25 changes: 15 additions & 10 deletions eslint/babel-eslint-parser/src/analyze-scope.js
Expand Up @@ -16,16 +16,16 @@ const flowFlippedAliasKeys = t.FLIPPED_ALIAS_KEYS.Flow.concat([
"ObjectPattern",
"RestElement",
]);
const visitorKeysMap = Object.entries(t.VISITOR_KEYS).reduce(function(
acc,
[key, value],
) {
if (flowFlippedAliasKeys.indexOf(value) === -1) {
acc[key] = value;
}
return acc;
},
{});

const visitorKeysMap = Object.entries(t.VISITOR_KEYS).reduce(
(acc, [key, value]) => {
if (!flowFlippedAliasKeys.includes(value)) {
acc[key] = value;
}
return acc;
},
{},
);

const propertyTypes = {
// loops
Expand Down Expand Up @@ -166,6 +166,11 @@ class Referencer extends OriginalReferencer {
this._visitClassProperty(node);
}

// TODO: Update to visit type annotations when TypeScript/Flow support this syntax.
ClassPrivateMethod(node) {
super.MethodDefinition(node);
}

DeclareModule(node) {
this._visitDeclareX(node);
}
Expand Down
2 changes: 1 addition & 1 deletion eslint/babel-eslint-parser/test/babel-eslint-parser.js
Expand Up @@ -270,7 +270,7 @@ describe("babylon-to-espree", () => {
assert.strictEqual(babylonAST.tokens[1].type, "Punctuator");
});

// Espree doesn't support the private fields yet
// Espree doesn't support private fields yet
it("hash (token)", () => {
const code = "class A { #x }";
const babylonAST = parseForESLint(code, {
Expand Down
Expand Up @@ -18,5 +18,6 @@ module.exports = {
["@babel/plugin-proposal-decorators", { decoratorsBeforeExport: false }],
["@babel/plugin-proposal-pipeline-operator", { proposal: "minimal" }],
"@babel/plugin-syntax-bigint",
"@babel/plugin-proposal-private-methods",
],
};
104 changes: 85 additions & 19 deletions eslint/babel-eslint-parser/test/non-regression.js
Expand Up @@ -1763,27 +1763,77 @@ describe("verify", () => {
);
});

describe("private class properties", () => {
it("should not be undefined", () => {
verifyAndAssertMessages(
`
class C {
#d = 1;
}
`,
{ "no-undef": 1 },
);
describe("class field declarations", () => {
describe("field declarations", () => {
it("should not be undefined", () => {
verifyAndAssertMessages(
`
class C {
d = 1;
}
`,
{ "no-undef": 1 },
);
});

it("should not be unused", () => {
verifyAndAssertMessages(
`
export class C {
d = 1;
}
`,
{ "no-unused-vars": 1 },
);
});
});

it("should not be unused", () => {
verifyAndAssertMessages(
`
export class C {
#d = 1;
}
`,
{ "no-unused-vars": 1 },
);
describe("private field declarations", () => {
it("should not be undefined", () => {
verifyAndAssertMessages(
`
class C {
#d = 1;
}
`,
{ "no-undef": 1 },
);
});

it("should not be unused", () => {
verifyAndAssertMessages(
`
export class C {
#d = 1;
}
`,
{ "no-unused-vars": 1 },
);
});
});

describe("private methods", () => {
it("should not be undefined", () => {
verifyAndAssertMessages(
`
class C {
#d() {};
}
`,
{ "no-undef": 1 },
);
});

it("should not be unused", () => {
verifyAndAssertMessages(
`
export class C {
#d() {};
}
`,
{ "no-unused-vars": 1 },
);
});
});
});

Expand Down Expand Up @@ -1853,6 +1903,22 @@ describe("verify", () => {
);
});

it("works with classPrivateMethods", () => {
verifyAndAssertMessages(
`
class A { #a(b, c) {} }
`,
);
});

it("works with arrow function classPrivateProperties", () => {
verifyAndAssertMessages(
`
class A { #a = (a, b) => {}; }
`,
);
});

it("works with optionalCatchBinding", () => {
verifyAndAssertMessages(
`
Expand Down
Expand Up @@ -182,7 +182,9 @@ const rewriteReferencesVisitor = {
ref.loc = path.node.loc;

if (
path.parentPath.isCallExpression({ callee: path.node }) &&
(path.parentPath.isCallExpression({ callee: path.node }) ||
path.parentPath.isOptionalCallExpression({ callee: path.node }) ||
path.parentPath.isTaggedTemplateExpression({ tag: path.node })) &&
t.isMemberExpression(ref)
) {
path.replaceWith(t.sequenceExpression([t.numericLiteral(0), ref]));
Expand Down