| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for starting the work! Left some minor feedback and please see the other PR re: the need for tests.
Sorry, something went wrong.
| fix: (fixer) => { | ||
| return fixer.insertTextAfter( | ||
| node, | ||
| '\n\nif (!common.hasCrypto)\n\tcommon.skip("missing crypto");' |
There was a problem hiding this comment.
What does the node refer to in this context? This should be getting inserted right after common is required rather than somewhere random.
Also, the project doesn't use tabs but rather spaces so \t should be a double space.
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for the comments. Working on commit to fix.
Sorry, something went wrong.
There was a problem hiding this comment.
I've pushed the changes. Also please note that I've added a regExp in rules-utils.js, please verify the validity of the same, or suggest if there are any better ways of doing that.
The reason for doing this was because the common module was addressed with different relative paths, such as ../../common or ../common.
Sorry, something went wrong.
|
Thanks for the updates! I'll be happy to review again once we have the tests for all of these fixers, just so we can be sure that they're working properly (it's a bit hard to tell without actually running the code). |
Sorry, something went wrong.
There was a problem hiding this comment.
Need help here @apapirovski . commonModuleNode comes as null here when running make -j4 test. I'm setting commonModuleNode in testCryptoUsage method.
PS: This works fine when running eslint with --fix to fix a generated error.
Sorry, something went wrong.
There was a problem hiding this comment.
Ping @apapirovski
Sorry, something went wrong.
There was a problem hiding this comment.
This description is not entirely accurate. The given node must be a call to require, it does not work for nodes which contain such a call.
Sorry, something went wrong.
There was a problem hiding this comment.
@tniessen Please check now. Suggest if any corrections.
Sorry, something went wrong.
|
Much like with the other PR:
Sorry @shobhitchittora. |
Sorry, something went wrong.
|
@BridgeAR What are your views on landing this? |
Sorry, something went wrong.
There was a problem hiding this comment.
I personally do not see as much concern as @apapirovski here as these rules are only active for our tests and we should realize if something goes wrong. The latest in the code review.
Sorry, something went wrong.
There was a problem hiding this comment.
Why do you not write the RegExp directly? There is no dynamic part as far as I see it.
So /^(\.\.\/)*common(\.js)?$/ does the job and can be moved outside of the function. That way it is only created once.
Sorry, something went wrong.
There was a problem hiding this comment.
done.
Sorry, something went wrong.
|
@BridgeAR would you be so kind and run CI for this too? |
Sorry, something went wrong.
There was a problem hiding this comment.
Does this (and other occurences below) pass the test? I think the 'missing crypto' message is missing.
Sorry, something went wrong.
There was a problem hiding this comment.
Added the string 'missing crypto' in tests. But there's still something wrong. Any help?
Sorry, something went wrong.
There was a problem hiding this comment.
Done now.
Sorry, something went wrong.
|
@shobhitchittora this has similar issues as the other PRs. Please run the tests by calling make -j4 test. You can also run the individual test by running python ./tools/test.py parallel/test-eslint-crypto-check. |
Sorry, something went wrong.
|
You can also run the linter only with make lint-js |
Sorry, something went wrong.
|
@BridgeAR I cannot spot the diff when running python ./tools/test.py parallel/test-eslint-crypto-check fails. Just getting this - === release test-eslint-crypto-check === Path: parallel/test-eslint-crypto-check assert.js:43 throw new errors.AssertionError(obj); ^ AssertionError [ERR_ASSERTION]: Output is incorrect. [00:00|% 100|+ 0|- 1]: Done Any suggestions? Can you spot the error? |
Sorry, something went wrong.
There was a problem hiding this comment.
lgtm.
Sorry, something went wrong.
There was a problem hiding this comment.
Nit: unnecessary change.
Sorry, something went wrong.
There was a problem hiding this comment.
This can not be the proper output because there is no common imported in the code.
Sorry, something went wrong.
There was a problem hiding this comment.
This can not be the expected output because common is not imported. But not only that, the first statement if (common.foo) {} was just removed? That is definitely not right.
Sorry, something went wrong.
|
@shobhitchittora please rebase and run the code again. In that case the output is going to show what check failed. Please carefully check what change you expect and what not with what input. Please add another test with a case where common is actually imported in the checked code part. |
Sorry, something went wrong.
1. Fixer for crypto-check.js 2. extends tests Refs : nodejs#16636
Removes unwanted indentation Refs : nodejs#16636
Adds check for fixing on when require('common') is present.
Refs : nodejs#16636
Adds "missing crypto" message in tests. Refs : nodejs#16636
1. Refactors test 2. Removes commonModule AST node as array. Refs : nodejs#16636
Review comments + updates test cases Refs : nodejs#16636
There was a problem hiding this comment.
Working tests now. Please check.
Sorry, something went wrong.
There was a problem hiding this comment.
Done now.
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM with the comment addressed and a green CI.
Sorry, something went wrong.
| var commonModuleRegExp = new RegExp(/^(\.\.\/)*common(\.js)?$/); | ||
| module.exports.isCommonModule = function(node) { | ||
| return node.callee.name === 'require' && | ||
| commonModuleRegExp.test(node.arguments[0].value); |
There was a problem hiding this comment.
This will produce access errors due to accessing nodes without arguments. Please guard against them the same as I suggested in the other PR.
Sorry, something went wrong.
Sorry, something went wrong.
|
Seems like there are linting errors. |
Sorry, something went wrong.
Removes extra spaces ( lint-error ) + rules-utils argument check suggestoin Refs : nodejs#16636
Sorry, something went wrong.
1. Fixer for crypto-check.js 2. Extends tests PR-URL: nodejs#16647 Refs: nodejs#16636 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
|
Landed in f242d4b 🎉 @shobhitchittora thanks for being patient :-) |
Sorry, something went wrong.
1. Fixer for crypto-check.js 2. Extends tests PR-URL: nodejs#16647 Refs: nodejs#16636 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
| Back | FazBrowse Home | New Git URL |
This implements an eslint fixer function to auto insert common.hasCryto check if missed out.
Refs: #16636
Checklist
Affected core subsystem(s)
Tools