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
add dict-string-keys
rule
#10107
add dict-string-keys
rule
#10107
Conversation
return; | ||
} | ||
|
||
arg1.properties.forEach(function(prop) { |
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.
Could you make this recurse if the value is also an object literal?
Basically:
If value is object literal, also check that all its keys are literals.
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.
doh, yeah forgot about that
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.
@cramforce done. unfortunately if the the value is a reference (Identifier
node) i can't really look it up and recursively check the reference (if its an array or object and its values/keys)
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.
That is fine.
} | ||
|
||
arg1.properties.forEach(function(prop) { | ||
if (!prop.key.raw) { |
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.
Raw stands for literal?
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.
if the Key
Node has a "raw" property then it is a string literal (value will be the quoted string), else it will have a name
property
enforces that the keys of the object passed into `dict` has to be strings and should be quoted.
0378cae
to
77faece
Compare
We enforce via the linter (ampproject#10107) that arguments to `dict` are object literals. So, there is no need to copy. Part of ampproject#9876
enforces that the keys of the object passed into
dict
has to bestrings and should be quoted.
Fixes #10094