-
Notifications
You must be signed in to change notification settings - Fork 4
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 lexical validation for variable not present #5
Add lexical validation for variable not present #5
Conversation
test/syntax.js
Outdated
expect(validateExp('y<!2', scope)).to.deep.equal(["y variable not present", "cannot eval '!2' as value"]); | ||
}) | ||
|
||
it('should validate complex expression', function () { |
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.
what about checking that y is present and all..?
src/syntax.js
Outdated
@@ -2,6 +2,8 @@ const operators = require('./operators.js')(isTruthy) | |||
const lexical = require('./lexical.js') | |||
const assert = require('../src/util/assert.js') | |||
|
|||
const listOfOperators= ["=","!", "<", ">", "contains", "and", "or" ] |
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.
this is already defined as lexical.operators
also seems unused
for (var i = 0; i < operatorREs.length; i++) { | ||
var operatorRE = operatorREs[i] | ||
var expRE = new RegExp(`^(${lexical.quoteBalanced.source})(${operatorRE.source})(${lexical.quoteBalanced.source})$`) | ||
if ((match = exp.match(expRE))) { |
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.
can u autoformat this new code only?
like theres double ((
here for no reason
var match; | ||
for (var i = 0; i < operatorREs.length; i++) { | ||
var operatorRE = operatorREs[i] | ||
var expRE = new RegExp(`^(${lexical.quoteBalanced.source})(${operatorRE.source})(${lexical.quoteBalanced.source})$`) |
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.
cant use template strings - this does not go through a transpiler
if(scope.get(str) !== undefined && scope.get(str) !== null) { | ||
return; | ||
} else { | ||
return `${str} variable not present` |
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.
don't use template strings?
i am not sure if they are safe. if we were using them before then you can keep them
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, we were using template strings in this module before.
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.
OK LGTM format if possible
No description provided.