Skip to content
Permalink
Browse files

VSCode: Add import sorter

  • Loading branch information
tvillarete committed Dec 28, 2019
1 parent e7e0a03 commit 29512d5e42885c12792f628a8b463d821fcbd676
Showing with 44 additions and 5 deletions.
  1. +38 −0 .vscode/settings.json
  2. +1 −1 src/hooks/useTimeout.ts
  3. +5 −4 src/hooks/useVolumeHandler.ts
@@ -0,0 +1,38 @@
{
/**
* Import sorter
*
* Rules for sorting the imports. Sort the imports in a standardized manner.
* First react, then external imports, then folder imports
*/

"importSorter.sortConfiguration.customOrderingRules.rules": [
{
"type": "importMember",
"regex": "^$",
"orderLevel": 10,
"disableSort": true
},
{
"regex": "^react",
"orderLevel": 20
},
{
"regex": "^([@]|[^.~])",
"orderLevel": 30
},
{
"regex": "^[~]",
"orderLevel": 40
},
{
"regex": "^[.]",
"orderLevel": 50
}
],
"importSorter.generalConfiguration.sortOnBeforeSave": true,
"importSorter.importStringConfiguration.maximumNumberOfImportExpressionsPerLine.type": "newLineEachExpressionAfterCountLimitExceptIfOnlyOne",
"importSorter.importStringConfiguration.maximumNumberOfImportExpressionsPerLine.count": 80,
"importSorter.importStringConfiguration.tabSize": 2,
"importSorter.importStringConfiguration.trailingComma": "multiLine"
}
@@ -1,4 +1,4 @@
import { useEffect, useCallback, useRef } from "react";
import { useCallback, useEffect, useRef } from 'react';

// React hook for delaying calls with time
// returns callback to use for cancelling
@@ -1,5 +1,6 @@
import { useState, useCallback, useRef, useEffect } from "react";
import useEventListener from "./useEventListener";
import { useCallback, useEffect, useRef, useState } from 'react';

import useEventListener from './useEventListener';

interface VolumeHandlerHook {
volume: number;
@@ -38,19 +39,19 @@ const useVolumeHandler = (): VolumeHandlerHook => {
}, []);

const increaseVolume = useCallback(() => {
setActiveState();
if (volume === 100 || !enabled) return;
const audio = document.getElementById("ipodAudio") as HTMLAudioElement;

setActiveState();
audio.volume = (volume + 4) / 100;
setVolume(volume + 4);
}, [volume, enabled, setActiveState]);

const decreaseVolume = useCallback(() => {
setActiveState();
if (volume === 0 || !enabled) return;
const audio = document.getElementById("ipodAudio") as HTMLAudioElement;

setActiveState();
audio.volume = (volume - 4) / 100;
setVolume(volume - 4);
}, [volume, enabled, setActiveState]);

0 comments on commit 29512d5

Please sign in to comment.
You can’t perform that action at this time.