Skip to content

Commit

Permalink
Add lwc/consistent-component-name support for .ts files (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
twoplustwoone authored Jan 2, 2023
1 parent a8c8872 commit efb4490
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/consistent-component-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
const fileName = context.getFilename();
const sourceCode = context.getSourceCode();

const fileBasename = path.basename(fileName, '.js');
const fileBasename = path.basename(fileName, path.extname(fileName));
const expectComponentName = fileBasename.charAt(0).toUpperCase() + fileBasename.slice(1);

return {
Expand Down
11 changes: 11 additions & 0 deletions test/lib/rules/consistent-component-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ ruleTester.run('consistent-class-name', rule, {
code: `export class ComplexName extends LightningElement {}`,
filename: 'complexName.js',
},
{
code: `
import { LightningElement } from 'lwc';
export class Foo extends LightningElement {}
`,
filename: 'foo.ts',
},
{
code: `export class ComplexName extends LightningElement {}`,
filename: 'complexName.ts',
},
],
invalid: [
{
Expand Down

0 comments on commit efb4490

Please sign in to comment.