-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
class-declaration-abstractness-changed #974
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -54,11 +54,17 @@ const classDeclarationTypeChanged: ComparerFactory = (context) => ({ | |||
if (aType === bType) { | ||||
return; | ||||
} | ||||
context.report({ | ||||
key: 'class-declaration-type-changed', | ||||
message: `The ${aType} "${a.getName()}" changed type from ${aType} to ${bType}`, | ||||
element: a | ||||
}); | ||||
|
||||
const isAbstract = (declaration) => declaration.isAbstract(); | ||||
if (isAbstract(a) !== isAbstract(b)) { | ||||
const changeType = isAbstract(a) ? 'abstract to concrete' : 'concrete to abstract'; | ||||
const changeSeverity = isAbstract(a) ? 'minor' : 'major'; | ||||
context.report({ | ||||
key: 'class-declaration-abstractness-changed', | ||||
message: `The class "${a.getName()}" changed from ${changeType} (${changeSeverity} change).`, | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The severity can't simply be expressed in the message but must be defined here:
You'll need to create two different keys: one for abstract to concrete, and one for concrete to abstract. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added the rules, and change the severity to changeKey. |
||||
element: a | ||||
}); | ||||
} | ||||
} | ||||
}); | ||||
|
||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing type-change report shouldn't be removed. Instead, the
if
statement above should be inverted (aType !== bType
or whatever) and the report should be put in there.