]> git.proxmox.com Git - mirror_novnc.git/commitdiff
Migrate deprecated eslint config to to new format
authorSamuel Mannehed <samuel@cendio.se>
Mon, 22 Apr 2024 06:49:30 +0000 (08:49 +0200)
committerSamuel Mannehed <samuel@cendio.se>
Tue, 30 Apr 2024 13:26:50 +0000 (15:26 +0200)
The .eslintrc and .eslintignore formats are deprecated. The new format
uses a single eslint.config.js (or .mjs) file at the top.

.eslintignore [deleted file]
.eslintrc [deleted file]
eslint.config.mjs [new file with mode: 0644]
package.json
po/.eslintrc [deleted file]
tests/.eslintrc [deleted file]
utils/.eslintrc [deleted file]

diff --git a/.eslintignore b/.eslintignore
deleted file mode 100644 (file)
index d381628..0000000
+++ /dev/null
@@ -1 +0,0 @@
-**/xtscancodes.js
diff --git a/.eslintrc b/.eslintrc
deleted file mode 100644 (file)
index 10e15ce..0000000
--- a/.eslintrc
+++ /dev/null
@@ -1,54 +0,0 @@
-{
-    "env": {
-        "browser": true,
-        "es2020": true
-    },
-    "parserOptions": {
-        "sourceType": "module",
-        "ecmaVersion": 2020
-    },
-    "extends": "eslint:recommended",
-    "rules": {
-        // Unsafe or confusing stuff that we forbid
-
-        "no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": true }],
-        "no-constant-condition": ["error", { "checkLoops": false }],
-        "no-var": "error",
-        "no-useless-constructor": "error",
-        "object-shorthand": ["error", "methods", { "avoidQuotes": true }],
-        "prefer-arrow-callback": "error",
-        "arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": false } ],
-        "arrow-parens": ["error", "as-needed", { "requireForBlockBody": true }],
-        "arrow-spacing": ["error"],
-        "no-confusing-arrow": ["error", { "allowParens": true }],
-
-        // Enforced coding style
-
-        "brace-style": ["error", "1tbs", { "allowSingleLine": true }],
-        "indent": ["error", 4, { "SwitchCase": 1,
-                                 "VariableDeclarator": "first",
-                                 "FunctionDeclaration": { "parameters": "first" },
-                                 "FunctionExpression": { "parameters": "first" },
-                                 "CallExpression": { "arguments": "first" },
-                                 "ArrayExpression": "first",
-                                 "ObjectExpression": "first",
-                                 "ImportDeclaration": "first",
-                                 "ignoreComments": true }],
-        "comma-spacing": ["error"],
-        "comma-style": ["error"],
-        "curly": ["error", "multi-line"],
-        "func-call-spacing": ["error"],
-        "func-names": ["error"],
-        "func-style": ["error", "declaration", { "allowArrowFunctions": true }],
-        "key-spacing": ["error"],
-        "keyword-spacing": ["error"],
-        "no-trailing-spaces": ["error"],
-        "semi": ["error"],
-        "space-before-blocks": ["error"],
-        "space-before-function-paren": ["error", { "anonymous": "always",
-                                                   "named": "never",
-                                                   "asyncArrow": "always" }],
-        "switch-colon-spacing": ["error"],
-        "camelcase": ["error", { allow: ["^XK_", "^XF86XK_"] }],
-    }
-}
diff --git a/eslint.config.mjs b/eslint.config.mjs
new file mode 100644 (file)
index 0000000..e3bfcd7
--- /dev/null
@@ -0,0 +1,98 @@
+import globals from "globals";
+import js from "@eslint/js";
+
+export default [
+    js.configs.recommended,
+    {
+        languageOptions: {
+            ecmaVersion: 2020,
+            sourceType: "module",
+            globals: {
+                ...globals.browser,
+                ...globals.es2020,
+            }
+        },
+        ignores: ["**/xtscancodes.js"],
+        rules: {
+            // Unsafe or confusing stuff that we forbid
+
+            "no-unused-vars": ["error", { "vars": "all",
+                                          "args": "none",
+                                          "ignoreRestSiblings": true,
+                                          "caughtErrors": "none" }],
+            "no-constant-condition": ["error", { "checkLoops": false }],
+            "no-var": "error",
+            "no-useless-constructor": "error",
+            "object-shorthand": ["error", "methods", { "avoidQuotes": true }],
+            "prefer-arrow-callback": "error",
+            "arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": false } ],
+            "arrow-parens": ["error", "as-needed", { "requireForBlockBody": true }],
+            "arrow-spacing": ["error"],
+            "no-confusing-arrow": ["error", { "allowParens": true }],
+
+            // Enforced coding style
+
+            "brace-style": ["error", "1tbs", { "allowSingleLine": true }],
+            "indent": ["error", 4, { "SwitchCase": 1,
+                                     "VariableDeclarator": "first",
+                                     "FunctionDeclaration": { "parameters": "first" },
+                                     "FunctionExpression": { "parameters": "first" },
+                                     "CallExpression": { "arguments": "first" },
+                                     "ArrayExpression": "first",
+                                     "ObjectExpression": "first",
+                                     "ImportDeclaration": "first",
+                                     "ignoreComments": true }],
+            "comma-spacing": ["error"],
+            "comma-style": ["error"],
+            "curly": ["error", "multi-line"],
+            "func-call-spacing": ["error"],
+            "func-names": ["error"],
+            "func-style": ["error", "declaration", { "allowArrowFunctions": true }],
+            "key-spacing": ["error"],
+            "keyword-spacing": ["error"],
+            "no-trailing-spaces": ["error"],
+            "semi": ["error"],
+            "space-before-blocks": ["error"],
+            "space-before-function-paren": ["error", { "anonymous": "always",
+                                                       "named": "never",
+                                                       "asyncArrow": "always" }],
+            "switch-colon-spacing": ["error"],
+            "camelcase": ["error", { "allow": ["^XK_", "^XF86XK_"] }],
+        }
+    },
+    {
+        files: ["po/po2js", "po/xgettext-html"],
+        languageOptions: {
+            globals: {
+                ...globals.node,
+            }
+        },
+    },
+    {
+        files: ["tests/*"],
+        languageOptions: {
+            globals: {
+                ...globals.node,
+                ...globals.mocha,
+                sinon: false,
+                chai: false,
+            }
+        },
+        rules: {
+            "prefer-arrow-callback": 0,
+            // Too many anonymous callbacks
+            "func-names": "off",
+        },
+    },
+    {
+        files: ["utils/*"],
+        languageOptions: {
+            globals: {
+                ...globals.node,
+            }
+        },
+        rules: {
+            "no-console": 0,
+        },
+    },
+];
index 482b86eb341d0199f0fb96bc4612ef62eab85daa..9f22165bc74168815d370db7cea7beec3da2ef07 100644 (file)
@@ -44,6 +44,7 @@
     "commander": "latest",
     "eslint": "latest",
     "fs-extra": "latest",
+    "globals": "latest",
     "jsdom": "latest",
     "karma": "latest",
     "karma-mocha": "latest",
diff --git a/po/.eslintrc b/po/.eslintrc
deleted file mode 100644 (file)
index a0157e2..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-{
-    "env": {
-        "node": true,
-    },
-}
diff --git a/tests/.eslintrc b/tests/.eslintrc
deleted file mode 100644 (file)
index 545fa2e..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-{
-    "env": {
-        "node": true,
-        "mocha": true
-    },
-    "globals": {
-        "chai": false,
-        "sinon": false
-    },
-    "rules": {
-        "prefer-arrow-callback": 0,
-        // Too many anonymous callbacks
-        "func-names": "off",
-    }
-}
diff --git a/utils/.eslintrc b/utils/.eslintrc
deleted file mode 100644 (file)
index b7dc129..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "env": {
-    "node": true
-  },
-  "rules": {
-       "no-console": 0
-  }
-}
\ No newline at end of file