diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-11-19 20:49:29 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-19 20:49:29 +0000 |
commit | b8950f56023bedacc265db654ca485783be8608e (patch) | |
tree | b806ee53e1d96917f5068ee8a0432f51730a3652 | |
parent | 32ae9363987acc99b3b7812211ab754433d3da49 (diff) | |
parent | a592c2a341db27cfac0a894b49eb922e56138004 (diff) | |
download | rspamd-b8950f56023bedacc265db654ca485783be8608e.tar.gz rspamd-b8950f56023bedacc265db654ca485783be8608e.zip |
Merge pull request #4711 from moisseev/webui
[Test] Restore stylistic rules check
-rw-r--r-- | .drone.yml | 1 | ||||
-rw-r--r-- | .eslintrc.json | 59 | ||||
-rw-r--r-- | interface/js/app/config.js | 7 | ||||
-rw-r--r-- | interface/js/app/graph.js | 3 | ||||
-rw-r--r-- | interface/js/app/history.js | 5 | ||||
-rw-r--r-- | interface/js/app/rspamd.js | 9 | ||||
-rw-r--r-- | interface/js/app/selectors.js | 2 | ||||
-rw-r--r-- | interface/js/app/stats.js | 7 | ||||
-rw-r--r-- | interface/js/app/symbols.js | 6 | ||||
-rw-r--r-- | interface/js/app/upload.js | 3 | ||||
-rw-r--r-- | interface/js/main.js | 4 | ||||
-rw-r--r-- | package.json | 1 |
12 files changed, 65 insertions, 42 deletions
diff --git a/.drone.yml b/.drone.yml index 9e5c3409e..ac0b12a8e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -488,6 +488,7 @@ "commands": [ "npm install", "./node_modules/.bin/eslint -v", + "npm show @stylistic/eslint-plugin version", "./node_modules/.bin/eslint ./", "./node_modules/.bin/stylelint -v", "npm show stylelint-config-standard version", diff --git a/.eslintrc.json b/.eslintrc.json index 322185acc..a8cc237e0 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,76 +3,81 @@ "browser": true, "es6": true }, - "extends": "eslint:all", + "extends": [ + "eslint:all", + "plugin:@stylistic/all-extends" + ], "globals": { "define": false }, + "plugins": [ + "@stylistic" + ], "rules": { - "array-bracket-newline": ["error", "consistent"], - "array-element-newline": "off", - "brace-style": ["error", "1tbs", { "allowSingleLine": true }], "camelcase": "off", "capitalized-comments": "off", - "comma-dangle": ["error", "only-multiline"], "curly": ["error", "multi-line"], - "dot-location": ["error", "property"], "func-names": "off", // "func-style": ["error", "declaration"], - "function-call-argument-newline": "off", "id-length": ["error", { "min": 1 }], - "indent": ["error", 4, { "SwitchCase": 1 }], - // "max-len": ["error", { "code": 120 }], - // "key-spacing": ["error", { + // "@stylistic/key-spacing": ["error", { // "singleLine": { "afterColon": false } // }], "line-comment-position": "off", "logical-assignment-operators": ["error", "never"], "max-params": ["warn", 6], "max-statements": ["warn", 55], - "max-statements-per-line": ["error", { "max": 2 }], "multiline-comment-style": "off", - "multiline-ternary": ["error", "always-multiline"], - "newline-per-chained-call": ["error", { "ignoreChainWithDepth": 5 }], "no-continue": "off", - "no-extra-parens": ["error", "functions"], - "no-implicit-globals": "off", "no-inline-comments": "off", "no-magic-numbers": "off", "no-negated-condition": "off", "no-plusplus": "off", "no-ternary": "off", - "object-curly-newline": ["error", { "consistent": true }], - "object-property-newline": ["error", { "allowAllPropertiesOnSameLine": true }], "object-shorthand": "off", "one-var": "off", - "padded-blocks": "off", "prefer-arrow-callback": "off", "prefer-destructuring": "off", "prefer-named-capture-group": "off", "prefer-object-has-own": "off", "prefer-spread": "off", "prefer-template": "off", - "quote-props" : ["error", "consistent-as-needed"], - "quotes": ["error", "double", { "avoidEscape": true }], - "require-jsdoc": "off", "require-unicode-regexp": "off", - "space-before-function-paren": ["error", { + + "@stylistic/array-bracket-newline": ["error", "consistent"], + "@stylistic/array-element-newline": "off", + "@stylistic/brace-style": ["error", "1tbs", { "allowSingleLine": true }], + "@stylistic/comma-dangle": ["error", "only-multiline"], + "@stylistic/dot-location": ["error", "property"], + "@stylistic/function-call-argument-newline": "off", + "@stylistic/indent": ["error", 4, { "SwitchCase": 1 }], + "@stylistic/max-len": ["error", { "code": 128 }], + "@stylistic/max-statements-per-line": ["error", { "max": 2 }], + "@stylistic/multiline-ternary": ["error", "always-multiline"], + "@stylistic/newline-per-chained-call": ["error", { "ignoreChainWithDepth": 5 }], + "@stylistic/no-extra-parens": ["error", "functions"], + "@stylistic/object-property-newline": ["error", { "allowAllPropertiesOnSameLine": true }], + "@stylistic/padded-blocks": "off", + "@stylistic/quote-props" : ["error", "consistent-as-needed"], + "@stylistic/quotes": ["error", "double", { "avoidEscape": true }], + "@stylistic/semi": ["error", "always"], + "@stylistic/space-before-function-paren": ["error", { "anonymous": "always", "named": "never" }], - "vars-on-top": "off", // Temporarily disabled rules "func-style": "off", - "function-paren-newline": "off", - "key-spacing": "off", - "max-len": "off", "max-lines": "off", "max-lines-per-function": "off", "no-invalid-this": "off", "prefer-exponentiation-operator": "off", "sort-keys": "off", - "sort-vars": "off" + "sort-vars": "off", + + "@stylistic/function-paren-newline": "off", + "@stylistic/key-spacing": "off", + "@stylistic/one-var-declaration-per-line": "off" } } diff --git a/interface/js/app/config.js b/interface/js/app/config.js index d62298693..e0adb365b 100644 --- a/interface/js/app/config.js +++ b/interface/js/app/config.js @@ -132,7 +132,8 @@ define(["jquery", "app/rspamd"], } const $tr = $("<tr>").append($td); - const $span = $('<span class="map-link" data-bs-toggle="modal" data-bs-target="#modalDialog">' + item.uri + "</span>").data("item", item); + const $span = $('<span class="map-link" data-bs-toggle="modal" data-bs-target="#modalDialog">' + + item.uri + "</span>").data("item", item); $span.wrap("<td>").parent().appendTo($tr); $("<td>" + item.description + "</td>").appendTo($tr); $tr.appendTo($tbody); @@ -173,8 +174,8 @@ define(["jquery", "app/rspamd"], // Highlighting a large amount of text is unresponsive mode = (new Blob([data[0].data]).size > 5120) ? "basic" : $("input[name=editorMode]:checked").val(); - $("<" + editor[mode].elt + ' id="editor" class="' + editor[mode].class + '" data-id="' + item.map + '">' + - "</" + editor[mode].elt + ">").appendTo("#modalBody"); + $("<" + editor[mode].elt + ' id="editor" class="' + editor[mode].class + '" data-id="' + item.map + + '"></' + editor[mode].elt + ">").appendTo("#modalBody"); if (editor[mode].codejar) { require(["codejar", "linenumbers", "prism"], function (CodeJar, withLineNumbers, Prism) { diff --git a/interface/js/app/graph.js b/interface/js/app/graph.js index b7276f1c1..154317fd7 100644 --- a/interface/js/app/graph.js +++ b/interface/js/app/graph.js @@ -104,7 +104,8 @@ define(["jquery", "app/rspamd", "d3evolution", "d3pie", "d3", "footable"], // Time intervals that don't have data are excluded from average calculation as d3.mean()ignores nulls const avg = d3.mean(curr, function (d) { return d.y; }); // To find an integral on the whole time interval we need to convert nulls to zeroes - const value = d3.mean(curr, function (d) { return Number(d.y); }) * timeInterval / scaleFactor ^ 0; // eslint-disable-line no-bitwise + // eslint-disable-next-line no-bitwise + const value = d3.mean(curr, function (d) { return Number(d.y); }) * timeInterval / scaleFactor ^ 0; const yExtents = d3.extent(curr, function (d) { return d.y; }); total += value; diff --git a/interface/js/app/history.js b/interface/js/app/history.js index 30fa06700..66e94a989 100644 --- a/interface/js/app/history.js +++ b/interface/js/app/history.js @@ -390,7 +390,10 @@ define(["jquery", "app/rspamd", "d3", "footable"], style: {"font-size": "11px", "width": 300, "maxWidth": 300}, sortValue: function (val) { return Number(val.options.sortValue); } }, - {name:"type", title:"Worker type", breakpoints:"xs sm", style:{"font-size":"11px", "width":150, "maxWidth":150}}, + {name:"type", + title:"Worker type", + breakpoints:"xs sm", + style:{"font-size":"11px", "width":150, "maxWidth":150}}, {name:"pid", title:"PID", breakpoints:"xs sm", style:{"font-size":"11px", "width":110, "maxWidth":110}}, {name:"module", title:"Module", style:{"font-size":"11px"}}, {name:"id", title:"Internal ID", style:{"font-size":"11px"}}, diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js index 4ad806d76..ed732449d 100644 --- a/interface/js/app/rspamd.js +++ b/interface/js/app/rspamd.js @@ -548,8 +548,8 @@ function ($, NProgress) { // Force options to be an object const o = options || {}; Object.keys(o).forEach(function (option) { - if (["complete", "data", "error", "errorMessage", "errorOnceId", "headers", "method", "params", "server", "statusCode", - "success"] + if (["complete", "data", "error", "errorMessage", "errorOnceId", "headers", "method", "params", "server", + "statusCode", "success"] .indexOf(option) < 0) { throw new Error("Unknown option: " + option); } @@ -902,7 +902,10 @@ function ($, NProgress) { let rcpt = {}; if (!item.rcpt_mime.length) { rcpt = format_rcpt(true, false); - } else if ($(item.rcpt_mime).not(item.rcpt_smtp).length !== 0 || $(item.rcpt_smtp).not(item.rcpt_mime).length !== 0) { + } else if ( + $(item.rcpt_mime).not(item.rcpt_smtp).length !== 0 || + $(item.rcpt_smtp).not(item.rcpt_mime).length !== 0 + ) { rcpt = format_rcpt(true, true); } else { rcpt = format_rcpt(false, true); diff --git a/interface/js/app/selectors.js b/interface/js/app/selectors.js index 759e3ea16..6535953b5 100644 --- a/interface/js/app/selectors.js +++ b/interface/js/app/selectors.js @@ -40,7 +40,7 @@ define(["jquery", "app/rspamd"], enable_disable_check_btn(); } const selector = $("#selectorsSelArea").val(); - if (selector.length && !rspamd.read_only ) { + if (selector.length && !rspamd.read_only) { rspamd.query("plugins/selectors/check_selector?selector=" + encodeURIComponent(selector), { method: "GET", success: function (json) { diff --git a/interface/js/app/stats.js b/interface/js/app/stats.js index 86386fe56..e6b7bc897 100644 --- a/interface/js/app/stats.js +++ b/interface/js/app/stats.js @@ -136,7 +136,9 @@ define(["jquery", "app/rspamd", "d3pie", "d3"], if (max) { const f = d3.format(".3f"); scan_times = { - data: "<small>" + f(min) + "/</small>" + f(d3.mean(val.data.scan_times)) + "<small>/" + f(max) + "</small>", + data: "<small>" + f(min) + "/</small>" + + f(d3.mean(val.data.scan_times)) + + "<small>/" + f(max) + "</small>", title: ' title="min/avg/max"' }; } else { @@ -150,7 +152,8 @@ define(["jquery", "app/rspamd", "d3pie", "d3"], } $("#clusterTable tbody").append('<tr class="' + row_class + '">' + - '<td class="align-middle"><input type="radio" class="form-check m-auto" name="clusterName" value="' + key + '"></td>' + + '<td class="align-middle"><input type="radio" class="form-check m-auto" name="clusterName" value="' + + key + '"></td>' + "<td>" + key + "</td>" + "<td>" + val.host + "</td>" + '<td class="text-center"><span class="icon"><i class="' + glyph_status + '"></i></span></td>' + diff --git a/interface/js/app/symbols.js b/interface/js/app/symbols.js index 7df5a8dfb..df3d28fad 100644 --- a/interface/js/app/symbols.js +++ b/interface/js/app/symbols.js @@ -201,7 +201,11 @@ define(["jquery", "app/rspamd", "footable"], {name:"symbol", title:"Symbol", style:{"font-size":"11px"}}, {name:"description", title:"Description", breakpoints:"xs sm", style:{"font-size":"11px"}}, {name:"weight", title:"Score", style:{"font-size":"11px"}}, - {name:"frequency", title:"Frequency", breakpoints:"xs sm", style:{"font-size":"11px"}, sortValue:function (value) { return Number(value).toFixed(2); }}, + {name:"frequency", + title:"Frequency", + breakpoints:"xs sm", + style:{"font-size":"11px"}, + sortValue:function (value) { return Number(value).toFixed(2); }}, {name:"time", title:"Avg. time", breakpoints:"xs sm", style:{"font-size":"11px"}}, {name:"save", title:"Save", style:{"font-size":"11px"}}, ], diff --git a/interface/js/app/upload.js b/interface/js/app/upload.js index 26bb82e8d..3800ca23f 100644 --- a/interface/js/app/upload.js +++ b/interface/js/app/upload.js @@ -256,7 +256,8 @@ define(["jquery", "app/rspamd"], }); function enable_disable_scan_btn() { - $("#scan button:not(#cleanScanHistory, #scanOptionsToggle)").prop("disabled", ($.trim($("textarea").val()).length === 0)); + $("#scan button:not(#cleanScanHistory, #scanOptionsToggle)") + .prop("disabled", ($.trim($("textarea").val()).length === 0)); } enable_disable_scan_btn(); $("textarea").on("input", function () { diff --git a/interface/js/main.js b/interface/js/main.js index a86982f87..4bc488895 100644 --- a/interface/js/main.js +++ b/interface/js/main.js @@ -22,7 +22,7 @@ requirejs.config({ shim: { app: {deps:["jquery"]}, codejar: {exports: "CodeJar", deps:["linenumbers"]}, - bootstrap: {exports:"bootstrap", deps:["jquery"]}, // Popovers require jQuery + bootstrap: {exports:"bootstrap", deps:["jquery"]}, // Popovers require jQuery d3: {exports:"d3"}, d3evolution: {exports:"D3Evolution", deps:["d3.global", "jquery"]}, d3pie: {exports:"D3Pie", deps:["d3.global", "jquery"]}, @@ -64,5 +64,5 @@ requirejs.onError = function (e) { // Load main UI require(["app/rspamd"], (rspamd) => { "use strict"; - rspamd.connect() + rspamd.connect(); }); diff --git a/package.json b/package.json index 51860e148..dd1bca360 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "devDependencies": { "eslint": "*", + "@stylistic/eslint-plugin": "*", "stylelint": ">=13.6.0", "stylelint-config-standard": "*", "postcss-html": "*" |