lint compliance

This commit is contained in:
yflory 2026-02-20 13:17:06 +01:00
parent 5a62afb17f
commit 32956fcdde
9 changed files with 461 additions and 296 deletions

View File

@ -1,101 +0,0 @@
// SPDX-FileCopyrightText: 2024 XWiki CryptPad Team <contact@cryptpad.org> and contributors
//
// SPDX-License-Identifier: AGPL-3.0-or-later
const compatPlugin = require("eslint-plugin-compat");
const globals = require("globals");
const js = require("@eslint/js");
const FlatCompat = require("@eslint/eslintrc").FlatCompat;
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
module.exports = [{
ignores: [
"**/node_modules/",
"www/components/",
"www/bower_components/",
"www/common/onlyoffice/dist",
"www/common/onlyoffice/x2t",
"**/onlyoffice-dist/",
"www/scratch",
"www/accounts",
"www/lib",
"www/accounts",
"www/worker",
"www/todo",
"**/*worker.bundle.js",
"**/_build",
"www/common/hyperscript.js",
"www/pad/wysiwygarea-plugin.js",
"www/pad/mediatag-plugin.js",
"www/pad/mediatag-plugin-dialog.js",
"www/pad/disable-base64.js",
"www/pad/wordcount/",
"www/kanban/jkanban.js",
"www/common/jscolor.js",
"www/common/media-tag-nacl.min.js",
"**/customize/",
"www/debug/chainpad.dist.js",
"www/pad/mathjax/",
"www/code/mermaid*.js",
"www/code/orgmode.js",
"www/common/worker.bundle.js",
"www/common/worker.bundle.min.js",
"src/tweetnacl",
"_build",
"scripts/api/testapi.js",
"rollup.config.mjs",
"*/lucide.js"
],
}, ...compat.extends("eslint:recommended", "plugin:compat/recommended"), {
plugins: {
compatPlugin,
},
languageOptions: {
globals: {
...globals.browser,
...globals.node,
define: "readonly",
},
ecmaVersion: "latest",
sourceType: "commonjs",
},
rules: {
indent: ["off", 4],
"linebreak-style": ["off", "unix"],
quotes: ["off", "single"],
semi: ["error", "always"],
eqeqeq: ["error", "always"],
"no-irregular-whitespace": ["off"],
"no-self-assign": ["off"],
"no-empty": ["off"],
"no-useless-escape": ["off"],
"no-extra-boolean-cast": ["off"],
"no-prototype-builtins": ["off"],
"no-use-before-define": ["error"],
"no-unused-vars": [
"error",
{
caughtErrors: "none"
}
]
},
}, {
files: ["**/.eslintrc.{js,cjs}"],
languageOptions: {
globals: {
...globals.node,
},
ecmaVersion: 5,
sourceType: "commonjs",
},
}];

79
eslint.config.mjs Normal file
View File

@ -0,0 +1,79 @@
import globals from "globals";
import { defineConfig, globalIgnores } from "eslint/config";
const rules = {
indent: ["off", 4],
"linebreak-style": ["off", "unix"],
quotes: ["off", "single"],
semi: ["error", "always"],
eqeqeq: ["error", "always"],
"no-irregular-whitespace": ["off"],
"no-self-assign": ["off"],
"no-empty": ["off"],
"no-useless-escape": ["off"],
"no-extra-boolean-cast": ["off"],
"no-prototype-builtins": ["error"],
"no-use-before-define": ["error"],
"no-prototype-builtins": ["off"], // FIXME
//"no-undef": ["error"],
"no-unused-vars": [
"error",
{
caughtErrors: "none"
}
]
};
export default defineConfig([
globalIgnores([
"data/**",
"datastore/**",
"blob/**", "block/**", "pins/**",
"LICENSES/**",
"node_modules/**",
"**/node_modules/",
"www/components/**",
"www/common/onlyoffice/dist/**",
"www/common/onlyoffice/x2t/**",
"**/onlyoffice-dist/**",
"www/scratch/**",
"www/accounts/**",
"www/lib/**",
"www/worker/**",
"www/todo/**",
"**/_build",
"www/common/hyperscript.js",
"www/pad/wysiwygarea-plugin.js",
"www/pad/mediatag-plugin.js",
"www/pad/mediatag-plugin-dialog.js",
"www/pad/disable-base64.js",
"www/pad/wordcount/**",
"www/kanban/jkanban.js",
"www/common/jscolor.js",
"www/common/media-tag-nacl.min.js",
"**/customize/**",
"www/debug/chainpad.dist.js",
"www/pad/mathjax/**",
"www/code/mermaid*.js",
"www/code/orgmode.js",
"www/common/worker.bundle.js",
"www/common/worker.bundle.min.js",
"rollup.config.mjs",
"*/lucide.js",
"scripts/**",
"**/.git/**"
]), {
files: [
"lib/**",
"src/**",
"www/**",
"customize.dist/**",
"config/**", "server.js"
],
languageOptions: {
globals: { ...globals.node, ...globals.browser, ...globals.amd }
},
rules
}]);

