mirror of
				https://github.com/blakeblackshear/frigate.git
				synced 2025-10-27 10:52:11 +01:00 
			
		
		
		
	test(web): fix switch case indent lint
This commit is contained in:
		
							parent
							
								
									6d133ef724
								
							
						
					
					
						commit
						85776cc7d0
					
				@ -111,7 +111,7 @@ module.exports = {
 | 
				
			|||||||
    'valid-typeof': 'error',
 | 
					    'valid-typeof': 'error',
 | 
				
			||||||
    camelcase: 'off',
 | 
					    camelcase: 'off',
 | 
				
			||||||
    eqeqeq: ['error', 'allow-null'],
 | 
					    eqeqeq: ['error', 'allow-null'],
 | 
				
			||||||
    indent: ['error', 2],
 | 
					    indent: ['error', 2, { SwitchCase: 1 }],
 | 
				
			||||||
    quotes: ['error', 'single', 'avoid-escape'],
 | 
					    quotes: ['error', 'single', 'avoid-escape'],
 | 
				
			||||||
    radix: 'error',
 | 
					    radix: 'error',
 | 
				
			||||||
    yoda: ['error', 'never'],
 | 
					    yoda: ['error', 'never'],
 | 
				
			||||||
 | 
				
			|||||||
@ -19,23 +19,23 @@ const Api = createContext(initialState);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
function reducer(state, { type, payload, meta }) {
 | 
					function reducer(state, { type, payload, meta }) {
 | 
				
			||||||
  switch (type) {
 | 
					  switch (type) {
 | 
				
			||||||
  case 'REQUEST': {
 | 
					    case 'REQUEST': {
 | 
				
			||||||
    const { url, fetchId } = payload;
 | 
					      const { url, fetchId } = payload;
 | 
				
			||||||
    const data = state.queries[url]?.data || null;
 | 
					      const data = state.queries[url]?.data || null;
 | 
				
			||||||
    return produce(state, (draftState) => {
 | 
					      return produce(state, (draftState) => {
 | 
				
			||||||
      draftState.queries[url] = { status: FetchStatus.LOADING, data, fetchId };
 | 
					        draftState.queries[url] = { status: FetchStatus.LOADING, data, fetchId };
 | 
				
			||||||
    });
 | 
					      });
 | 
				
			||||||
  }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  case 'RESPONSE': {
 | 
					    case 'RESPONSE': {
 | 
				
			||||||
    const { url, ok, data, fetchId } = payload;
 | 
					      const { url, ok, data, fetchId } = payload;
 | 
				
			||||||
    return produce(state, (draftState) => {
 | 
					      return produce(state, (draftState) => {
 | 
				
			||||||
      draftState.queries[url] = { status: ok ? FetchStatus.LOADED : FetchStatus.ERROR, data, fetchId };
 | 
					        draftState.queries[url] = { status: ok ? FetchStatus.LOADED : FetchStatus.ERROR, data, fetchId };
 | 
				
			||||||
    });
 | 
					      });
 | 
				
			||||||
  }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  default:
 | 
					    default:
 | 
				
			||||||
    return state;
 | 
					      return state;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -38,29 +38,29 @@ export default function Select({ label, onChange, options: inputOptions = [], se
 | 
				
			|||||||
  const handleKeydown = useCallback(
 | 
					  const handleKeydown = useCallback(
 | 
				
			||||||
    (event) => {
 | 
					    (event) => {
 | 
				
			||||||
      switch (event.key) {
 | 
					      switch (event.key) {
 | 
				
			||||||
      case 'Enter': {
 | 
					        case 'Enter': {
 | 
				
			||||||
        if (!showMenu) {
 | 
					          if (!showMenu) {
 | 
				
			||||||
          setShowMenu(true);
 | 
					            setShowMenu(true);
 | 
				
			||||||
          setFocused(selected);
 | 
					            setFocused(selected);
 | 
				
			||||||
        } else {
 | 
					          } else {
 | 
				
			||||||
          setSelected(focused);
 | 
					            setSelected(focused);
 | 
				
			||||||
          onChange && onChange(options[focused].value, options[focused].label);
 | 
					            onChange && onChange(options[focused].value, options[focused].label);
 | 
				
			||||||
          setShowMenu(false);
 | 
					            setShowMenu(false);
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      case 'ArrowDown': {
 | 
					        case 'ArrowDown': {
 | 
				
			||||||
        const newIndex = focused + 1;
 | 
					          const newIndex = focused + 1;
 | 
				
			||||||
        newIndex < options.length && setFocused(newIndex);
 | 
					          newIndex < options.length && setFocused(newIndex);
 | 
				
			||||||
        break;
 | 
					          break;
 | 
				
			||||||
      }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      case 'ArrowUp': {
 | 
					        case 'ArrowUp': {
 | 
				
			||||||
        const newIndex = focused - 1;
 | 
					          const newIndex = focused - 1;
 | 
				
			||||||
        newIndex > -1 && setFocused(newIndex);
 | 
					          newIndex > -1 && setFocused(newIndex);
 | 
				
			||||||
        break;
 | 
					          break;
 | 
				
			||||||
      }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // no default
 | 
					        // no default
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
				
			|||||||
@ -14,32 +14,32 @@ const API_LIMIT = 25;
 | 
				
			|||||||
const initialState = Object.freeze({ events: [], reachedEnd: false, searchStrings: {} });
 | 
					const initialState = Object.freeze({ events: [], reachedEnd: false, searchStrings: {} });
 | 
				
			||||||
const reducer = (state = initialState, action) => {
 | 
					const reducer = (state = initialState, action) => {
 | 
				
			||||||
  switch (action.type) {
 | 
					  switch (action.type) {
 | 
				
			||||||
  case 'APPEND_EVENTS': {
 | 
					    case 'APPEND_EVENTS': {
 | 
				
			||||||
    const {
 | 
					      const {
 | 
				
			||||||
      meta: { searchString },
 | 
					        meta: { searchString },
 | 
				
			||||||
      payload,
 | 
					        payload,
 | 
				
			||||||
    } = action;
 | 
					      } = action;
 | 
				
			||||||
    return produce(state, (draftState) => {
 | 
					      return produce(state, (draftState) => {
 | 
				
			||||||
      draftState.searchStrings[searchString] = true;
 | 
					        draftState.searchStrings[searchString] = true;
 | 
				
			||||||
      draftState.events.push(...payload);
 | 
					        draftState.events.push(...payload);
 | 
				
			||||||
    });
 | 
					      });
 | 
				
			||||||
  }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  case 'REACHED_END': {
 | 
					    case 'REACHED_END': {
 | 
				
			||||||
    const {
 | 
					      const {
 | 
				
			||||||
      meta: { searchString },
 | 
					        meta: { searchString },
 | 
				
			||||||
    } = action;
 | 
					      } = action;
 | 
				
			||||||
    return produce(state, (draftState) => {
 | 
					      return produce(state, (draftState) => {
 | 
				
			||||||
      draftState.reachedEnd = true;
 | 
					        draftState.reachedEnd = true;
 | 
				
			||||||
      draftState.searchStrings[searchString] = true;
 | 
					        draftState.searchStrings[searchString] = true;
 | 
				
			||||||
    });
 | 
					      });
 | 
				
			||||||
  }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  case 'RESET':
 | 
					    case 'RESET':
 | 
				
			||||||
    return initialState;
 | 
					      return initialState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  default:
 | 
					    default:
 | 
				
			||||||
    return state;
 | 
					      return state;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user