-
Notifications
You must be signed in to change notification settings - Fork 889
Cleaner Configuration of Rules #629
Comments
Most importantly, any refactoring here should make rule arguments statically typed in some way. That is, a rule should declare which arguments it knows about, and what type they have. With the current model, it is pretty much impossible to implement, e.g., a GUI that allows configuration of tslint rules. |
@vvakame wondering if you have any feedback regarding this? I know |
You do not have to care! I'll support new tslint.json. |
I think something similar to how ESLint does thing might work well. Here's an example of how a rule declares its configuration schema. |
Proposal for new config schema (taken from #345): I'm thinking about implementing this soon, I like the idea of each rule taking an object as configuration. (This is also very nice code-wise, since rules only accept a boolean or array right now, we can implement this feature with no backwards-compat breakage.) I like a format similar to what's specified above:
Open questions:
I also like how this proposal makes it easy to add in additional options for things like auto-fixing, as mentioned above. This would probable be implemented in two steps:
|
Agreed. The number system is pretty unclear at first glance, let's not go down that road with TSLint |
I'm still not entirely sure what |
The idea was that in the future you could set a default level, and anything that was |
I started work on this. Interested in any feedback. I am working over here - https://github.com/olore/tslint/tree/enhanced-config-options
I have a few questions -
|
I think we should consider not putting the mode inside of each rule, but have blocks of rules with their own custom configurations. Since there's a need for exclude globs (#73) and we now have
It's easier to move rules between these rule sets than changing "warning" to "error", for each rule you want to change. You can configure any number of these custom rule sets that can apply different rules to different sets of files. Plus it's easily backwards compatible since nothing inside |
@nchen63, thanks for the thoughts. I like the ability to group the rules by level, I'll see how I can incorporate that somehow. It's definitely repetitive right now. After taking a peek at ESLint and reading through #73, namely @jkillian's #73 (comment) am in the camp that thinks tslint.json should only define the how, not the what to lint. #73 doesn't convince me of the importance of implementing an ignore/globbing feature into tslint.json. |
+1, I am also in this camp |
@jkillian The lack of severity support is adds difficulty to advocating for TypeScript within my teams. Thank you! |
There are currently a few different possible levels of complexity of options for rules:
no-debugger
)check-whitespace
, each option indicates whether something should be checked or not)max-line-length
)ban
)The current Boolean/Array paradigm of declaring options only supports the first two of this optimally. It also is functional for the third option, but doesn't really model it well. It's not ideal at all for the fourth case.
There are more and more feature requests which require a more descriptive way to list options (#562 and #522), and it makes sense to have a system that better facilitates rules like this.
Any thoughts on how we should do this?
The text was updated successfully, but these errors were encountered: