Change decoratorsBeforeExport default to false (#8113)

This commit is contained in:
Nicolò Ribaudo 2018-06-04 21:12:01 +02:00 committed by GitHub
parent b445b79734
commit 6349118bed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 16 deletions

View File

@ -52,10 +52,7 @@ function normalizeOptions(code, opts): Format {
style: " ",
base: 0,
},
decoratorsBeforeExport:
opts.decoratorsBeforeExport === undefined
? true
: opts.decoratorsBeforeExport,
decoratorsBeforeExport: !!opts.decoratorsBeforeExport,
};
if (format.minified) {

View File

@ -32,15 +32,15 @@ class Foo {
}
@foo
export default class Foo {
export default @foo
class Foo {
bar() {
class Baz {}
}
}
@foo
export class Foo {
export @foo
class Foo {
bar() {
class Baz {}
}

View File

@ -263,8 +263,7 @@ export default class StatementParser extends ExpressionParser {
this.raise(
this.state.start,
"Using the export keyword between a decorator and a class is not allowed. " +
"Please use `export @dec class` instead, or set the " +
"'decoratorsBeforeExport' option to true.",
"Please use `export @dec class` instead.",
);
}
} else if (!this.canHaveLeadingDecorator()) {

View File

@ -1,4 +1,4 @@
{
"sourceType": "module",
"throws": "Using the export keyword between a decorator and a class is not allowed. Please use `export @dec class` instead, or set the 'decoratorsBeforeExport' option to true. (2:0)"
"throws": "Using the export keyword between a decorator and a class is not allowed. Please use `export @dec class` instead. (2:0)"
}

View File

@ -16,7 +16,7 @@ export default declare((api, options) => {
);
}
let { decoratorsBeforeExport } = options;
const { decoratorsBeforeExport } = options;
if (decoratorsBeforeExport !== undefined) {
if (legacy) {
throw new Error(
@ -26,8 +26,6 @@ export default declare((api, options) => {
if (typeof decoratorsBeforeExport !== "boolean") {
throw new Error("'decoratorsBeforeExport' must be a boolean.");
}
} else if (!legacy) {
decoratorsBeforeExport = true;
}
return {

View File

@ -47,8 +47,8 @@ describe("'decoratorsBeforeExport' option", function() {
const AFTER = "export @dec class Foo {}";
// These are skipped
run(BEFORE, undefined, false);
run(AFTER, undefined, true);
run(BEFORE, undefined, true);
run(AFTER, undefined, false);
run(BEFORE, true, false);
run(AFTER, true, true);
run(BEFORE, false, true);