Forbid decorators on object property (#14661)
This commit is contained in:
1 parent
1d4f243d72
commit
4965a790cb
6 files changed
+28
-38
No files matched your search
@@ -199,7 +199,6 @@ const allowedMessageCodes = new Set([
|
||||
"LineTerminatorBeforeArrow",
|
||||
"InvalidEscapeSequenceTemplate",
|
||||
"NonAbstractClassHasAbstractMethod",
|
||||
"UnsupportedPropertyDecorator",
|
||||
"OptionalTypeBeforeRequired",
|
||||
"PatternIsOptional",
|
||||
"OptionalBindingPattern",
|
||||
|
||||
@@ -47,9 +47,6 @@ const additionalVisitorKeys = {
|
||||
NeverTypeAnnotation: [],
|
||||
UndefinedTypeAnnotation: [],
|
||||
UnknownTypeAnnotation: [],
|
||||
|
||||
// Unknown
|
||||
Property: ["decorators"],
|
||||
};
|
||||
|
||||
const excludeKeys = {
|
||||
|
||||
@@ -579,32 +579,22 @@ class Foo {
|
||||
|
||||
exports[`multiple.js [acorn] format 1`] = `
|
||||
"Unexpected character '@' (2:3)
|
||||
1 | const dog = {
|
||||
1 | const dog = class {
|
||||
> 2 | @readonly
|
||||
| ^
|
||||
3 | @nonenumerable
|
||||
4 | @doubledValue
|
||||
5 | legs: 4,"
|
||||
5 | legs = 4;"
|
||||
`;
|
||||
|
||||
exports[`multiple.js [espree] format 1`] = `
|
||||
"Unexpected character '@' (2:3)
|
||||
1 | const dog = {
|
||||
1 | const dog = class {
|
||||
> 2 | @readonly
|
||||
| ^
|
||||
3 | @nonenumerable
|
||||
4 | @doubledValue
|
||||
5 | legs: 4,"
|
||||
`;
|
||||
|
||||
exports[`multiple.js [meriyah] format 1`] = `
|
||||
"Unexpected token: '@' (2:3)
|
||||
1 | const dog = {
|
||||
> 2 | @readonly
|
||||
| ^
|
||||
3 | @nonenumerable
|
||||
4 | @doubledValue
|
||||
5 | legs: 4,"
|
||||
5 | legs = 4;"
|
||||
`;
|
||||
|
||||
exports[`multiple.js format 1`] = `
|
||||
@@ -613,40 +603,44 @@ parsers: ["babel"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
const dog = {
|
||||
const dog = class {
|
||||
@readonly
|
||||
@nonenumerable
|
||||
@doubledValue
|
||||
legs: 4,
|
||||
legs = 4;
|
||||
|
||||
@readonly
|
||||
@nonenumerable
|
||||
@doubledValue
|
||||
eyes: 2
|
||||
eyes() {return 2}
|
||||
};
|
||||
|
||||
const foo = {
|
||||
@multipleDecorators @inline @theyWontAllFitInOneline aVeryLongPropName: "A very long string as value"
|
||||
const foo = class {
|
||||
@multipleDecorators @inline @theyWontAllFitInOneline aVeryLongPropName = "A very long string as value"
|
||||
@multipleDecorators @inline @theyWontAllFitInOneline aVeryLongPropName() { "A very long string as value"}
|
||||
};
|
||||
|
||||
=====================================output=====================================
|
||||
const dog = {
|
||||
const dog = class {
|
||||
@readonly
|
||||
@nonenumerable
|
||||
@doubledValue
|
||||
legs: 4,
|
||||
legs = 4;
|
||||
|
||||
@readonly
|
||||
@nonenumerable
|
||||
@doubledValue
|
||||
eyes: 2,
|
||||
eyes() {
|
||||
return 2;
|
||||
}
|
||||
};
|
||||
|
||||
const foo = {
|
||||
@multipleDecorators
|
||||
@inline
|
||||
@theyWontAllFitInOneline
|
||||
aVeryLongPropName: "A very long string as value",
|
||||
const foo = class {
|
||||
@multipleDecorators @inline @theyWontAllFitInOneline aVeryLongPropName =
|
||||
"A very long string as value";
|
||||
@multipleDecorators @inline @theyWontAllFitInOneline aVeryLongPropName() {
|
||||
"A very long string as value";
|
||||
}
|
||||
};
|
||||
|
||||
================================================================================
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
run_spec(import.meta, ["babel"], {
|
||||
errors: { acorn: true, espree: true, meriyah: ["multiple.js"] },
|
||||
errors: { acorn: true, espree: true },
|
||||
});
|
||||
@@ -1,15 +1,16 @@
|
||||
const dog = {
|
||||
const dog = class {
|
||||
@readonly
|
||||
@nonenumerable
|
||||
@doubledValue
|
||||
legs: 4,
|
||||
legs = 4;
|
||||
|
||||
@readonly
|
||||
@nonenumerable
|
||||
@doubledValue
|
||||
eyes: 2
|
||||
eyes() {return 2}
|
||||
};
|
||||
|
||||
const foo = {
|
||||
@multipleDecorators @inline @theyWontAllFitInOneline aVeryLongPropName: "A very long string as value"
|
||||
const foo = class {
|
||||
@multipleDecorators @inline @theyWontAllFitInOneline aVeryLongPropName = "A very long string as value"
|
||||
@multipleDecorators @inline @theyWontAllFitInOneline aVeryLongPropName() { "A very long string as value"}
|
||||
};
|
||||
@@ -613,7 +613,6 @@ exports[`visitor keys estree 1`] = `
|
||||
"Property": [
|
||||
"key",
|
||||
"value",
|
||||
"decorators",
|
||||
],
|
||||
"PropertyDefinition": [
|
||||
"decorators",
|
||||
|
||||
Reference in new issue
Block a user