Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/utils/identifierMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function snakeCase(
// If underScoreBeforeDigits is true then, well, insert an underscore
// before digits :). Only the first digit gets an underscore if
// there are multiple.
if (underscoreBeforeDigits && isDigit(char) && !isDigit(prevChar)) {
if (underscoreBeforeDigits && isDigit(char) && !isDigit(prevChar) && prevChar !== '_') {
out += '_' + char;
continue;
}
Expand Down
1 change: 1 addition & 0 deletions tests/unit/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ describe('utils', () => {
testUnderscoreBeforeNumbers('fööBäR', 'föö_bä_r');

testUnderscoreBeforeNumbers('foo1bar2', 'foo_1bar_2');
testUnderscoreBeforeNumbers('foo_1bar_2', 'foo_1bar_2', 'foo1bar2');
testUnderscoreBeforeNumbers('Foo', 'foo', 'foo');
testUnderscoreBeforeNumbers('FooBar', 'foo_bar', 'fooBar');
testUnderscoreBeforeNumbers('märkäLänttiÄäliö', 'märkä_läntti_ääliö');
Expand Down