-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
add no-dupe-class-members rule #82
base: master
Are you sure you want to change the base?
Conversation
Doesn't this have to account for typescript overloading? |
That's right. Sorry I wasn't even considering TypeScript support, I'll fix that |
Don't forget to run |
} | ||
} | ||
|
||
fn check<T: Named>(code: &str, ctx: &mut RuleCtx, nodes: Vec<T>) -> Option<Diagnostic> { |
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.
fn check<T: Named>(code: &str, ctx: &mut RuleCtx, nodes: Vec<T>) -> Option<Diagnostic> { | |
fn check(code: &str, ctx: &mut RuleCtx, nodes: Vec<impl Named>) -> Option<Diagnostic> { |
} | ||
if let Some(prev_decl) = names.insert(name.clone(), n.name_node()) { | ||
let err = ctx | ||
.err(code, format!("Duplicate name '{}'", name)) |
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.
.err(code, format!("Duplicate name '{}'", name)) | |
.err(code, format!("Duplicate name `{}`", name)) |
We use backticks for code/names in the project usually, so this should be consistent too
.err(code, format!("Duplicate name '{}'", name)) | ||
.secondary( | ||
prev_decl, | ||
format!("Previous declaration of the method '{}' here", &name), |
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.
format!("Previous declaration of the method '{}' here", &name), | |
format!("Previous declaration of the method `{}` is here", &name), |
See above
prev_decl, | ||
format!("Previous declaration of the method '{}' here", &name), | ||
) | ||
.primary(n.name_node(), format!("'{}' redefined here", name)); |
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.
.primary(n.name_node(), format!("'{}' redefined here", name)); | |
.primary(n.name_node(), format!("`{}` is redefined here", name)); |
See above
It does not handle class properties, and I'm not sure if it should. Looks like typescript-lint doesn't handle it either. |
I think it should considering class fields are supported by default in the parser under ts syntax, and in the future i'll allow it in js files with a config flag too |
@@ -32,4 +32,5 @@ group! { | |||
valid_typeof::ValidTypeof, | |||
no_extra_boolean_cast::NoExtraBooleanCast, | |||
no_confusing_arrow::NoConfusingArrow, | |||
no_dupe_class_members::NoDupeClassMembers |
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.
Now that I see the list of rules here, I think it would be pretty nice to sort them in alphabetic order.
Checklist