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

Clean all always enabled parser plugins #16572

Merged
merged 6 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Gulpfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,13 @@ function buildRollupDts(packages) {
const bundle = await rollup({
input,
plugins: [
{
transform: code =>
code.replace(
/type BABEL_8_BREAKING\s*=\s*boolean/g,
`type BABEL_8_BREAKING = ${bool(process.env.BABEL_8_BREAKING) ?? false}`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ?? false here seems to never be run?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bool can return undefined. While it's ok usually, in this case undefined was included in the generated code.

),
},
bool(process.env.BABEL_8_BREAKING) ? rollupDts() : rollupDts5(),
],
external,
Expand Down Expand Up @@ -641,7 +648,9 @@ function buildRollupDts(packages) {
build(
"packages/babel-parser/typings/babel-parser.source.d.ts",
"packages/babel-parser/typings/babel-parser.d.ts",
"// This file is auto-generated! Do not modify it directly.\n/* eslint-disable @typescript-eslint/consistent-type-imports, prettier/prettier */",
"// This file is auto-generated! Do not modify it directly.\n" +
// @typescript-eslint/no-redundant-type-constituents can be removed once we drop the IF_BABEL_7 type
"/* eslint-disable @typescript-eslint/consistent-type-imports, @typescript-eslint/no-redundant-type-constituents, prettier/prettier */",
"packages/babel-parser"
)
);
Expand Down
6 changes: 1 addition & 5 deletions eslint/babel-eslint-parser/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,7 @@ describe("Babel and Espree", () => {
babelOptions: {
filename: "test.js",
parserOpts: {
plugins: [
["estree", { classFeatures: true }],
"classPrivateProperties",
"classProperties",
],
plugins: [["estree", { classFeatures: true }]],
},
},
}).ast;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"plugins": ["flow", "classProperties"]
"plugins": ["flow"]
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "plugins": ["classProperties", "flow"] }
{ "plugins": ["flow"] }
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "plugins": ["classPrivateProperties", "flow"] }
{ "plugins": ["flow"] }
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "plugins": ["jsx", "optionalChaining", "flow"] }
{ "plugins": ["jsx", "flow"] }

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
"plugins": ["typescript"]
}
18 changes: 0 additions & 18 deletions packages/babel-parser/data/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,24 +170,16 @@
{
"enum": [
"asyncDoExpressions",
"asyncGenerators",
"bigInt",
"classPrivateMethods",
"classPrivateProperties",
"classProperties",
"classStaticBlock",
"decimal",
"decorators",
"decorators-legacy",
"decoratorAutoAccessors",
"deferredImportEvaluation",
"destructuringPrivate",
"doExpressions",
"dynamicImport",
"estree",
"explicitResourceManagement",
"exportDefaultFrom",
"exportNamespaceFrom",
"flow",
"flowComments",
"functionBind",
Expand All @@ -197,22 +189,12 @@
"importMeta",
"importReflection",
"jsx",
"logicalAssignment",
"moduleBlocks",
"moduleStringNames",
"nullishCoalescingOperator",
"numericSeparator",
"objectRestSpread",
"optionalCatchBinding",
"optionalChaining",
"partialApplication",
"pipelineOperator",
"placeholders",
"privateIn",
"regexpUnicodeSets",
"sourcePhaseImports",
"throwExpressions",
"topLevelAwait",
"typescript",
"v8intrinsic"
],
Expand Down
42 changes: 22 additions & 20 deletions packages/babel-parser/src/typings.d.ts
Original file line number Diff line number Diff line change
@@ -1,54 +1,56 @@
type BABEL_8_BREAKING = boolean;
type IF_BABEL_7<V> = false extends BABEL_8_BREAKING ? V : never;

export type Plugin =
| "asyncDoExpressions"
| "asyncGenerators"
| "bigInt"
| "classPrivateMethods"
| "classPrivateProperties"
| "classProperties"
| "classStaticBlock" // Enabled by default
| IF_BABEL_7<"asyncGenerators">
| IF_BABEL_7<"bigInt">
| IF_BABEL_7<"classPrivateMethods">
| IF_BABEL_7<"classPrivateProperties">
| IF_BABEL_7<"classProperties">
| IF_BABEL_7<"classStaticBlock">
| "decimal"
| "decorators-legacy"
| "deferredImportEvaluation"
| "decoratorAutoAccessors"
| "destructuringPrivate"
| "doExpressions"
| "dynamicImport"
| IF_BABEL_7<"dynamicImport">
| "explicitResourceManagement"
| "exportDefaultFrom"
| "exportNamespaceFrom" // deprecated
| IF_BABEL_7<"exportNamespaceFrom">
| "flow"
| "flowComments"
| "functionBind"
| "functionSent"
| "importMeta"
| "jsx"
| "logicalAssignment"
| IF_BABEL_7<"logicalAssignment">
| "importAssertions" // deprecated
| "importAttributes"
| "importReflection"
| "moduleBlocks"
| "moduleStringNames"
| "nullishCoalescingOperator"
| "numericSeparator"
| "objectRestSpread"
| "optionalCatchBinding"
| "optionalChaining"
| IF_BABEL_7<"moduleStringNames">
| IF_BABEL_7<"nullishCoalescingOperator">
| IF_BABEL_7<"numericSeparator">
| IF_BABEL_7<"objectRestSpread">
| IF_BABEL_7<"optionalCatchBinding">
| IF_BABEL_7<"optionalChaining">
| "partialApplication"
| "placeholders"
| "privateIn" // Enabled by default
| "regexpUnicodeSets" // Enabled by default
| IF_BABEL_7<"privateIn">
| IF_BABEL_7<"regexpUnicodeSets">
| "sourcePhaseImports"
| "throwExpressions"
| "topLevelAwait"
| IF_BABEL_7<"topLevelAwait">
| "v8intrinsic"
| ParserPluginWithOptions[0];

export type ParserPluginWithOptions =
| ["decorators", DecoratorsPluginOptions]
| ["estree", { classFeatures?: boolean }]
| ["importAttributes", { deprecatedAssertSyntax: boolean }]
// @deprecated
| ["moduleAttributes", { version: "may-2020" }]
| IF_BABEL_7<["moduleAttributes", { version: "may-2020" }]>
| ["optionalChainingAssign", { version: "2023-07" }]
| ["pipelineOperator", PipelineOperatorPluginOptions]
| ["recordAndTuple", RecordAndTuplePluginOptions]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{
"plugins": [
["pipelineOperator", { "proposal": "hack", "topicToken": "^" }],
"classPrivateProperties",
"classPrivateMethods"
]
"plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "^" }]]
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"plugins": [
["pipelineOperator", { "proposal": "hack", "topicToken": "^" }],
"doExpressions",
"asyncGenerators"
"doExpressions"
]
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"plugins": [
["pipelineOperator", { "proposal": "hack", "topicToken": "^" }],
"doExpressions",
"asyncGenerators"
"doExpressions"
]
}
Loading
Loading