options: ["^[^_]+$", {
properties: false
}]
+ },
+
+ // Class Methods
+ {
+ code: "class x { foo() {} }",
+ options: ["^[^_]+$"],
+ parserOptions: { ecmaVersion: 2022 }
+ },
+ {
+ code: "class x { #foo() {} }",
+ options: ["^[^_]+$"],
+ parserOptions: { ecmaVersion: 2022 }
+ },
+
+ // Class Fields
+ {
+ code: "class x { _foo = 1; }",
+ options: ["^[^_]+$", {
+ classFields: false
+ }],
+ parserOptions: { ecmaVersion: 2022 }
+ },
+ {
+ code: "class x { #_foo = 1; }",
+ options: ["^[^_]+$", {
+ classFields: false
+ }],
+ parserOptions: { ecmaVersion: 2022 }
}
+
],
invalid: [
{
type: "Identifier"
}
]
+ },
+
+ // Class Methods
+ {
+ code: "class x { _foo() {} }",
+ options: ["^[^_]+$"],
+ parserOptions: { ecmaVersion: 2022 },
+ errors: [
+ {
+ message: "Identifier '_foo' does not match the pattern '^[^_]+$'.",
+ type: "Identifier"
+ }
+ ]
+ },
+ {
+ code: "class x { #_foo() {} }",
+ options: ["^[^_]+$"],
+ parserOptions: { ecmaVersion: 2022 },
+ errors: [
+ {
+ message: "Identifier '#_foo' does not match the pattern '^[^_]+$'.",
+ type: "PrivateIdentifier"
+ }
+ ]
+ },
+
+ // Class Fields
+ {
+ code: "class x { _foo = 1; }",
+ options: ["^[^_]+$", {
+ classFields: true
+ }],
+ parserOptions: { ecmaVersion: 2022 },
+ errors: [
+ {
+ message: "Identifier '_foo' does not match the pattern '^[^_]+$'.",
+ type: "Identifier"
+ }
+ ]
+ },
+ {
+ code: "class x { #_foo = 1; }",
+ options: ["^[^_]+$", {
+ classFields: true
+ }],
+ parserOptions: { ecmaVersion: 2022 },
+ errors: [
+ {
+ message: "Identifier '#_foo' does not match the pattern '^[^_]+$'.",
+ type: "PrivateIdentifier"
+ }
+ ]
}
+
]
});