Skip to content
Snippets Groups Projects
Commit 4fe264e9 authored by Paul Kaplan's avatar Paul Kaplan
Browse files

Fix all lint warnings except todo comments (including a bug!)

parent 3f1494e3
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,7 @@ const AudioTrimmer = props => ( ...@@ -10,7 +10,7 @@ const AudioTrimmer = props => (
className={styles.absolute} className={styles.absolute}
ref={props.containerRef} ref={props.containerRef}
> >
{props.trimStart !== null ? ( {props.trimStart === null ? null : (
<Box <Box
className={classNames(styles.absolute, styles.trimBackground, styles.startTrimBackground)} className={classNames(styles.absolute, styles.trimBackground, styles.startTrimBackground)}
style={{ style={{
...@@ -28,7 +28,7 @@ const AudioTrimmer = props => ( ...@@ -28,7 +28,7 @@ const AudioTrimmer = props => (
</Box> </Box>
</Box> </Box>
</Box> </Box>
) : null} )}
{props.playhead ? ( {props.playhead ? (
<Box <Box
...@@ -39,12 +39,12 @@ const AudioTrimmer = props => ( ...@@ -39,12 +39,12 @@ const AudioTrimmer = props => (
/> />
) : null} ) : null}
{props.trimEnd !== null ? ( {props.trimEnd === null ? null : (
<Box <Box
className={classNames(styles.absolute, styles.trimBackground, styles.endTrimBackground)} className={classNames(styles.absolute, styles.trimBackground, styles.endTrimBackground)}
style={{ style={{
left: `${100 * props.trimEnd}%`, left: `${100 * props.trimEnd}%`,
width: `${100 - 100 * props.trimEnd}%` width: `${100 - (100 * props.trimEnd)}%`
}} }}
onMouseDown={props.onTrimEndMouseDown} onMouseDown={props.onTrimEndMouseDown}
> >
...@@ -58,7 +58,7 @@ const AudioTrimmer = props => ( ...@@ -58,7 +58,7 @@ const AudioTrimmer = props => (
</Box> </Box>
</Box> </Box>
</Box> </Box>
) : null } )}
</div> </div>
); );
......
...@@ -17,7 +17,7 @@ const Meter = props => { ...@@ -17,7 +17,7 @@ const Meter = props => {
const barSpacing = 2.5; const barSpacing = 2.5;
const barRounding = 3; const barRounding = 3;
const barHeight = (height - barSpacing * (nBars + 1)) / nBars; const barHeight = (height - (barSpacing * (nBars + 1))) / nBars;
const nBarsToMask = nBars - Math.floor(level * nBars); const nBarsToMask = nBars - Math.floor(level * nBars);
...@@ -38,12 +38,12 @@ const Meter = props => { ...@@ -38,12 +38,12 @@ const Meter = props => {
ry={barRounding} ry={barRounding}
width={width - 2} width={width - 2}
x={1} x={1}
y={height - (barSpacing + barHeight) * (index + 1)} y={height - ((barSpacing + barHeight) * (index + 1))}
/> />
))} ))}
<rect <rect
fill="white" fill="white"
height={nBarsToMask * (barHeight + barSpacing) + barSpacing / 2} height={(nBarsToMask * (barHeight + barSpacing)) + (barSpacing / 2)}
opacity="0.75" opacity="0.75"
width={width} width={width}
x={0} x={0}
......
...@@ -57,7 +57,7 @@ const RecordingStep = props => ( ...@@ -57,7 +57,7 @@ const RecordingStep = props => (
className={styles.recordButtonCircleOutline} className={styles.recordButtonCircleOutline}
cx="26" cx="26"
cy="26" cy="26"
r={27 + props.level * 5} r={27 + (props.level * 5)}
/> />
</svg> </svg>
)} )}
......
...@@ -52,7 +52,7 @@ class AudioTrimmer extends React.Component { ...@@ -52,7 +52,7 @@ class AudioTrimmer extends React.Component {
render () { render () {
return ( return (
<AudioTrimmerComponent <AudioTrimmerComponent
containerRef={el => (this.containerElement = el)} containerRef={el => (this.containerElement = el)} // eslint-disable-line react/jsx-no-bind
playhead={this.props.playhead} playhead={this.props.playhead}
trimEnd={this.props.trimEnd} trimEnd={this.props.trimEnd}
trimStart={this.props.trimStart} trimStart={this.props.trimStart}
......
...@@ -20,7 +20,7 @@ class AudioBufferPlayer { ...@@ -20,7 +20,7 @@ class AudioBufferPlayer {
this.startTime = Date.now(); this.startTime = Date.now();
const trimStartTime = this.buffer.duration * trimStart; const trimStartTime = this.buffer.duration * trimStart;
const trimmedDuration = this.buffer.duration * trimEnd - trimStartTime; const trimmedDuration = (this.buffer.duration * trimEnd) - trimStartTime;
this.source = this.audioContext.createBufferSource(); this.source = this.audioContext.createBufferSource();
this.source.onended = onEnded; this.source.onended = onEnded;
......
...@@ -24,7 +24,7 @@ class AudioEffects { ...@@ -24,7 +24,7 @@ class AudioEffects {
let playbackRate = 1; let playbackRate = 1;
switch (name) { switch (name) {
case effectTypes.ECHO: case effectTypes.ECHO:
sampleCount = buffer.length + 0.25 * 3 * buffer.sampleRate; sampleCount = buffer.length + (0.25 * 3 * buffer.sampleRate);
break; break;
case effectTypes.FASTER: case effectTypes.FASTER:
playbackRate = pitchRatio; playbackRate = pitchRatio;
......
...@@ -18,15 +18,15 @@ class RobotEffect { ...@@ -18,15 +18,15 @@ class RobotEffect {
// Piecewise function given by (2) in Parker paper // Piecewise function given by (2) in Parker paper
const transform = (v, vb = 0.2, vl = 0.4, h = 0.65) => { const transform = (v, vb = 0.2, vl = 0.4, h = 0.65) => {
if (v <= vb) return 0; if (v <= vb) return 0;
if (v <= vl) return h * (Math.pow(v - vb, 2) / (2 * vl - 2 * vb)); if (v <= vl) return h * (Math.pow(v - vb, 2) / ((2 * vl) - (2 * vb)));
return h * v - h * vl + h * (Math.pow(v - vb, 2) / (2 * vl - 2 * vb)); return (h * v) - (h * vl) + (h * (Math.pow(v - vb, 2) / ((2 * vl) - (2 * vb))));
}; };
// Create the waveshaper curve with the voltage transform above // Create the waveshaper curve with the voltage transform above
const bufferLength = 1024; const bufferLength = 1024;
const curve = new Float32Array(bufferLength); const curve = new Float32Array(bufferLength);
for (let i = 0; i < bufferLength; i++) { for (let i = 0; i < bufferLength; i++) {
const voltage = 2 * (i / bufferLength) - 1; const voltage = (2 * (i / bufferLength)) - 1;
curve[i] = transform(voltage); curve[i] = transform(voltage);
} }
node.curve = curve; node.curve = curve;
......
// Wrap browser AudioContext because we shouldn't create more than one
const AUDIO_CONTEXT = new (window.AudioContext || window.webkitAudioContext)(); const AUDIO_CONTEXT = new (window.AudioContext || window.webkitAudioContext)();
/**
* Wrap browser AudioContext because we shouldn't create more than one
* @return {AudioContext} The singleton AudioContext
*/
export default function () { export default function () {
return AUDIO_CONTEXT; return AUDIO_CONTEXT;
} }
import ScratchBlocks from 'scratch-blocks'; import ScratchBlocks from 'scratch-blocks';
/**
* Connect scratch blocks with the vm
* @param {VirtualMachine} vm - The scratch vm
* @return {ScratchBlocks} ScratchBlocks connected with the vm
*/
export default function (vm) { export default function (vm) {
const jsonForMenuBlock = function (name, menuOptionsFn, colors, start) { const jsonForMenuBlock = function (name, menuOptionsFn, colors, start) {
......
/**
* Convert monitors from VM format to what the GUI needs to render.
* - Convert opcode to a label and a category
* - Add missing XY position data if needed
*/
import OpcodeLabels from './opcode-labels.js'; import OpcodeLabels from './opcode-labels.js';
const PADDING = 5; const PADDING = 5;
...@@ -10,6 +5,20 @@ const MONITOR_HEIGHT = 23; ...@@ -10,6 +5,20 @@ const MONITOR_HEIGHT = 23;
const isUndefined = a => typeof a === 'undefined'; const isUndefined = a => typeof a === 'undefined';
/**
* Convert monitors from VM format to what the GUI needs to render.
* - Convert opcode to a label and a category
* - Add missing XY position data if needed
* @param {object} block - The monitor block
* @param {string} block.id - The id of the monitor block
* @param {number} block.index - The index of the monitor
* @param {string} block.opcode - The opcode of the monitor
* @param {object} block.params - Extra params to the monitor block
* @param {string} block.value - The monitor value
* @param {number} x - The monitor x position
* @param {number} y - The monitor y position
* @return {object} The adapted monitor with label and category
*/
export default function ({id, index, opcode, params, value, x, y}) { export default function ({id, index, opcode, params, value, x, y}) {
let {label, category, labelFn} = OpcodeLabels(opcode); let {label, category, labelFn} = OpcodeLabels(opcode);
......
...@@ -66,6 +66,11 @@ const opcodeMap = { ...@@ -66,6 +66,11 @@ const opcodeMap = {
} }
}; };
/**
* Get the label for an opcode
* @param {string} opcode the opcode you want a label for
* @return {object} object with label and category
*/
export default function (opcode) { export default function (opcode) {
if (opcode in opcodeMap) return opcodeMap[opcode]; if (opcode in opcodeMap) return opcodeMap[opcode];
return { return {
......
...@@ -42,8 +42,8 @@ const getLogs = (whitelist) => { ...@@ -42,8 +42,8 @@ const getLogs = (whitelist) => {
console.warn('Ignoring non-SEVERE entry: ' + message); console.warn('Ignoring non-SEVERE entry: ' + message);
return false; return false;
} }
return true;
} }
return true;
}); });
}); });
}; };
......
...@@ -9,7 +9,7 @@ describe('computeRMS', () => { ...@@ -9,7 +9,7 @@ describe('computeRMS', () => {
const unity = 0.5; const unity = 0.5;
const samples = [3, 2, 1]; const samples = [3, 2, 1];
expect(computeRMS(samples, unity)).toEqual( expect(computeRMS(samples, unity)).toEqual(
Math.sqrt(Math.sqrt((3 * 3 + 2 * 2 + 1 * 1) / 3) / 0.5) Math.sqrt(Math.sqrt(((3 * 3) + (2 * 2) + (1 * 1)) / 3) / 0.5)
); );
}); });
test('uses a default unity value of 0.55', () => { test('uses a default unity value of 0.55', () => {
...@@ -28,8 +28,8 @@ describe('computeChunkedRMS', () => { ...@@ -28,8 +28,8 @@ describe('computeChunkedRMS', () => {
// rms scaled with default unity of 0.55 // rms scaled with default unity of 0.55
expect(chunkedLevels.length).toEqual(3); expect(chunkedLevels.length).toEqual(3);
expect(chunkedLevels).toEqual([ expect(chunkedLevels).toEqual([
Math.sqrt(Math.sqrt((2 * 2 + 1 * 1) / 2) / 0.55), Math.sqrt(Math.sqrt(((2 * 2) + (1 * 1)) / 2) / 0.55),
Math.sqrt(Math.sqrt((3 * 3 + 2 * 2) / 2) / 0.55), Math.sqrt(Math.sqrt(((3 * 3) + (2 * 2)) / 2) / 0.55),
Math.sqrt(Math.sqrt((5 * 5) / 1) / 0.55) Math.sqrt(Math.sqrt((5 * 5) / 1) / 0.55)
]); ]);
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment