Skip to content

Commit

Permalink
no-anonymous-default-export: Uppercase class name (#2282)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker authored Feb 19, 2024
1 parent 366ecf9 commit 5ce4169
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion rules/no-anonymous-default-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function getSuggestionName(node, filename, sourceCode) {
return;
}

name = node.type === 'ClassDeclaration' ? upperFirst(name) : name;
name = node.type === 'ClassDeclaration' || node.type === 'ClassExpression' ? upperFirst(name) : name;
name = avoidCapture(name, getScopes(sourceCode.getScope(node)));

return name;
Expand Down
20 changes: 10 additions & 10 deletions test/snapshots/no-anonymous-default-export.mjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,9 @@ Generated by [AVA](https://avajs.dev).
| ^^^^^ The class should be named.␊
--------------------------------------------------------------------------------␊
Suggestion 1/1: Name it as \`foo__\`.␊
Suggestion 1/1: Name it as \`Foo__\`.␊
1 | let Foo, Foo_, foo, foo_␊
2 | export default (class foo__{})␊
2 | export default (class Foo__{})␊
`

## invalid(24): export default (class extends class {} {})
Expand All @@ -532,8 +532,8 @@ Generated by [AVA](https://avajs.dev).
| ^^^^^^^^^^^^^^^^^^^^^^ The class should be named.␊
--------------------------------------------------------------------------------␊
Suggestion 1/1: Name it as \`foo\`.␊
1 | export default (class foo extends class {} {})␊
Suggestion 1/1: Name it as \`Foo\`.␊
1 | export default (class Foo extends class {} {})␊
`

## invalid(25): let Exports, Exports_, exports, exports_ exports = class {}
Expand All @@ -559,9 +559,9 @@ Generated by [AVA](https://avajs.dev).
| ^^^^^ The class should be named.␊
--------------------------------------------------------------------------------␊
Suggestion 1/1: Name it as \`exports__\`.␊
Suggestion 1/1: Name it as \`Exports__\`.␊
1 | let Exports, Exports_, exports, exports_␊
2 | exports = class exports__ {}␊
2 | exports = class Exports__ {}␊
`

## invalid(26): module.exports = class {}
Expand All @@ -585,8 +585,8 @@ Generated by [AVA](https://avajs.dev).
| ^^^^^ The class should be named.␊
--------------------------------------------------------------------------------␊
Suggestion 1/1: Name it as \`module_\`.␊
1 | module.exports = class module_ {}␊
Suggestion 1/1: Name it as \`Module\`.␊
1 | module.exports = class Module {}␊
`

## invalid(27): export default function () {}
Expand Down Expand Up @@ -1405,8 +1405,8 @@ Generated by [AVA](https://avajs.dev).
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The class should be named.␊
--------------------------------------------------------------------------------␊
Suggestion 1/1: Name it as \`foo\`.␊
1 | module.exports = @decorator(class {}) class foo extends class {} {}␊
Suggestion 1/1: Name it as \`Foo\`.␊
1 | module.exports = @decorator(class {}) class Foo extends class {} {}␊
`

## invalid(4): @decorator @decorator(class {}) export default class {}
Expand Down
Binary file modified test/snapshots/no-anonymous-default-export.mjs.snap
Binary file not shown.

0 comments on commit 5ce4169

Please sign in to comment.