Skip to content

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

Merged
merged 11 commits into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"extends": "eslint:recommended",
"env": {
"node": true,
"mocha": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"ecmaFeatures" : {
"globalReturn": false,
"impliedStrict": true,
"jsx": false
}
},
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"no-console": [
"error"
],
"no-unused-vars": [
"error",
{
"vars": "all",
"args": "none",
"ignoreRestSiblings": false
}
]
}
}

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ npm-debug.log*~
auto-save-list
tramp
.\#*
.vscode

# Org-mode
.org-id-locations
Expand Down
1 change: 0 additions & 1 deletion .jshintignore

This file was deleted.

26 changes: 0 additions & 26 deletions .jshintrc

This file was deleted.

24 changes: 12 additions & 12 deletions lib/grant-types/authorization-code-grant-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,21 @@ AuthorizationCodeGrantType.prototype.getAuthorizationCode = function(request, cl
* @see https://tools.ietf.org/html/rfc6749#section-4.1.3
*/

AuthorizationCodeGrantType.prototype.validateRedirectUri = function(request, code) {
if (!code.redirectUri) {
return;
}
AuthorizationCodeGrantType.prototype.validateRedirectUri = function(request, code) {
if (!code.redirectUri) {
return;
}

var redirectUri = request.body.redirect_uri || request.query.redirect_uri;
var redirectUri = request.body.redirect_uri || request.query.redirect_uri;

if (!is.uri(redirectUri)) {
throw new InvalidRequestError('Invalid request: `redirect_uri` is not a valid URI');
}
if (!is.uri(redirectUri)) {
throw new InvalidRequestError('Invalid request: `redirect_uri` is not a valid URI');
}

if (redirectUri !== code.redirectUri) {
throw new InvalidRequestError('Invalid request: `redirect_uri` is invalid');
}
};
if (redirectUri !== code.redirectUri) {
throw new InvalidRequestError('Invalid request: `redirect_uri` is invalid');
}
};

/**
* Revoke the authorization code.
Expand Down
2 changes: 1 addition & 1 deletion lib/models/token-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function TokenModel(data, options) {
this.customAttributes = {};

for (var key in data) {
if (data.hasOwnProperty(key) && (modelAttributes.indexOf(key) < 0)) {
if ( Object.prototype.hasOwnProperty.call(data, key) && (modelAttributes.indexOf(key) < 0)) {
this.customAttributes[key] = data[key];
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/token-types/bearer-token-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ BearerTokenType.prototype.valueOf = function() {
}

for (var key in this.customAttributes) {
if (this.customAttributes.hasOwnProperty(key)) {
if ( Object.prototype.hasOwnProperty.call(this.customAttributes, key) ) {
object[key] = this.customAttributes[key];
}
}
Expand Down
19 changes: 14 additions & 5 deletions lib/validator/is.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
'use strict';
/* eslint-disable no-control-regex */

/**
* Validation rules.
*/

var rules = {
NCHAR: /^[\u002D|\u002E|\u005F|\w]+$/,
NQCHAR: /^[\u0021|\u0023-\u005B|\u005D-\u007E]+$/,
NQSCHAR: /^[\u0020-\u0021|\u0023-\u005B|\u005D-\u007E]+$/,
UNICODECHARNOCRLF: /^[\u0009|\u0020-\u007E|\u0080-\uD7FF|\uE000-\uFFFD|\u10000-\u10FFFF]+$/,
NCHAR: /^[\u002D\u002E\u005F\w]+$/,
NQCHAR: /^[\u0021\u0023-\u005B\u005D-\u007E]+$/,
NQSCHAR: /^[\u0020-\u0021\u0023-\u005B\u005D-\u007E]+$/,
UNICODECHARNOCRLF: /^[\u0009\u0020-\u007E\u0080-\uD7FF\uE000-\uFFFD]+$/,
UNICODECHARNOCRLF_EXTENDED: /^[\u{10000}-\u{10FFFF}]+$/u,
URI: /^[a-zA-Z][a-zA-Z0-9+.-]+:/,
VSCHAR: /^[\u0020-\u007E]+$/
};

/* eslint-enable no-control-regex */

/**
* Export validation functions.
*/
Expand Down Expand Up @@ -57,7 +61,12 @@ module.exports = {
*/

uchar: function(value) {
return rules.UNICODECHARNOCRLF.test(value);
// manually test \u10000-\u10FFFF
if (rules.UNICODECHARNOCRLF.test(value)) {
return true;
}

return rules.UNICODECHARNOCRLF_EXTENDED.test(value);
},

/**
Expand Down
Loading