-
Notifications
You must be signed in to change notification settings - Fork 510
Add ability to declare acceptable values for the rules #895
Comments
It can be replaced with a Also one rule could handle several rules and values. And also one rule could have aliases (for modern configuration). But fully declarative version (yours) will also be good. |
As I can remember, @mikesherov wanted to do something about it. |
Yeah, i remember something like that, although no one responded when i repeatedly ask about this, hence the ticket |
Looks good and manageable. Nice work, Oleg. Who will implement the validation using this? I can help port some rules We just have to make sure no rule currently overrides this.values in its
|
Whoever is capable and have time to do this :-), after 1.10 my next item is jquery tasks, there is a lot them accumulated out there.
That is my thought exactly. |
I think I still have an open issue about this somewhere... My thoughts were to make rule values declarative rather than having functions. This would also make documentation auto generate able. |
We can try to use here https://github.com/molnarg/js-schema/ or analogue. But it's 24Kb. Probably we can find more lighten solution. |
Came across
|
Some stuff on a declarative format: values: [
// true,
// number,
// string
// one of the strings in an array
// object with properties 'beforeOpeningRoundBrace' and 'beforeOpeningCurlyBrace' which are both true
];
// markelog's original one
values: [{
type: "boolean",
value: true
}, {
type: "number" // maybe no value?
}, {
type: "string"
}, {
type: "string",
value: ['a', 'b', 'c']
}, {
type: "object",
value: [ // not sure how this would work
{
type: "string",
value: "beforeOpeningCurlyBrace"
},
{
type: "string",
value: "beforeOpeningRoundBrace"
},
]
}, ];
// use constructor functions? (js-schema)
values: [
true,
Number,
['a', 'b', 'c'],
{
beforeOpeningCurlyBrace: [String]
beforeOpeningRoundBrace: [String]
}
];
// react type (namespaces to represent things)
values: [
Types.true,
Types.number,
Types.oneOf(['a', 'b', 'c']),
Types.object({
beforeOpeningCurlyBrace: Types.arrayOf(Types.String)
beforeOpeningRoundBrace: Types.arrayOf(Types.String)
})
]; I do like the 2nd one if something like that is possible? |
Nice stuff. Thanks! ;-) About 2nd one: https://github.com/molnarg/js-schema/ — 25Kb, can be used in browser. Is it fine for us? |
Looks like ESLint has an issue about notifying on config options using a declarative approach too! There's also https://github.com/mafintosh/is-my-json-valid and https://github.com/hapijs/joi. |
Do we know if we're going to use another tool to validate or make our own? |
Looking to use one of the suggested tools. The proposed schema would change
|
What options do we have on the table? |
I've been looking at the ones suggested in this thread mostly. @hzoo's suggestion of https://github.com/mafintosh/is-my-json-valid feels like the best one so far. I'm in the middle of a prototype with it, so no guarantees that it'll work just yet. |
Yeah that's the one ESLint is planning on using as well - eslint/eslint#2179 |
Now this responsibility falls on the
configure
method, but it would much easier if this method would be replaced by some declaration like:we couldn't fully dispose from the
configure
method, but it will simplify a lot of things/cc @mdevils
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: