Skip to content

Extract rule: template-modifier-name-case#2452

Merged
NullVoxPopuli merged 3 commits intoember-cli:masterfrom
NullVoxPopuli:nvp/template-lint-extract-rule-template-modifier-name-case
Mar 13, 2026
Merged

Extract rule: template-modifier-name-case#2452
NullVoxPopuli merged 3 commits intoember-cli:masterfrom
NullVoxPopuli:nvp/template-lint-extract-rule-template-modifier-name-case

Conversation

@NullVoxPopuli
Copy link
Copy Markdown
Contributor

Split from #2371.

@NullVoxPopuli NullVoxPopuli force-pushed the nvp/template-lint-extract-rule-template-modifier-name-case branch 3 times, most recently from 5b47d3a to 7ff4e6c Compare March 10, 2026 22:24
@johanrd
Copy link
Copy Markdown
Contributor

johanrd commented Mar 12, 2026

Review from claude: comparing against ember-template-lint modifier-name-case

dasherize is buggy for leading-capital and consecutive-capital names. The PR's implementation blindly prepends - before every uppercase letter:

str.replaceAll(/([A-Z])/g, '-$1').toLowerCase()

The original has guards for index 0 and non-alpha preceding chars:

// index === 0 or previous char is not a letter → just lowercase, no dash
if (index === 0 || !ALPHA.test(key[index - 1])) {
  return char.toLowerCase();
}
return `-${char.toLowerCase()}`;

Results:

Input Original PR
FooBar foo-bar -foo-bar
XFoo x-foo -x-foo
HTMLParser htmlparser -h-t-m-l-parser

The current test cases all use lowercase-initial camelCase (didInsert, fooBar) so the bug doesn't surface. It would break any PascalCase or acronym-prefixed modifier name. The original also handles ::
/ for namespaced paths (e.g. Foo::BarBazfoo/bar-baz).

Fix: port the original's dasherize-component-name helper, or at minimum add the index-0 and consecutive-capital guards.

Unused broken messageId. meta.messages.dasherized uses {{dasherizeModifierName}} for both the before and after placeholders — it would render the same value twice. It's never actually used (the rule
builds messages via generateErrorMessage inline). Either fix the template to use distinct placeholders and switch to messageId, or remove it.

@NullVoxPopuli NullVoxPopuli force-pushed the nvp/template-lint-extract-rule-template-modifier-name-case branch from 7ff4e6c to b3991f2 Compare March 13, 2026 18:37
@NullVoxPopuli NullVoxPopuli merged commit f71806b into ember-cli:master Mar 13, 2026
9 checks passed
@NullVoxPopuli NullVoxPopuli deleted the nvp/template-lint-extract-rule-template-modifier-name-case branch March 13, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants