Skip to content

Commit 63e8c44

Browse files
[Babel 8] Remove minimal,smart option of Pipeline Operator (#16801)
Co-authored-by: Nicolò Ribaudo <hello@nicr.dev>
1 parent 506bf91 commit 63e8c44

328 files changed

Lines changed: 66 additions & 53 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

eslint/babel-eslint-parser/test/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,18 @@ describe("Babel and Espree", () => {
364364
});
365365

366366
// Espree doesn't support the pipeline operator yet
367-
it("pipeline operator (token)", () => {
367+
itBabel7("pipeline operator (token)", () => {
368368
const code = "foo |> bar";
369369
const babylonAST = parseForESLint(code, {
370370
eslintVisitorKeys: true,
371371
eslintScopeManager: true,
372-
babelOptions: BABEL_OPTIONS,
372+
babelOptions: {
373+
filename: "test.js",
374+
parserOpts: {
375+
plugins: [["pipelineOperator", { proposal: "minimal" }]],
376+
tokens: true,
377+
},
378+
},
373379
}).ast;
374380
expect(babylonAST.tokens[1].type).toEqual("Punctuator");
375381
});

eslint/babel-eslint-shared-fixtures/config/babel.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ module.exports = {
1010
"@babel/plugin-syntax-export-default-from",
1111
"@babel/plugin-transform-class-properties",
1212
["@babel/plugin-proposal-decorators", { version: "2023-05" }],
13-
["@babel/plugin-proposal-pipeline-operator", { proposal: "minimal" }],
1413
"@babel/plugin-transform-private-methods",
1514
"@babel/plugin-proposal-do-expressions",
1615
"@babel/plugin-proposal-explicit-resource-management",

packages/babel-generator/test/fixtures/types/PipelineBareFunction/input.js renamed to packages/babel-generator/test/fixtures/types/PipelineBareFunction-babel-7/input.js

File renamed without changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"plugins": [["pipelineOperator", { "proposal": "smart" }]],
3+
"BABEL_8_BREAKING": false
4+
}

packages/babel-generator/test/fixtures/types/PipelineBareFunction/output.js renamed to packages/babel-generator/test/fixtures/types/PipelineBareFunction-babel-7/output.js

File renamed without changes.

packages/babel-generator/test/fixtures/types/PipelineBareFunction/options.json

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"plugins": [["pipelineOperator", { "proposal": "smart" }]]
2+
"plugins": [["pipelineOperator", { "proposal": "smart" }]],
3+
"BABEL_8_BREAKING": false
34
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"]
2+
"plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"],
3+
"BABEL_8_BREAKING": false
34
}

packages/babel-parser/src/parser/expression.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ export default abstract class ExpressionParser extends LValParser {
469469

470470
if (
471471
op === tt.pipeline &&
472+
// @ts-expect-error Remove this in Babel 8
472473
this.hasPlugin(["pipelineOperator", { proposal: "minimal" }])
473474
) {
474475
if (this.state.type === tt._await && this.prodParam.hasAwait) {
@@ -524,6 +525,7 @@ export default abstract class ExpressionParser extends LValParser {
524525
return this.parseHackPipeBody();
525526
});
526527

528+
// @ts-expect-error Remove this in Babel 8
527529
case "smart":
528530
return this.withTopicBindingContext(() => {
529531
if (this.prodParam.hasYield && this.isContextual(tt._yield)) {
@@ -3009,6 +3011,7 @@ export default abstract class ExpressionParser extends LValParser {
30093011
// of the infix operator `|>`.
30103012

30113013
checkPipelineAtInfixOperator(left: N.Expression, leftStartLoc: Position) {
3014+
// @ts-expect-error Remove this in Babel 8
30123015
if (this.hasPlugin(["pipelineOperator", { proposal: "smart" }])) {
30133016
if (left.type === "SequenceExpression") {
30143017
// Ensure that the pipeline head is not a comma-delimited
@@ -3096,6 +3099,7 @@ export default abstract class ExpressionParser extends LValParser {
30963099
// had before the function was called.
30973100

30983101
withSmartMixTopicForbiddingContext<T>(callback: () => T): T {
3102+
// @ts-expect-error Remove this in Babel 8
30993103
if (this.hasPlugin(["pipelineOperator", { proposal: "smart" }])) {
31003104
// Reset the parser’s topic context only if the smart-mix pipe proposal is active.
31013105
const outerContextTopicState = this.state.topicContext;

packages/babel-parser/src/plugin-utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ export type MixinPlugin = (
99
superClass: new (...args: any) => Parser,
1010
) => new (...args: any) => Parser;
1111

12-
const PIPELINE_PROPOSALS = ["minimal", "fsharp", "hack", "smart"];
12+
const PIPELINE_PROPOSALS = process.env.BABEL_8_BREAKING
13+
? ["fsharp", "hack"]
14+
: ["minimal", "fsharp", "hack", "smart"];
1315
const TOPIC_TOKENS = ["^^", "@@", "^", "%", "#"];
1416

1517
export function validatePlugins(pluginsMap: Map<string, any>) {

0 commit comments

Comments
 (0)