summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Holthuis <jan.holthuis@ruhr-uni-bochum.de>2022-01-11 19:56:53 +0100
committerGitHub <noreply@github.com>2022-01-11 19:56:53 +0100
commit7819ed741373a5dfc1d8de371f24fda0783782cd (patch)
tree39c61515a87b5724450bf6214dbe781f9c392682
parent3d606d284de494200ffb67763e4518284afa4c5d (diff)
parent050ccbef5d768a232b9dd08eeb5000f8340b3cd9 (diff)
Merge pull request #4616 from Holzhaus/eslint-mjs-support
eslint: Add mjs support
-rw-r--r--.eslintrc.json28
-rw-r--r--.pre-commit-config.yaml2
-rw-r--r--res/qml/Mixxx/MathUtils.mjs8
3 files changed, 30 insertions, 8 deletions
diff --git a/.eslintrc.json b/.eslintrc.json
index 1c77f95525..84911dce95 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -62,11 +62,25 @@
"yoda": "warn"
},
"globals": {
- "console": "writable",
- "svg": "writable",
- "HIDController": "writable",
- "HIDDebug": "writable",
- "HIDPacket": "writable",
- "controller": "writable"
- }
+ "console": "readable"
+ },
+ "overrides": [
+ {
+ "files": ["**/*.mjs"],
+ "parserOptions": {
+ "sourceType": "module"
+ }
+ },
+ {
+ "files": ["res/controllers/*.js"],
+ "globals": {
+ "console": "readable",
+ "svg": "writable",
+ "HIDController": "writable",
+ "HIDDebug": "writable",
+ "HIDPacket": "writable",
+ "controller": "writable"
+ }
+ }
+ ]
}
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 2b52d0fac2..468bfbaf32 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -67,6 +67,8 @@ repos:
hooks:
- id: eslint
args: [--fix, --report-unused-disable-directives]
+ files: \.m?js$
+ types: [file]
stages:
- commit
- manual
diff --git a/res/qml/Mixxx/MathUtils.mjs b/res/qml/Mixxx/MathUtils.mjs
index e399e23b87..e7b500b7b4 100644
--- a/res/qml/Mixxx/MathUtils.mjs
+++ b/res/qml/Mixxx/MathUtils.mjs
@@ -1,3 +1,9 @@
-export function clamp(value, min, max) {
+/**
+ * @param {number} value Value
+ * @param {number} min Lower bound
+ * @param {number} max Upper bound
+ * @returns {number} Value clamped between min and max
+ */
+export const clamp = function(value, min, max) {
return Math.max(Math.min(value, max), min);
};