Skip to content

Commit

Permalink
fix linter issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bradenhs committed Dec 9, 2023
1 parent 7928114 commit 28cb3d9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 23 deletions.
21 changes: 11 additions & 10 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
module.exports = {
"extends": [
extends: [
"react-app",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
"plugin:prettier/recommended",
],
"rules": {
rules: {
"prettier/prettier": ["warn"],
"no-unused-expressions": "off",
"@typescript-eslint/no-unused-expressions": ["warn"]
"@typescript-eslint/no-unused-expressions": ["warn"],
"no-loop-func": "off",
},
"settings": {
"react": {
"version": "detect"
}
}
}
settings: {
react: {
version: "detect",
},
},
};
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"lodash": "^4.17.21",
"parcel": "^2.10.3",
"prettier": "^2.6.1",
"process": "^0.11.10",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"rollup": "^2.70.1",
Expand Down
22 changes: 11 additions & 11 deletions src/createLocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,34 +49,34 @@ export function createLocation({
paramDef["~internal"].valueSerializer.urlEncode ?? urlEncodeDefault;

const getValue = (paramValue: unknown) => {

let value: string | null;

if (paramDef["~internal"].array) {
if (!Array.isArray(paramValue)) {
if (__DEV__) {
throw TypeRouteError.Expected_type_does_not_match_actual_type.create({
context: "routes[routeName](...)",
actualType: typeOf(paramValue),
expectedType: "array",
value: paramValue,
valueName: paramName,
});
throw TypeRouteError.Expected_type_does_not_match_actual_type.create(
{
context: "routes[routeName](...)",
actualType: typeOf(paramValue),
expectedType: "array",
value: paramValue,
valueName: paramName,
}
);
}
}

value =
(paramValue as unknown[]).length === 0
? null
: (paramValue as unknown[])
.map((part) => stringify(paramDef, part, urlEncode))
.join(arraySeparator);
.map((part) => stringify(paramDef, part, urlEncode))
.join(arraySeparator);
} else {
value = stringify(paramDef, paramValue, urlEncode);
}

return value;

};

const value = getValue(paramValue);
Expand Down
2 changes: 0 additions & 2 deletions test/createRouter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,6 @@ describe("createRouter", () => {
expect(route.href).toBe("/bar?page=2");
});


it("should not include default query params in href", () => {
const { routes, session } = createRouter(
{
Expand Down Expand Up @@ -566,7 +565,6 @@ describe("createRouter", () => {

routes.bar({ page: 2 }).push();
expect(route.href).toBe("/bar?page=2");

});

it("should handle redirect for initial route", () => {
Expand Down

0 comments on commit 28cb3d9

Please sign in to comment.