From 9fc42f01ee6609631a9d864da7e8c4da5cf5e583 Mon Sep 17 00:00:00 2001 From: Victor Lin <13424970+victorlin@users.noreply.github.com> Date: Thu, 4 May 2023 13:37:59 -0700 Subject: [PATCH] eslint: Address no-use-before-define violations There is only one, and it is because a function expression is used before it is defined. Changing to a function declaration solves this because those are hoisted to the top-level (function expressions are not). Rule doc page: https://eslint.org/docs/latest/rules/no-use-before-define --- .eslintrc.yaml | 2 +- src/util/getGenotype.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 061503271..8246fb083 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -20,7 +20,7 @@ globals: rules: # Code quality rules no-unused-vars: ["error", { "argsIgnorePattern": "^_", "destructuredArrayIgnorePattern": "^_" }] - # no-use-before-define: ["error", { "functions": false }] + no-use-before-define: ["error", { "functions": false }] # prefer-const: ["error", {"destructuring": "all"}] react/prop-types: off # Remove this override once all props have been typed using PropTypes or TypeScript. diff --git a/src/util/getGenotype.js b/src/util/getGenotype.js index 64e1d0a02..acdc1b418 100644 --- a/src/util/getGenotype.js +++ b/src/util/getGenotype.js @@ -60,12 +60,12 @@ export const decodeColorByGenotype = (colorBy, geneLengths) => { return null; }; -export const decodePositions = (positions, geneLength = 'Infinity') => { +export function decodePositions(positions, geneLength = 'Infinity') { return positions .split(",") .map((x) => parseInt(x, 10)) .filter((x) => x > 0 && x <= Math.floor(geneLength)); -}; +} /** * Encode genotype filters for storage in URL query state.