diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000000..ecba16da636 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +res/controllers/lodash.mixxx.js diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000000..53b473badd7 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,51 @@ +{ + "extends": "eslint:recommended", + "parserOptions": { + "ecmaVersion": 5, + "sourceType": "script" + }, + "rules": { + "array-bracket-spacing" : "warn", + "block-spacing": "warn", + "brace-style": ["warn", "1tbs", { + "allowSingleLine": true + }], + "camelcase": "warn", + "comma-spacing": "warn", + "computed-property-spacing" : ["warn", "never", { + "enforceForClassMembers": true + }], + "dot-location": "warn", + "eqeqeq": ["error", "always"], + "func-style": ["error", "expression", { + "allowArrowFunctions": true + }], + "key-spacing": "warn", + "keyword-spacing": "warn", + "linebreak-style": ["warn", "unix"], + "no-trailing-spaces": "warn", + "no-unneeded-ternary": ["warn", { + "defaultAssignment": false + }], + "no-unused-vars": ["error", { + "argsIgnorePattern": "^_" + }], + "object-curly-newline" : ["warn", { + "consistent": true, + "multiline": true + }], + "object-curly-spacing" : "warn", + "quotes": ["warn", "double"], + "require-atomic-updates": "error", + "semi": "warn", + "semi-spacing": "warn", + "space-before-blocks": ["warn", "always"], + "space-before-function-paren": ["warn", "never"], + "space-in-parens": "warn" + }, + "globals": { + "console": "writable", + "svg": "writable", + "print": "readonly" + } +} diff --git a/res/controllers/.eslintrc.json b/res/controllers/.eslintrc.json new file mode 100644 index 00000000000..a5f60376e3f --- /dev/null +++ b/res/controllers/.eslintrc.json @@ -0,0 +1,10 @@ +{ + "globals": { + "_": "readonly", + "color": "readonly", + "components": "readonly", + "engine": "readonly", + "midi": "readonly", + "script": "readonly" + } +} diff --git a/res/controllers/Soundless_joyMIDI_scripts.js b/res/controllers/Soundless_joyMIDI_scripts.js index 9644636dee4..0b6f47e263c 100644 --- a/res/controllers/Soundless_joyMIDI_scripts.js +++ b/res/controllers/Soundless_joyMIDI_scripts.js @@ -25,8 +25,8 @@ var joyMIDI = { btnKey: 0, btnBeatgrid: 0, btnVolume: 0, - btnFilter: { "low": 0, "middle": 0, "high": 0 }, - btnFx: { "1": 0, "2": 0 }, + btnFilter: {"low": 0, "middle": 0, "high": 0}, + btnFx: {"1": 0, "2": 0}, connBeatIndicator: {}, }, @@ -39,8 +39,8 @@ var joyMIDI = { btnKey: 0, btnBeatgrid: 0, btnVolume: 0, - btnFilter: { "low": 0, "middle": 0, "high": 0 }, - btnFx: { "1": 0, "2": 0 }, + btnFilter: {"low": 0, "middle": 0, "high": 0}, + btnFx: {"1": 0, "2": 0}, connBeatIndicator: {}, }, @@ -89,18 +89,18 @@ var fsrDelay = false; //==== Init, Shutdown ======================================================== -joyMIDI.init = function(id, debug) { +joyMIDI.init = function(_id, _debug) { joyMIDI["[Channel1]"].connBeatIndicator = engine.makeConnection("[Channel1]", "beat_active", joyMIDI.onBeatIndicator); joyMIDI["[Channel2]"].connBeatIndicator = engine.makeConnection("[Channel2]", "beat_active", joyMIDI.onBeatIndicator); -} +}; joyMIDI.shutdown = function() { joyMIDI["[Channel1]"].connBeatIndicator.disconnect(); joyMIDI["[Channel2]"].connBeatIndicator.disconnect(); -} +}; //==== Callback ============================================================== -joyMIDI.onBeatIndicator = function(value, group, control) { +joyMIDI.onBeatIndicator = function(value, group, _control) { var fader = engine.getParameter("[Master]", "crossfader"); if (fader < 0.5) { // Left @@ -113,12 +113,12 @@ joyMIDI.onBeatIndicator = function(value, group, control) { midi.sendShortMsg(0x92, 0x00, (value) ? 0x7F : 0x00); } } -} +}; //==== Button ================================================================ joyMIDI.shiftButton = function(channel, control, value, status, group) { joyMIDI[group].btnShift = (value > 0) ? PRESSED : RELEASED; -} +}; joyMIDI.syncButton = function(channel, control, value, status, group) { if (!joyMIDI.userSetting.knobEnable) { @@ -169,11 +169,11 @@ joyMIDI.syncButton = function(channel, control, value, status, group) { joyMIDI[group].btnSync = RELEASED; } } -} +}; joyMIDI.syncTimerHandler = function(group) { joyMIDI[group].syncLongPress = 1; -} +}; joyMIDI.cueButton = function(channel, control, value, status, group) { var sft = joyMIDI[group].btnShift; @@ -181,7 +181,7 @@ joyMIDI.cueButton = function(channel, control, value, status, group) { var val = (value > 0) ? 1 : 0; engine.setValue(group, cmd, val); -} +}; joyMIDI.playButton = function(channel, control, value, status, group) { var sft = joyMIDI[group].btnShift; @@ -190,13 +190,13 @@ joyMIDI.playButton = function(channel, control, value, status, group) { if (value > 0) { script.toggleControl(group, cmd); } -} +}; joyMIDI.scratchButton = function(channel, control, value, status, group) { if (value > 0) { joyMIDI[group].isScratchPermanent = !joyMIDI[group].isScratchPermanent; } -} +}; joyMIDI.keyButton = function(channel, control, value, status, group) { if (!joyMIDI.userSetting.knobEnable) { @@ -228,7 +228,7 @@ joyMIDI.keyButton = function(channel, control, value, status, group) { joyMIDI[group].btnKey = RELEASED; } } -} +}; joyMIDI.beatgridButton = function(channel, control, value, status, group) { if (!joyMIDI.userSetting.knobEnable) { @@ -262,7 +262,7 @@ joyMIDI.beatgridButton = function(channel, control, value, status, group) { joyMIDI[group].btnBeatgrid = RELEASED; } } -} +}; joyMIDI.volumeButton = function(channel, control, value, status, group) { if (!joyMIDI.userSetting.knobEnable) { @@ -288,22 +288,22 @@ joyMIDI.volumeButton = function(channel, control, value, status, group) { joyMIDI[group].btnVolume = RELEASED; } } -} +}; joyMIDI.filterLowButton = function(channel, control, value, status, group) { joyMIDI.filterButton(channel, control, value, status, group, "[EqualizerRack1_" + group + "_Effect1]", "button_parameter1", "low"); -} +}; joyMIDI.filterMiddleButton = function(channel, control, value, status, group) { joyMIDI.filterButton(channel, control, value, status, group, "[EqualizerRack1_" + group + "_Effect1]", "button_parameter2", "middle"); -} +}; joyMIDI.filterHighButton = function(channel, control, value, status, group) { joyMIDI.filterButton(channel, control, value, status, group, "[EqualizerRack1_" + group + "_Effect1]", "button_parameter3", "high"); -} +}; joyMIDI.filterButton = function(channel, control, value, status, group, group2, param, select) { if (!joyMIDI.userSetting.knobEnable) { @@ -329,7 +329,7 @@ joyMIDI.filterButton = function(channel, control, value, status, group, group2, joyMIDI[group].btnFilter[select] = RELEASED; } } -} +}; joyMIDI.hotcueButton = function(channel, control, value, status, group) { var num = control - ((group === "[Channel1]") ? 0x3B : 0x3F); @@ -338,7 +338,7 @@ joyMIDI.hotcueButton = function(channel, control, value, status, group) { var val = (value > 0) ? 1 : 0; engine.setValue(group, cmd, val); -} +}; joyMIDI.reloopToggleButton = function(channel, control, value, status, group) { var usr = joyMIDI.userSetting.beatLoopRollEnable; @@ -347,7 +347,7 @@ joyMIDI.reloopToggleButton = function(channel, control, value, status, group) { var val = (value > 0) ? 1 : 0; engine.setValue(group, cmd, val); -} +}; joyMIDI.loopInButton = function(channel, control, value, status, group) { var sft = joyMIDI[group].btnShift; @@ -355,7 +355,7 @@ joyMIDI.loopInButton = function(channel, control, value, status, group) { var val = (value > 0) ? 1 : 0; engine.setValue(group, cmd, val); -} +}; joyMIDI.loopOutButton = function(channel, control, value, status, group) { var sft = joyMIDI[group].btnShift; @@ -363,40 +363,40 @@ joyMIDI.loopOutButton = function(channel, control, value, status, group) { var val = (value > 0) ? 1 : 0; engine.setValue(group, cmd, val); -} +}; joyMIDI.loop0p125Button = function(channel, control, value, status, group) { joyMIDI.loopXButton(channel, control, value, status, group, - [ "beatloop_0.125_toggle", "beatloop_2_toggle", - "beatlooproll_0.125_activate", "beatlooproll_2_activate" ]); -} + ["beatloop_0.125_toggle", "beatloop_2_toggle", + "beatlooproll_0.125_activate", "beatlooproll_2_activate"]); +}; joyMIDI.loop0p25Button = function(channel, control, value, status, group) { joyMIDI.loopXButton(channel, control, value, status, group, - [ "beatloop_0.25_toggle", "beatloop_4_toggle", - "beatlooproll_0.25_activate", "beatlooproll_4_activate" ]); -} + ["beatloop_0.25_toggle", "beatloop_4_toggle", + "beatlooproll_0.25_activate", "beatlooproll_4_activate"]); +}; joyMIDI.loop0p5Button = function(channel, control, value, status, group) { joyMIDI.loopXButton(channel, control, value, status, group, - [ "beatloop_0.5_toggle", "beatloop_8_toggle", - "beatlooproll_0.5_activate", "beatlooproll_8_activate" ]); -} + ["beatloop_0.5_toggle", "beatloop_8_toggle", + "beatlooproll_0.5_activate", "beatlooproll_8_activate"]); +}; joyMIDI.loop1Button = function(channel, control, value, status, group) { joyMIDI.loopXButton(channel, control, value, status, group, - [ "beatloop_1_toggle", "beatloop_16_toggle", - "beatlooproll_1_activate", "beatlooproll_16_activate" ]); -} + ["beatloop_1_toggle", "beatloop_16_toggle", + "beatlooproll_1_activate", "beatlooproll_16_activate"]); +}; joyMIDI.loopXButton = function(channel, control, value, status, group, commands) { var usr = joyMIDI.userSetting.beatLoopRollEnable; var sft = joyMIDI[group].btnShift; - var cmd = commands[ sft + (usr?2:0) ]; + var cmd = commands[sft + (usr?2:0)]; var val = (value > 0) ? 1 : 0; engine.setValue(group, cmd, val); -} +}; joyMIDI.loadButton = function(channel, control, value, status, group) { var sft = joyMIDI[group].btnShift; @@ -404,23 +404,23 @@ joyMIDI.loadButton = function(channel, control, value, status, group) { var val = (value > 0) ? 1 : 0; engine.setValue(group, cmd, val); -} +}; joyMIDI.sampler1Button = function(channel, control, value, status, group) { joyMIDI.samplerButton(channel, control, value, status, group, 1); -} +}; joyMIDI.sampler2Button = function(channel, control, value, status, group) { joyMIDI.samplerButton(channel, control, value, status, group, 2); -} +}; joyMIDI.sampler3Button = function(channel, control, value, status, group) { joyMIDI.samplerButton(channel, control, value, status, group, 3); -} +}; joyMIDI.sampler4Button = function(channel, control, value, status, group) { joyMIDI.samplerButton(channel, control, value, status, group, 4); -} +}; joyMIDI.samplerButton = function(channel, control, value, status, group, number) { var commands = ["start_play", "start_stop", "cue_gotoandplay", "cue_default"]; @@ -430,17 +430,17 @@ joyMIDI.samplerButton = function(channel, control, value, status, group, number) var val = (value > 0) ? 1 : 0; engine.setValue(group, cmd, val); -} +}; joyMIDI.fx1Button = function(channel, control, value, status, group) { joyMIDI.fxButton(channel, control, value, status, group, "[EffectRack1_EffectUnit1]", "group_"+group+"_enable", 1); -} +}; joyMIDI.fx2Button = function(channel, control, value, status, group) { joyMIDI.fxButton(channel, control, value, status, group, "[EffectRack1_EffectUnit2]", "group_"+group+"_enable", 2); -} +}; joyMIDI.fxButton = function(channel, control, value, status, group, group2, param, select) { if (!joyMIDI.userSetting.knobEnable) { @@ -466,7 +466,7 @@ joyMIDI.fxButton = function(channel, control, value, status, group, group2, para joyMIDI[group].btnFx[select] = RELEASED; } } -} +}; //==== Wheel ============================================================ joyMIDI.wheel = function(channel, control, value, status, group) { @@ -508,14 +508,14 @@ joyMIDI.wheel = function(channel, control, value, status, group) { } else { joyMIDI.wheelPitchBend(channel, control, value, status, group); } -} +}; joyMIDI.wheelPitchBend = function(channel, control, value, status, group) { var newValue = joyMIDI.helperAccel(value - 64); engine.setValue(group, "jog", newValue); print(group + "jog=" + newValue); -} +}; joyMIDI.wheelScratch = function(channel, control, value, status, group) { var deck = script.deckFromGroup(group); @@ -536,12 +536,12 @@ joyMIDI.wheelScratch = function(channel, control, value, status, group) { joyMIDI[group].scratchTimerID = engine.beginTimer(scratchDisableTime, function() { joyMIDI.ScratchTimerHandler(deck, group); }, true); -} +}; -joyMIDI.ScratchTimerHandler = function(deck, group){ +joyMIDI.ScratchTimerHandler = function(deck, group) { engine.scratchDisable(deck); joyMIDI[group].scratchTimerID = 0; -} +}; joyMIDI.wheelSync = function(channel, control, value, status, group) { var delta = joyMIDI.helperAccel(value - 64) * 0.01; @@ -551,7 +551,7 @@ joyMIDI.wheelSync = function(channel, control, value, status, group) { newValue = joyMIDI.helperLimit(newValue, 1.0, -1.0); engine.setValue(group, "rate", newValue); print(group + "rate=" + newValue); -} +}; joyMIDI.wheelKey = function(channel, control, value, status, group) { var delta = /*joyMIDI.helperAccel*/(value - 64) * 0.2; @@ -561,7 +561,7 @@ joyMIDI.wheelKey = function(channel, control, value, status, group) { newValue = joyMIDI.helperLimit(newValue, 6.0, -6.0); engine.setValue(group, "pitch", newValue); print(group + "pitch=" + newValue); -} +}; joyMIDI.wheelBeatgrid = function(channel, control, value, status, group) { var delta = joyMIDI.helperAccel(value - 64); @@ -576,7 +576,7 @@ joyMIDI.wheelBeatgrid = function(channel, control, value, status, group) { print(group + "beats_translate_later"); } } -} +}; joyMIDI.wheelVolume = function(channel, control, value, status, group) { var delta = joyMIDI.helperAccel(value - 64) * 0.01; @@ -586,22 +586,22 @@ joyMIDI.wheelVolume = function(channel, control, value, status, group) { newValue = joyMIDI.helperLimit(newValue, 1.0, 0); engine.setValue(group, "volume", newValue); print(group + "volume=" + newValue); -} +}; joyMIDI.wheelFilterLow = function(channel, control, value, status, group) { joyMIDI.wheelFilter(channel, control, value, status, group, "[EqualizerRack1_" + group + "_Effect1]", "parameter1", "low"); -} +}; joyMIDI.wheelFilterMiddle = function(channel, control, value, status, group) { joyMIDI.wheelFilter(channel, control, value, status, group, "[EqualizerRack1_" + group + "_Effect1]", "parameter2", "middle"); -} +}; joyMIDI.wheelFilterHigh = function(channel, control, value, status, group) { joyMIDI.wheelFilter(channel, control, value, status, group, "[EqualizerRack1_" + group + "_Effect1]", "parameter3", "high"); -} +}; joyMIDI.wheelFilter = function(channel, control, value, status, group, group2, param, select) { var delta = joyMIDI.helperAccel(value - 64) * 0.01; @@ -611,7 +611,7 @@ joyMIDI.wheelFilter = function(channel, control, value, status, group, group2, p newValue = joyMIDI.helperLimit(newValue, 1.0, 0); engine.setParameter(group2, param, newValue); print(group + "EQ_" + select + "=" + newValue); -} +}; joyMIDI.wheelFx1 = function(channel, control, value, status, group) { if (group === "[Channel1]") { @@ -621,7 +621,7 @@ joyMIDI.wheelFx1 = function(channel, control, value, status, group) { joyMIDI.wheelFx(channel, control, value, status, group, "[EffectRack1_EffectUnit2]", "mix", 1); } -} +}; joyMIDI.wheelFx2 = function(channel, control, value, status, group) { if (group === "[Channel1]") { @@ -631,27 +631,26 @@ joyMIDI.wheelFx2 = function(channel, control, value, status, group) { joyMIDI.wheelFx(channel, control, value, status, group, "[EffectRack1_EffectUnit2]", "super1", 2); } -} +}; -joyMIDI.wheelFx = function(channel, control, value, status, group, group2, param, select) { +joyMIDI.wheelFx = function(channel, control, value, status, group, group2, param, _select) { var delta = joyMIDI.helperAccel(value - 64) * 0.01; var oldValue = engine.getParameter(group2, param); var newValue = oldValue + delta; newValue = joyMIDI.helperLimit(newValue, 1.0, 0); engine.setParameter(group2, param, newValue); -} +}; //==== Jojstick ============================================================ -joyMIDI.joystick = function(channel, control, value, status, group) { +joyMIDI.joystick = function(channel, control, _value, _status, _group) { if (joystickDelay === false) { /* Delay a while */ joystickDelay = true; engine.beginTimer(300, function() { joystickDelay = false; }, true); - var isShift = joyMIDI["[Channel1]"].btnShift === true || joyMIDI["[Channel2]"].btnShift === true; if (!joyMIDI["[Channel1]"].btnShift) { /* Joystick only */ switch (control) { @@ -670,11 +669,11 @@ joyMIDI.joystick = function(channel, control, value, status, group) { } } } -} +}; //==== FSR ============================================================ -joyMIDI.fsr = function(channel, control, value, status, group) { +joyMIDI.fsr = function(_channel, _control, _value, _status, _group) { if (fsrDelay === false) { /* Delay a while */ @@ -690,14 +689,14 @@ joyMIDI.fsr = function(channel, control, value, status, group) { engine.setValue("[Library]", "MoveFocusBackward", true); } } -} +}; //==== Helper ============================================================= joyMIDI.helperLimit = function(input, max, min) { input = input > max ? max : input; input = input < min ? min : input; return input; -} +}; joyMIDI.helperAccel = function(input) { var acc = 0; @@ -708,4 +707,4 @@ joyMIDI.helperAccel = function(input) { acc = input; } return acc; -} +}; diff --git a/res/controllers/novation-launchpad/.eslintrc.yaml b/res/controllers/novation-launchpad/.eslintrc.yaml deleted file mode 100644 index ac9d79ec089..00000000000 --- a/res/controllers/novation-launchpad/.eslintrc.yaml +++ /dev/null @@ -1,57 +0,0 @@ -env: - node: true - es6: true - -extends: standard -parser: babel-eslint -plugins: - - import - - flowtype -rules: - # sort-imports: error - import/no-duplicates: error - no-duplicate-imports: off # see https://github.com/babel/eslint-plugin-babel/issues/59 - flowtype/boolean-style: - - 2 - - boolean - flowtype/define-flow-type: 1 - flowtype/delimiter-dangle: - - 2 - - never - flowtype/generic-spacing: - - 2 - - never - flowtype/no-primitive-constructor-types: 2 - # flowtype/no-weak-types: 2 - flowtype/object-type-delimiter: - - 2 - - comma - # flowtype/require-parameter-type: 2 - # flowtype/require-return-type: - # - 2 - # - always - # - annotateUndefined: never - flowtype/require-valid-file-annotation: 2 - flowtype/semi: - - 2 - - never - flowtype/space-after-type-colon: - - 2 - - always - flowtype/space-before-generic-bracket: - - 2 - - never - flowtype/space-before-type-colon: - - 2 - - never - flowtype/type-id-match: - - 2 - - "^([A-Z][a-z0-9]+)+$" - flowtype/union-intersection-spacing: - - 2 - - always - flowtype/use-flow-type: 1 - flowtype/valid-syntax: 1 -settings: - flowtype: - onlyFilesWithFlowAnnotation: false diff --git a/script/.eslintrc.json b/script/.eslintrc.json new file mode 100644 index 00000000000..16bdb96c043 --- /dev/null +++ b/script/.eslintrc.json @@ -0,0 +1,7 @@ +{ + "globals": { + "__extension__": "readonly", + "__setupPackage__": "readonly", + "__postInit__": "readonly" + } +}