Skip to content

Commit

Permalink
fix(file-name-matches-element): respect 'none' case type (#127)
Browse files Browse the repository at this point in the history
We forgot to implement `none` as a case type/transform in the
file-name-matches-element rule. It is basically a pass-through
transform, i.e. the name of the class should be exactly the name of the
file.

Fixes #126
  • Loading branch information
43081j authored Sep 22, 2023
1 parent 18edd72 commit d9f7aba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/test/rules/file-name-matches-element_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,15 @@ ruleTester.run('file-name-matches-element', rule, {
suffix: 'Bar'
}
]
},
{
code: 'class SomeElement extends HTMLElement {}',
filename: 'SomeElement.js',
options: [
{
transform: 'none'
}
]
}
],

Expand Down
4 changes: 3 additions & 1 deletion src/util/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function toCamelCase(str: string): string {
*/
export function toCaseByType(
str: string,
type: 'kebab' | 'camel' | 'snake' | 'pascal'
type: 'kebab' | 'camel' | 'snake' | 'pascal' | 'none'
): string {
switch (type) {
case 'kebab':
Expand All @@ -65,5 +65,7 @@ export function toCaseByType(
return toSnakeCase(str);
case 'pascal':
return toPascalCase(str);
case 'none':
return str;
}
}

0 comments on commit d9f7aba

Please sign in to comment.