Add lint for invalid XHP class enum values
commitd3c96ad72964dcd486c189f610f20c9a88d73cc0
authorWilfred Hughes <wilfred@fb.com>
Tue, 31 May 2022 21:46:23 +0000 (31 14:46 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Tue, 31 May 2022 21:46:23 +0000 (31 14:46 -0700)
tree56245402ca9a65e501d4ee273e3b8cf8b7881c57
parentdf5d481fe7ede3031829043830622ce18b1cbcb0
Add lint for invalid XHP class enum values

Summary:
If a user writes an XHP attribute with a literal value that isn't included in the enum, produce a lint warning. This warns on code of the form:

```
class :foo {
  attribute enum {'big', 'small'} size;
}

function bad_attr_value(): void {
  $x = <foo size="medium" />;
}
```

Reviewed By: hgoldstein

Differential Revision: D36728410

fbshipit-source-id: 0d54e32e8d3b2a757a0acc49fffbcc4aaa993be3
hphp/hack/src/lints/linter_xhp_attr_value.ml [new file with mode: 0644]
hphp/hack/src/lints/linting_main.ml
hphp/hack/src/lints/lints_codes.ml
hphp/hack/src/lints/lints_errors.ml
hphp/hack/test/lint/xhp_invalid_attr_value.php [new file with mode: 0644]
hphp/hack/test/lint/xhp_invalid_attr_value.php.exp [new file with mode: 0644]
hphp/hack/test/lint/xhp_invalid_attr_value_int.php [new file with mode: 0644]
hphp/hack/test/lint/xhp_invalid_attr_value_int.php.exp [new file with mode: 0644]
hphp/hack/test/lint/xhp_invalid_attr_value_int_and_string.php [new file with mode: 0644]
hphp/hack/test/lint/xhp_invalid_attr_value_int_and_string.php.exp [new file with mode: 0644]