Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-anonymous-default-export: Uppercase class name #2282

Merged
Merged
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 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.
Loading