-
Notifications
You must be signed in to change notification settings - Fork 885
Support disallowing namespaces (noNamespace). #1133
Conversation
} | ||
} | ||
|
||
class NullWalker extends Lint.RuleWalker { |
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.
Can we give this class a more meaningful name, like NoNamespaceWalker
?
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.
Done.
Thanks @mprobst, I like this rule! Makes sense to me to have this rule as more TS codebases will want to enforce ES6 module usage over namespaces. Left you a few tweaks to make, and then we should be able to merge this. Looks like the rule also needs a rebase, a previously merged PR must've created a conflict |
Thanks for the review! Please take another look. |
So, in the mean time I found the I've added that as a separate commit as it makes the configuration a bit harder to understand. Let me know what you think. |
It's a tough call. In my mind:
They're definitely about similar syntaxic elements, but the goals of the two are somewhat different. I'm unsure here about what's best. |
I agree, it's a bit tricky, and I presume it might also be nicer to have just one option going forward ( How do we resolve? Get a third opinion? |
@adidahiya any thoughts? |
@alexeagle knows his way around static analysis tools and might venture an opinion? |
I think tslint lacks a curated default set of checks, in which case things that have been deprecated by the language ( In my opinion, the convenience of |
Makes sense to me. We should be sure that An example of this would be if you had a rule that required explicit typedefs and had a rule that required implicit typedefs. It would be impossible to declare a variable and satisfy both of these rules. I think we'll be fine here, as |
899827a
to
068e7e1
Compare
Agreed, sounds good to me. Please take another look; I've "unmerged" the code, and now just share the implementation of |
Friendly ping :-) |
@@ -44,7 +44,7 @@ class NoInternalModuleWalker extends Lint.RuleWalker { | |||
} | |||
} | |||
|
|||
function isNestedDeclaration(node: ts.ModuleDeclaration) { | |||
export function isNestedDeclaration(node: ts.ModuleDeclaration) { |
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.
Can you instead move this function to src/language/utils
and rename it isNestedModuleDeclaration
? Then we avoid any chance of circular dependencies and keep shared code in a separate location
Sorry for the delay! Can you make the one change listed above and also rebase off the latest develop? (The rebase will help make sure that CI passes) |
This allows code bases to outlaw pre-ES6 modules and namespaces. It's often still useful to declare namespaces when interacting with non-TypeScript code, so this has an option to allow "declare namespace" style usage.
No worries! Refactored and rebased, PTAL. |
Looks great, thank you! |
This allows code bases to outlaw pre-ES6 modules and namespaces. It's often
still useful to declare namespaces when interacting with non-TypeScript code, so
this has an option to allow "declare namespace" style usage.