View File

@ -85,7 +85,7 @@ var getActiveSessions = function (Env, Server, cb) {
};
var shutdown = function (Env, Server, cb) {
if (true) { // eslint-disable-line no-constant-condition
if (true) {
return void cb('E_NOT_IMPLEMENTED');
}

View File

@ -266,7 +266,7 @@ var getMetadataAtPath = function (Env, path, _cb) {
// if you can't parse, that's bad
return void cb("INVALID_METADATA");
}
readMore(); // eslint-disable-line no-unreachable
readMore();
}, function (err) {
cb(err);
});

558
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,7 @@
"body-parser": "^1.20.4",
"bootstrap": "^4.0.0",
"bootstrap-tokenfield": "^0.12.0",
"chainpad": "^5.2.6",
"chainpad": "^5.3.1",
"chainpad-crypto": "^0.3.0",
"chainpad-listmap": "^1.2.0",
"chainpad-netflux": "^1.3.0",
@ -72,17 +72,18 @@
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^12.1.0",
"eslint": "^9.16.0",
"eslint": "^10.0.0",
"eslint-plugin-compat": "^6.0.1",
"globals": "^17.3.0",
"rollup": "^4.24.0",
"stylelint": "^16.9.0",
"stylelint": "^16.26.1",
"stylelint-config-standard-less": "^3.0.1",
"tslib": "^2.7.0",
"typescript": "^5.6.2"
},
"overrides": {
"minimist": "~1.2.3",
"minimatch": "~3.1.2",
"minimatch": "~10.2.2",
"ws": "^8.17.1",
"jquery": "3.6.0"
},
@ -96,6 +97,7 @@
"offlinedev": "DEV=1 OFFLINE=1 node server.js",
"package": "PACKAGE=1 node server.js",
"lint": "eslint . && stylelint \"./customize.dist/src/less2/**/*.less\"",
"lint:debug": "DEBUG=eslint:* eslint .",
"lint:js": "eslint .",
"lint:less": "stylelint \"./customize.dist/src/less2/**/*.less\"",
"lint:translations": "node ./scripts/translations/lint-translations.js",

View File

@ -2,8 +2,6 @@
//
// SPDX-License-Identifier: AGPL-3.0-or-later
/* eslint compat/compat: "off" */
(() => {
const factory = (ApiConfig = {}) => {
let window = globalThis;

View File

@ -1252,7 +1252,6 @@ define([
// check if they provide legal data
assert(function (cb, msg) {
// eslint-disable-next-line no-constant-condition
if (true) { return void cb(true); } // FIXME stubbed while we determine whether this is necessary
if (ApiConfig.restrictRegistration) { return void cb(true); }

View File

@ -122,7 +122,7 @@ define([
// Sanitize file names
var illegalRe = /[\/\?<>\\:\*\|"]/g;
var controlRe = /[\x00-\x1f\x80-\x9f]/g; // eslint-disable-line no-control-regex
var controlRe = /[\x00-\x1f\x80-\x9f]/g;
var reservedRe = /^\.+$/;
var safeRe = /[&'%!"{}[\]]/g;
var sanitize = function (input) {