-
-
Notifications
You must be signed in to change notification settings - Fork 51
Replaces jshint with eslint #30
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
Conversation
I've add the following two lines to the lint config because I didn't want to mess with the code base too much. "no-control-regex": "off",
"no-prototype-builtins": "off", Ideally these are removed in the future. |
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 added some detailed comments on things I haven't seen in detail before.
Also I'd like to know how you all think about moving away from var
in favour of const
and let
?
.eslintrc
Outdated
"error", | ||
{ | ||
"vars": "all", | ||
"args": "none", |
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 also think we should throw on unused args, at least the jshint did that 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.
Personally don't think we should throw, it should be a warning.
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.
Personally, I'd like to keep it this way. Though an arg may not be used it makes a function a bit more expressive when you can see what is available.
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.
@jwerre I thought this is thrown when an arg is defined but not used in the function body like so:
function dosomething (foo, bar) {
console.log(foo) // bar is defined as arg but never used in the function
}
With eslint replacing jshint, it will close this PR #12 |
This node-oauth2-server/lib/validator/is.js Line 11 in b9aae53
From what I can tell there are no tests for |
I will add the test and push it to this branch |
I actually found a faulty usage of the RegExp 😱 the regex groupings use Fortunately I took a look at. Maybe we should report this to the original project back? |
I updated the validator and it has now 100% coverage plus we test for all unicode charatcer ranges (valid and invalid ones) so there should be no false-positives or false-negatives sneak in anymore. I wonder if this could be considered a security vulnerability? I mean it won't allow code injection (am I right?) but at least it would have allowed invalid characters and depending on where it's used could lead to issues. |
I forgot to mention: the test now takes about I also mostly sticked to ES5 code style, although we could easily support ES6 without any issue (since we don't support these super old node versions, right!?) but I think it's better to have a later PR with update to ES6 or even do it when the time for Typescript comes. |
I mean we can, but as per usual, I guarantee nothing will be done about it. It would be interesting what issues this Regex might raise if used incorrectly. |
@HappyZombies @jankapunkt I think were good to merge here. |
From my end it's good I just wanted to @HappyZombies to take a look since I also worked on the code and hence am biased |
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.
@jwerre I left a comment stating that jshint should be npm uninstalled. Not sure if you missed it or I did this review incorrectly lol
Things look good but I want to do a more thorough review later today. Should have this merged by EOD though 👍 |
I am trying to run the linter but am getting the following error. I am on Windows Node -> v12.16.3 Error below. PS node-oauth2-server> npm run pretest
> @node-oauth/oauth2-server@4.0.0 pretest /node-oauth2-server
> eslint lib test index.js
Oops! Something went wrong! :(
ESLint: 8.0.0
Error: Cannot find module '@eslint/eslintrc/universal'
Require stack:
- node-oauth2-server\node_modules\eslint\lib\linter\linter.js
- node-oauth2-server\node_modules\eslint\lib\linter\index.js
- node-oauth2-server\node_modules\eslint\lib\cli-engine\cli-engine.js
- node-oauth2-server\node_modules\eslint\lib\eslint\eslint.js
- node-oauth2-server\node_modules\eslint\lib\eslint\index.js
- node-oauth2-server\node_modules\eslint\lib\cli.js
- node-oauth2-server\node_modules\eslint\bin\eslint.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
at Function.Module._load (internal/modules/cjs/loader.js:840:27)
at Module.require (internal/modules/cjs/loader.js:1019:19)
at require (node-oauth2-server\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
at Object.<anonymous> (node-oauth2-server\node_modules\eslint\lib\linter\linter.js:27:9)
at Module._compile (node-oauth2-server\node_modules\v8-compile-cache\v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Module.require (internal/modules/cjs/loader.js:1019:19) Is this a Node 12 issue maybe? I will try it again with Node 14 @jwerre any clue? |
hmmm... can you try deleting your node_modules and reinstalling? Also try running |
I did do that, but I will try to delete the entire NPM cache, now I wonder if this a windows issue with version 8 lol. |
Ya, sounds like a windows thing... can you spin up a Docker container? |
Yeah works within Docker...imma make an issue on the ESLint project. I tried searching but get unrelated jest stuff |
Either way I am bit hesitant now to accept it due to there possibly being an issue with Windows -- but I guess that's a risk we can take. |
Oh wait let me try this. Per their docs Prerequisites: Node.js (^12.22.0, ^14.17.0, or >=16.0.0) built with SSL support. (If you are using an official Node.js distribution, SSL is always built in.) I am running on Node v12.16.3 I got sidetracked with the Docker stuff lol. BUT per #34, this means that we need a very specific version of Node now ...and not Node 10 :/ |
Yay version upgrade works! Went on v14.18.1 |
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.
@jwerre left a comment on why no-console is off. Really don't understand why this would need to be off. Could seriously disrupt people who use this, and should be highly discouraged.
Really good catch. Of course we should. |
Replaced jshint with eslint as discussed in #27