#21356·eslint

Bug: new-cap doesn't report names starting with an astral letter

Author: sary8Created Sep 26, 2026Updated Sep 26, 2026
Labelsbugruleacceptedrepro:yes

This issue was created with AI (Claude Fable 5.1, Claude Opus 5.5).

Environment

Node version: v25.2.1 npm version: v11.6.2 Local ESLint version: v10.11.0 (Currently used) Global ESLint version: Not found Operating System: win32 10.0.26200

What parser are you using?

Default (Espree)

What did you do?

javascript
/*eslint new-cap: "error"*/

new φ(); // reported
new (); // not reported

Φ(); // reported
(); // not reported

and are Deseret letters (U+10428, U+10400), so each one is a surrogate pair.

What did you expect to happen?

All four calls should be reported.

What actually happened?

  3:5  error  A constructor name should not start with a lowercase letter                                    new-cap
  6:1  error  A function with a name starting with an uppercase letter should only be used as a constructor  new-cap

✖ 2 problems (2 errors, 0 warnings)

Link to Minimal Reproducible Example

https://eslint.org/play/#eyJ0ZXh0IjoiLyplc2xpbnQgbmV3LWNhcDogXCJlcnJvclwiKi9cblxubmV3IM+GKCk7IC8vIHJlcG9ydGVkXG5uZXcg8JCQqCgpOyAvLyBub3QgcmVwb3J0ZWRcblxuzqYoKTsgLy8gcmVwb3J0ZWRcbvCQkIAoKTsgLy8gbm90IHJlcG9ydGVkIiwib3B0aW9ucyI6eyJydWxlcyI6e30sImxhbmd1YWdlT3B0aW9ucyI6eyJlY21hVmVyc2lvbiI6ImxhdGVzdCIsInNvdXJjZVR5cGUiOiJtb2R1bGUifX19

Participation

  • I am willing to submit a pull request for this issue.

AI acknowledgment

  • I did not use AI to generate this issue report.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

Additional comments

getCap() uses str.charAt(0), which returns only the high surrogate (\uD801) for these names, so they end up as "non-alpha":

https://github.com/eslint/eslint/blob/39d79ba9650542ac66d585d1899304abd630c07d/lib/rules/new-cap.js#L141-L155

const [firstChar] = str; would fix it.