-
Notifications
You must be signed in to change notification settings - Fork 510
New format attempt #698
Comments
A couple of questions we must answer:
|
curlyBraces: {
require: false,
disallow: false
}
What ticket number are we talking about? |
is it #516? Auto formatting API |
Is
the same as
#341 ? |
Ok good point - I don't think so. Auto formatting seems to mean it will actually correct the code style errors of rules already specified/known. Automatic configuration is changing the jscsrc file to match a specified file or determine code style rules automatically? |
Correct |
Yes, #341. |
Nice work, Oleg. How are you going to map the configuration items to the existing rules? The current way is nice because we rely on the user to indicate the rules to use. Is the plan to change the returned value from each rule's A few nitpicks: https://gist.github.com/markelog/752e53faf9f27de4024d#file-gistfile1-js-L15
https://gist.github.com/markelog/752e53faf9f27de4024d#file-gistfile1-js-L45 To keep with the style, maybe |
Btw It would be great to use in plugins. |
@zxqfox How would that help plugins? Can you elaborate? |
More questions:
|
Just a thought... Instead of
Which doesn't seem to allow for "require spaces around only + but disallow spaces around all except - ", we do:
Which would cover "require spaces around only + but disallow spaces around all except - " as follows:
|
Sounds reasonable.
Fixed
We don't have module for it yet, i suppose we could only guess, but i don't see problems with this ticket with any config style we choose.
Your idea looks better: {
require: true || { except|only: [] },
disallow: true || { except|only: [] }
}
Didn't get to that part yet, requires more thought i guess. One way or another it would be sane to have no more than two levels of nesting objects, like this: "function": {
"spacesInFunction": {
"anonymousExpression": {
...
}
...
},
"validate": {
"argumentSeparator": ...
}
} Would be overdoing it i guess. |
In common: {
"category": {
"rule": {
"require": true || { "allExcept|only": [] },
"disallow": true || { "allExcept|only": [] }
}
}
} But once again, I'm stuck in mapping these declarations to rules. |
Let's decide on format first, there is a lot of grey areas we need to cover first. |
@mrjoelkemp Some thoughts about plugins.
Finally I have a lot of my own thoughts (partially realized in jscs-jsdoc) but each of them very variative. So I think configuration format topic is very close to plugins because of configuration-rules mapping. p.s. I ❤️ new format at all. |
@markelog It's like you giving scissors to kids. Rules and plugins shouldn't be developed by someone who doesn't know how to do it right. This nesting could be very useful for plugins, but I agree that 3-rd level of nesting should be used very-very rarely or never. |
- add validation of allExcept (should be a <String[]>) - remove required - rename except to allExcept (according to jscs-dev#698) - fix docs
- add comment about deprecation allowSlash with link to an issue - add validation of allExcept (should be a <String[]>, according to jscs-dev#698)
according to jscs-dev#592 and jscs-dev#593 we've decided to make allExcept option to this rule to pass there a list of allowed characters - added allExcept option to pass here exceptions - fixes initial jscs-dev#592 bug with tabs in line comments - add validation of allExcept (should be a <String[]>, according to jscs-dev#698) Closes jscs-dev#696 Fixes jscs-dev#592
to all: there is a lot of rules to adopt for this config, we also need identify rules that we would move to the plugin i.e. rules that could not be used in any of supported presets and those rules that could not be easily included in any category (first level). So if you have time, please go ahead and add rest of the rules to the new format, i will update the gist with our new ideas shortly. |
We discussed this approach with Oleg earlier and I like it.
|
Format updated, stopped at |
Yeah, maybe In some ways but i'm trying to take best ideas from all purposed formats.
It could be handled on engine level, if, for example, there both If you have time to add more rules to the gist above or provide more constructive critic - that would be much appreciated. |
Keep in mind conflicting rules aren't always conflicting. I could require space between Although, if there is a rule that should be only require XOR disallow, we could enforce that at engine level, as @markelog described. |
Sorry if this is coming off as non-constructive, but I was just trying to flag that the nature of the format has some issues as raised in #698 (comment) |
Bad idea. It's better to go Presets and additional rules (I believe) perfectly works when provided by plugins. I would not like to allow specifying preset as an NPM-module name. That's plugins are made for. |
Plugins could express both |
Couple new rules, fixes, comments, stopped at |
I propose to have some config proxy because of a big lag between this research and v2.0. What if we will try to load configuration with a new way and convert to current naming if it has |
@zxqfox Sounds interesting, but can you supply an example of the |
Oh. ;-) I'm talking about @markelog's gist: https://gist.github.com/markelog/752e53faf9f27de4024d#file-gistfile1-js-L7 The current And the cli option can be simply p.s. I'm also thinking about different inline disables. This converter also could help users to convert v1 disables to v2. |
@markelog https://gist.github.com/markelog/752e53faf9f27de4024d#file-gistfile1-js-L89 btw. |
Hm.. Maybe keep using We could also support boolean values for the common/simple use case of only requiring and disallowing rules. E.g. {
"blocks": {
"curlyBraces": true,
"newlineBefore": false,
"paddingNewlines": null
}
} Though it may not be obvious whether {
"blocks": {
"curlyBraces": "require",
"newlineBefore": "disallow",
"paddingNewlines": null
}
} |
@Krinkle Yeah, I've thought about it too. Like these booleans usage. It's pretty intuitive. |
For new/modified rules now, is it still
because some rules like requireSpacesInsideParentheses are using
|
Just wanted to drop a note that the "2-level" approach to configuration here means:
I'm not sure again as to the benefit of having 2 levels for rules. It introduces the question of what belongs in the top level vs. the bottom level. If the options are all normalized, simplified (meaning combining beforeAndAfter and require/disallow) and some names shortened, 1 level looks fine too IMO:
Just something to consider. |
I think we're at the point of prototyping this thing, i'm sure will find more caveats along the way or possible improvements. |
A bit of discussion on this issue going on in Gitter: https://gitter.im/jscs-dev/node-jscs?at=55566279811d64626eebcb40. We're torn between forcing users to change their configuration in 2.0 versus having an internal conversion proxy to allow users to not have to change their config. |
For this issue to resolve i think we need to:
Only last item is a breaking change. |
In other words, is there any takers for the proposed items? |
Yes, I'm looking at #895. |
WIP
Related to #136
This is what i got so far - https://gist.github.com/markelog/752e53faf9f27de4024d
/cc @mikesherov @mdevils @mrjoelkemp @nschonni
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: