Skip to content
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

Use eslint-config-metarhia and fix linting issues #204

Closed
wants to merge 1 commit into from
Closed
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
177 changes: 1 addition & 176 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,176 +1 @@
env:
node: true
es6: true
extends: 'eslint:recommended'
globals:
api: false
application: false
connection: false
impress: false
rules:
indent:
- error
- 2
- SwitchCase: 1
VariableDeclarator:
var: 2
let: 2
const: 1
MemberExpression: 1
linebreak-style:
- error
- unix
quotes:
- error
- single
semi:
- error
- always
eqeqeq:
- error
- always
no-loop-func:
- error
strict:
- error
- global
block-spacing:
- error
- always
brace-style:
- error
- 1tbs
- allowSingleLine: true
camelcase:
- error
comma-style:
- error
- last
comma-spacing:
- error
- before: false
after: true
eol-last:
- error
func-call-spacing:
- error
- never
key-spacing:
- error
- beforeColon: false
afterColon: true
mode: minimum
keyword-spacing:
- error
- before: true
after: true
overrides:
function:
after: false
max-len:
- error
- code: 80
ignoreUrls: true
max-nested-callbacks:
- error
- max: 5
new-cap:
- error
- newIsCap: true
capIsNew: true
properties: true
new-parens:
- error
no-lonely-if:
- error
no-trailing-spaces:
- error
no-unneeded-ternary:
- error
no-whitespace-before-property:
- error
object-curly-spacing:
- error
- always
operator-assignment:
- error
- always
operator-linebreak:
- error
- after
semi-spacing:
- error
- before: false
after: true
space-before-blocks:
- error
- always
space-before-function-paren:
- error
- never
space-in-parens:
- error
- never
space-infix-ops:
- error
space-unary-ops:
- error
- words: true
nonwords: false
overrides:
typeof: false
no-unreachable:
- error
no-global-assign:
- error
no-self-compare:
- error
no-unmodified-loop-condition:
- error
no-constant-condition:
- error
- checkLoops: false
no-console:
- off
no-useless-concat:
- error
no-useless-escape:
- error
no-shadow-restricted-names:
- error
no-use-before-define:
- error
- functions: false
arrow-body-style:
- error
- as-needed
arrow-spacing:
- error
no-confusing-arrow:
- error
- allowParens: true
no-useless-computed-key:
- error
no-useless-rename:
- error
no-var:
- error
object-shorthand:
- error
- always
prefer-arrow-callback:
- error
prefer-const:
- error
prefer-numeric-literals:
- error
prefer-rest-params:
- error
prefer-spread:
- error
rest-spread-spacing:
- error
- never
template-curly-spacing:
- error
- never
extends: 'metarhia'
8 changes: 2 additions & 6 deletions lib/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ const splitAt = (index, array) => {
// Shuffle an array
// arr - <Array>
// Returns: <Array>
const shuffle = arr => (
arr.sort(() => Math.random() - 0.5)
);
const shuffle = arr => arr.sort(() => Math.random() - 0.5);

// Generate int array from given range
// from - <number>, range start
Expand Down Expand Up @@ -64,9 +62,7 @@ const sequence = (seq, max) => {
// Get last element of array
// arr - <Array>
// Returns: <any>, element
const last = arr => (
arr[arr.length - 1]
);
const last = arr => arr[arr.length - 1];

module.exports = {
splitAt,
Expand Down
44 changes: 23 additions & 21 deletions lib/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,50 +41,50 @@ const passwordTests = {
MIN_LENGTH: {
test: (password, options) => password.length >= options.minLength,
hint: options => ({ name: 'MIN_LENGTH', minLength: options.minLength }),
options: { minLength: 10 }
options: { minLength: 10 },
},
MAX_LENGTH: {
test: (password, options) => password.length <= options.maxLength,
hint: options => ({ name: 'MAX_LENGTH', maxLength: options.maxLength }),
options: { maxLength: 128 }
options: { maxLength: 128 },
},
MIN_PASSPHRASE_LENGTH: {
test: (password, options) => password.length >= options.minLength,
hint: options => ({
name: 'MIN_PASSPHRASE_LENGTH',
minLength: options.minLength
minLength: options.minLength,
}),
options: { minLength: 20 }
options: { minLength: 20 },
},
MAX_REPEATED_CHARS: {
test: (password, options) => {
const regexp = new RegExp(`(.)\\1{${options.number},}`);
return !regexp.test(password);
},
hint: options => ({ name: 'MAX_REPEATED_CHARS', number: options.number }),
options: { number: 2 }
options: { number: 2 },
},
MIN_LOWERCASE_CHARS: {
test: (password, option) => (
stringIncludesChars(password, unicodeCategories.Ll, option.number)
test: (password, option) => stringIncludesChars(
password, unicodeCategories.Ll, option.number
),
hint: options => ({ name: 'MIN_LOWERCASE_CHARS', number: options.number }),
options: { number: 1 }
options: { number: 1 },
},
MIN_UPPERCASE_CHARS: {
test: (password, options) => (
stringIncludesChars(password, unicodeCategories.Lu, options.number)
test: (password, options) => stringIncludesChars(
password, unicodeCategories.Lu, options.number
),
hint: options => ({ name: 'MIN_UPPERCASE_CHARS', number: options.number }),
options: { number: 1 }
options: { number: 1 },
},
MIN_NUMBERS: {
test: (password, options) => {
const NUMBERS_RANGE = [[49, 57]];
return stringIncludesChars(password, NUMBERS_RANGE, options.number);
},
hint: options => ({ name: 'MIN_NUMBERS', number: options.number }),
options: { number: 1 }
options: { number: 1 },
},
MIN_SPECIAL_CHARS: {
test: (password, options) => {
Expand All @@ -93,20 +93,20 @@ const passwordTests = {
return stringIncludesChars(password, SPECIAL_CHARS_RANGE, options.number);
},
hint: options => ({ name: 'MIN_SPECIAL_CHARS', number: options.number }),
options: { number: 1 }
}
options: { number: 1 },
},
};

const loginTests = {
MIN_LENGTH: {
test: (login, options) => login.length >= options.minLength,
hint: options => ({ name: 'MIN_LENGTH', minLength: options.minLength }),
options: { minLength: 6 }
options: { minLength: 6 },
},
MAX_LENGTH: {
test: (login, options) => login.length <= options.maxLength,
hint: options => ({ name: 'MAX_LENGTH', maxLength: options.maxLength }),
options: { maxLength: 50 }
options: { maxLength: 50 },
},
IS_EMAIL: {
test: login => {
Expand All @@ -123,9 +123,11 @@ const loginTests = {
localPart.length <= MAX_LOCAL_PART_LENGTH &&
EMAIL_REGEXP.test(login);
}

return false;
},
hint: () => ({ name: 'IS_EMAIL' }),
}
},
};

const loginPasswordTests = {
Expand All @@ -136,7 +138,7 @@ const loginPasswordTests = {
PASSWORD_INCLUDES_LOGIN: {
test: (login, password) => !password.includes(login),
hint: () => ({ name: 'PASSWORD_INCLUDES_LOGIN' }),
}
},
};

class AuthenticationStrength {
Expand Down Expand Up @@ -221,7 +223,7 @@ const checkPassword = (password, required, optional = []) => {
'MIN_NUMBERS',
'MIN_SPECIAL_CHARS',
'MIN_UPPERCASE_CHARS',
'MIN_LOWERCASE_CHARS'
'MIN_LOWERCASE_CHARS',
];
}
return makeTest(passwordTests, required, optional, password);
Expand All @@ -237,7 +239,7 @@ const checkLoginPassword = (login, password, required, optional = []) => {
if (!required) {
required = [
'PASSWORD_INCLUDES_LOGIN',
'LOGIN_INCLUDES_PASSWORD'
'LOGIN_INCLUDES_PASSWORD',
];
}
return makeTest(loginPasswordTests, required, optional, login, password);
Expand All @@ -246,5 +248,5 @@ const checkLoginPassword = (login, password, required, optional = []) => {
module.exports = {
checkLogin,
checkPassword,
checkLoginPassword
checkLoginPassword,
};
2 changes: 1 addition & 1 deletion lib/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Cache.prototype.clr = function(prefix, fn) {

// Create Cache, enhanced Map
// Returns: <Cache>
const cache = () => (new Cache());
const cache = () => new Cache();

module.exports = {
cache,
Expand Down
2 changes: 1 addition & 1 deletion lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ EnhancedEmitter.prototype.forward = function(to, events) {
// Create EnhancedEmitter, enhanced EventEmitter
// with wildcard and forward method
// Returns: <EventEmitter>
const emitter = () => (new EnhancedEmitter());
const emitter = () => new EnhancedEmitter();

module.exports = {
forwardEvents,
Expand Down
2 changes: 1 addition & 1 deletion lib/fp.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const zip = (...arrays) => {
// count - <number>, new array length
// elem - <any>, value to replicate
// Returns: <Array>, replicated
const replicate = (count, elem) => (Array.from({ length: count }, () => elem));
const replicate = (count, elem) => Array.from({ length: count }, () => elem);

// Zip arrays using specific function
// fn - <Function>, for zipping elements with index i
Expand Down
Loading