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
WIP: Validate rule options #2179
Changes from all commits
946a1f5
7884c58
cf08971
b9ba185
62237e6
0a59e82
5867baa
fd02595
605736a
ea482b5
6e6c84c
8d33e62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -316,3 +316,5 @@ module.exports = function(context) { | |
}; | ||
|
||
}; | ||
|
||
module.exports.schema = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it be easier to just check if there's a schema, then validate, otherwise skip? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, that's exactly what it does if there's no schema. In this case, the schema specifies that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh.. ok, got it. Thanks. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,3 +86,9 @@ module.exports = function(context) { | |
}; | ||
|
||
}; | ||
|
||
module.exports.schema = [ | ||
{ | ||
"type": "integer" | ||
} | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,3 +71,5 @@ module.exports = function(context) { | |
}; | ||
|
||
}; | ||
|
||
module.exports.schema = []; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,3 +106,9 @@ module.exports = function(context) { | |
}; | ||
|
||
}; | ||
|
||
module.exports.schema = [ | ||
{ | ||
"type": "string" | ||
} | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,3 +62,5 @@ module.exports = function(context) { | |
} | ||
}; | ||
}; | ||
|
||
module.exports.schema = []; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,5 @@ module.exports = function(context) { | |
}; | ||
|
||
}; | ||
|
||
module.exports.schema = []; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,3 +88,9 @@ module.exports = function(context) { | |
}; | ||
|
||
}; | ||
|
||
module.exports.schema = [ | ||
{ | ||
"enum": ["smart", "allow-null"] | ||
} | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,3 +41,5 @@ module.exports = function(context) { | |
} | ||
}; | ||
}; | ||
|
||
module.exports.schema = []; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,3 +68,9 @@ module.exports = function(context) { | |
}; | ||
|
||
}; | ||
|
||
module.exports.schema = [ | ||
{ | ||
"enum": ["start", "middle", "end"] | ||
} | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,3 +41,9 @@ module.exports = function(context) { | |
} | ||
|
||
}; | ||
|
||
module.exports.schema = [ | ||
{ | ||
"enum": ["always", "never"] | ||
} | ||
]; |
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.
I have to debug through the code to be sure, but it feels like you are going to run validations multiple times on the same rule. Once here, and once in eslint.js, and if eslint called programmatically, an extra time in CLI-engine.
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.
Since configs are just simple objects full of name/options pairs, options have to be validated when location information is still available. My first approach was to validate exactly once in
verify
when the final configuration had been determined, but we wanted to be able to print the source of any invalid options, so I moved validation out into the locations you listed.I suppose the alternative approach would be to attach source location metadata to config objects, but that seemed like overkill.
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.
Yes, attaching metadata seems like an overkill.