|
// A class name must start with an upper-case letter and be either 1 letter long or contain a lower-case letter. |
|
'class-name': /\b[A-Z](?:[A-Z_\d]*[a-z]\w*)?\b/, |
In swift, we have a pattern of naming private things a client can but really shouldn't touch with one or more prefixed underscore.
With the current regex though, it must start with /[A-Z]/, is something like _Foo would not match.
The solution could be as simple as: /\b_*[A-Z](?:[A-Z_\d]*[a-z]\w*)?\b/, or /\b(?:_+)?[A-Z](?:[A-Z_\d]*[a-z]\w*)?\b/.
Technically swift also supports naming both classes (and funcs and vars) literally anything (even including whitespace) by wrapping the name in backticks (ex. `Foo Bar`), but that's very rarely used and I think can safely be excluded.
prism/src/languages/swift.js
Lines 139 to 140 in d805f30
In swift, we have a pattern of naming private things a client can but really shouldn't touch with one or more prefixed underscore.
With the current regex though, it must start with
/[A-Z]/, is something like_Foowould not match.The solution could be as simple as:
/\b_*[A-Z](?:[A-Z_\d]*[a-z]\w*)?\b/, or/\b(?:_+)?[A-Z](?:[A-Z_\d]*[a-z]\w*)?\b/.Technically swift also supports naming both classes (and funcs and vars) literally anything (even including whitespace) by wrapping the name in backticks (ex. `Foo Bar`), but that's very rarely used and I think can safely be excluded.