From 212a4592d2d9c80497f6db6ea1b9b2d4414db21b Mon Sep 17 00:00:00 2001 From: Sefinek Date: Thu, 31 Oct 2024 21:05:54 +0100 Subject: [PATCH] eslint cfg update --- config.js | 2 +- ecosystem.config.js | 6 +++--- eslint.config.mjs | 37 ++++++++++++++++++------------------- index.js | 2 +- scripts/csv.js | 2 +- scripts/generateComment.js | 2 +- scripts/headers.js | 4 ++-- scripts/log.js | 2 +- scripts/payload.js | 6 +++--- scripts/sefinekAPI.js | 6 +++--- whitelist.js | 2 +- 11 files changed, 35 insertions(+), 36 deletions(-) diff --git a/config.js b/config.js index a3d2ccc..96dbd51 100644 --- a/config.js +++ b/config.js @@ -21,5 +21,5 @@ module.exports = { SUCCESS_COOLDOWN, IP_REFRESH_INTERVAL, REPORT_TO_SEFINEK_API, - SEFINEK_API_INTERVAL + SEFINEK_API_INTERVAL, }; \ No newline at end of file diff --git a/ecosystem.config.js b/ecosystem.config.js index ebf490a..644132c 100644 --- a/ecosystem.config.js +++ b/ecosystem.config.js @@ -27,7 +27,7 @@ module.exports = { // Environment variables env: { - NODE_ENV: 'production' - } - }] + NODE_ENV: 'production', + }, + }], }; \ No newline at end of file diff --git a/eslint.config.mjs b/eslint.config.mjs index a966355..ae1f169 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,7 +1,6 @@ import js from '@eslint/js'; import globals from 'globals'; -// noinspection JSUnusedGlobalSymbols export default [ js.configs.recommended, { @@ -9,13 +8,13 @@ export default [ ecmaVersion: 2024, globals: { ...globals.node, - ...globals.es2024 - } + ...globals.es2024, + }, }, rules: { 'arrow-spacing': ['warn', { before: true, after: true }], - 'comma-dangle': ['error'], - 'comma-spacing': 'error', + 'comma-dangle': ['warn', { arrays: 'always-multiline', objects: 'always-multiline' }], + 'comma-spacing': 'warn', 'comma-style': 'error', 'curly': ['error', 'multi-line', 'consistent'], 'dot-location': ['error', 'property'], @@ -26,31 +25,31 @@ export default [ 'max-statements-per-line': ['error', { max: 2 }], 'no-console': 'off', 'no-empty': 'warn', - 'no-empty-function': 'error', + 'no-empty-function': 'warn', 'no-floating-decimal': 'error', - 'no-lonely-if': 'error', + 'no-lonely-if': 'warn', 'no-multi-spaces': 'warn', - 'no-multiple-empty-lines': ['warn', { max: 4, maxEOF: 1, maxBOF: 0 }], + 'no-multiple-empty-lines': ['warn', { max: 3, maxEOF: 1, maxBOF: 0 }], 'no-shadow': ['error', { allow: ['err', 'resolve', 'reject'] }], - 'no-trailing-spaces': ['warn'], + 'no-trailing-spaces': 'warn', 'no-unreachable': 'warn', 'no-unused-vars': 'warn', 'no-use-before-define': ['error', { functions: false, classes: true }], 'no-var': 'error', - 'object-curly-spacing': ['error', 'always'], + 'object-curly-spacing': ['warn', 'always'], 'prefer-const': 'error', 'quotes': ['warn', 'single'], 'semi': ['warn', 'always'], 'sort-vars': 'warn', - 'space-before-blocks': 'error', - 'space-before-function-paren': ['error', { anonymous: 'never', named: 'never', asyncArrow: 'always' }], - 'space-in-parens': 'error', - 'space-infix-ops': 'error', - 'space-unary-ops': 'error', + 'space-before-blocks': 'warn', + 'space-before-function-paren': ['warn', { anonymous: 'never', named: 'never', asyncArrow: 'always' }], + 'space-in-parens': 'warn', + 'space-infix-ops': 'warn', + 'space-unary-ops': 'warn', 'spaced-comment': 'warn', - 'wrap-regex': 'error', - 'yoda': 'error' + 'wrap-regex': 'warn', + 'yoda': 'error', }, - ignores: ['node_modules', 'public/js/bootstrap.bundle.min.js'] - } + ignores: ['node_modules', '*min.js', '*bundle*', 'build/*', 'dist/*'], + }, ]; \ No newline at end of file diff --git a/index.js b/index.js index 9006daf..ac98b71 100644 --- a/index.js +++ b/index.js @@ -73,7 +73,7 @@ const reportIP = async (event, uri, country, hostname, endpoint, cycleErrorCount await axios.post('https://api.abuseipdb.com/api/v2/report', { ip: event.clientIP, categories: '19', - comment: generateComment(event) + comment: generateComment(event), }, { headers: headers.ABUSEIPDB }); logToCSV(event.rayName, event.clientIP, country, hostname, endpoint, event.userAgent, event.action, 'REPORTED'); diff --git a/scripts/csv.js b/scripts/csv.js index 03e47d9..f0424b8 100644 --- a/scripts/csv.js +++ b/scripts/csv.js @@ -49,7 +49,7 @@ const readReportedIPs = () => { useragent: parts[6].replace(/(^"|"$)/g, ''), action: parts[7], status: parts[8], - sefinekAPI: parts[9] === 'true' + sefinekAPI: parts[9] === 'true', }; }) .filter(item => item !== null); diff --git a/scripts/generateComment.js b/scripts/generateComment.js index 7270f34..75dc3c4 100644 --- a/scripts/generateComment.js +++ b/scripts/generateComment.js @@ -9,7 +9,7 @@ module.exports = it => { { label: 'Timestamp', value: it.datetime }, { label: 'Ray ID', value: it.rayName }, { label: 'Rule ID', value: it.ruleId }, - { label: 'UA', value: it.userAgent || 'Empty string' } + { label: 'UA', value: it.userAgent || 'Empty string' }, ]; const reportLines = fields diff --git a/scripts/headers.js b/scripts/headers.js index bc68ed2..d969534 100644 --- a/scripts/headers.js +++ b/scripts/headers.js @@ -6,13 +6,13 @@ const CLOUDFLARE = { 'User-Agent': userAgent, 'Content-Type': 'application/json', 'Authorization': `Bearer ${process.env.CLOUDFLARE_API_KEY}`, - 'X-Auth-Email': process.env.CLOUDFLARE_EMAIL + 'X-Auth-Email': process.env.CLOUDFLARE_EMAIL, }; const ABUSEIPDB = { 'User-Agent': userAgent, 'Content-Type': 'application/json', - 'Key': process.env.ABUSEIPDB_API_KEY + 'Key': process.env.ABUSEIPDB_API_KEY, }; module.exports = { CLOUDFLARE, ABUSEIPDB }; \ No newline at end of file diff --git a/scripts/log.js b/scripts/log.js index d3ab1f4..2f955d0 100644 --- a/scripts/log.js +++ b/scripts/log.js @@ -1,7 +1,7 @@ const levels = { log: '[INFO]', warn: '[WARN]', - error: '[FAIL]' + error: '[FAIL]', }; module.exports = (level, msg) => console[level](`${levels[level]} ${msg}`); \ No newline at end of file diff --git a/scripts/payload.js b/scripts/payload.js index 12a06c7..8d6fc03 100644 --- a/scripts/payload.js +++ b/scripts/payload.js @@ -44,9 +44,9 @@ module.exports = () => { { action_neq: 'managed_challenge_skipped' }, { action_neq: 'managed_challenge_non_interactive_solved' }, { action_neq: 'managed_challenge_interactive_solved' }, - { action_neq: 'managed_challenge_bypassed' } - ] - } + { action_neq: 'managed_challenge_bypassed' }, + ], + }, }; return { query, variables }; diff --git a/scripts/sefinekAPI.js b/scripts/sefinekAPI.js index 67b3a54..96c4c56 100644 --- a/scripts/sefinekAPI.js +++ b/scripts/sefinekAPI.js @@ -37,10 +37,10 @@ module.exports = async () => { useragent: ip.useragent.replace(/"/g, ''), action: ip.action, country: ip.country, - timestamp: ip.timestamp - })) + timestamp: ip.timestamp, + })), }, { - headers: { 'Authorization': process.env.SEFINEK_API_SECRET } + headers: { 'Authorization': process.env.SEFINEK_API_SECRET }, }); log('log', `Successfully sent ${uniqueLogs.length} logs to Sefinek API. Status: ${res.status}`); diff --git a/whitelist.js b/whitelist.js index 8095866..2252be2 100644 --- a/whitelist.js +++ b/whitelist.js @@ -1,5 +1,5 @@ module.exports = [ '/weryfikacja', '/verification', - '/download' + '/download', ]; \ No newline at end of file