"Invalid component name" error when creating a Lightning Web Component from IE in Webstorm

Issue #1875 resolved
Riadh Mankai created an issue

When creating a LWC, any component name I enter seems to be invalid and it’s impossible to create a component! I tried with and without a class name, I even tried to leave everything to default, and I still face the same issue.

Comments (3)

  1. Scott Wells repo owner

    LWC component names must begin with a leading lower-cased character. You can find more here:

    https://developer.salesforce.com/docs/component-library/documentation/en/lwc/create_components_folder

    but the key aspects are:

    The folder and its files must have the same name, including capitalization and underscores.

    The folder and its files must follow these naming rules.

    • Must begin with a lowercase letter
    • Must contain only alphanumeric or underscore characters
    • Must be unique in the namespace
    • Can’t include whitespace
    • Can’t end with an underscore
    • Can’t contain two consecutive underscores
    • Can’t contain a hyphen (dash)

    The IDE enforces those naming conventions in the new component dialog. Please let me know if you've found Salesforce's documentation to be incorrect/stale and such a component name is in fact valid.

  2. Scott Wells repo owner

    Resolving this since it appears to be working as designed. If it turns out these validation rules are incorrect and are rejecting what should be valid input, please feel free to reopen with full details and I'll consult with Salesforce as to these exceptions to their documentation.

  3. Riadh Mankai reporter

    Thanks Scott, my bad. Just starting to play around with these LWC and didn’t realize the naming convention was enforced. It would be nice for the error message in IC to provide the details rather than a generic error “Invalid Component name”. A nice to have obviously, not critical at all.

  4. Log in to comment