Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
dangowans committed Jun 27, 2024
1 parent 2399765 commit 8fa4fcb
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 22 deletions.
9 changes: 4 additions & 5 deletions public-typescript/adminOccupancyTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
function moveOccupancyTypeField(clickEvent) {
const buttonElement = clickEvent.currentTarget;
const occupancyTypeFieldId = clickEvent.currentTarget.closest('.container--occupancyTypeField').dataset.occupancyTypeFieldId;
cityssm.postJSON(los.urlPrefix +
'/admin/' +
(buttonElement.dataset.direction === 'up'
? 'doMoveOccupancyTypeFieldUp'
: 'doMoveOccupancyTypeFieldDown'), {
cityssm.postJSON(`${los.urlPrefix}/admin/${buttonElement.dataset.direction === 'up'
? 'doMoveOccupancyTypeFieldUp'
: // eslint-disable-next-line no-secrets/no-secrets
'doMoveOccupancyTypeFieldDown'}`, {
occupancyTypeFieldId,
moveToEnd: clickEvent.shiftKey ? '1' : '0'
}, occupancyTypeResponseHandler);
Expand Down
11 changes: 6 additions & 5 deletions public-typescript/adminOccupancyTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ type ResponseJSON =
modalElement.querySelector(
'#occupancyTypeFieldEdit--isRequired'
) as HTMLSelectElement
).value = (occupancyTypeField.isRequired ?? false) ? '1' : '0'
).value = occupancyTypeField.isRequired ?? false ? '1' : '0'

minimumLengthElement = modalElement.querySelector(
'#occupancyTypeFieldEdit--minimumLength'
Expand Down Expand Up @@ -481,11 +481,12 @@ type ResponseJSON =
).dataset.occupancyTypeFieldId

cityssm.postJSON(
los.urlPrefix +
'/admin/' +
(buttonElement.dataset.direction === 'up'
`${los.urlPrefix}/admin/${
buttonElement.dataset.direction === 'up'
? 'doMoveOccupancyTypeFieldUp'
: 'doMoveOccupancyTypeFieldDown'),
: // eslint-disable-next-line no-secrets/no-secrets
'doMoveOccupancyTypeFieldDown'
}`,
{
occupancyTypeFieldId,
moveToEnd: clickEvent.shiftKey ? '1' : '0'
Expand Down
18 changes: 13 additions & 5 deletions public-typescript/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,18 +211,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
/*
* Colours
*/
const hues = ['red', 'green', 'orange', 'blue', 'pink', 'yellow', 'purple'];
const hues = [
'red',
'green',
'orange',
'blue',
'pink',
'yellow',
'purple'
];
const luminosity = ['bright', 'light', 'dark'];
function getRandomColor(seedString) {
let actualSeedString = seedString;
if (actualSeedString.length < 2) {
actualSeedString = actualSeedString + 'a1';
actualSeedString += 'a1';
}
return exports.randomColor({
seed: actualSeedString + actualSeedString,
hue: hues[actualSeedString.codePointAt(actualSeedString.length - 1) % hues.length],
luminosity: luminosity[actualSeedString.codePointAt(actualSeedString.length - 2) %
luminosity.length]
hue: hues[actualSeedString.codePointAt(actualSeedString.length - 1) %
hues.length],
luminosity: luminosity[actualSeedString.codePointAt(actualSeedString.length - 2) % luminosity.length]
});
}
/*
Expand Down
41 changes: 35 additions & 6 deletions public-typescript/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,29 @@ import type { Options as BulmaCalendarOptions } from 'bulma-calendar'

import type * as globalTypes from '../types/globalTypes.js'

type RandomColorHue =
| 'red'
| 'orange'
| 'yellow'
| 'green'
| 'blue'
| 'purple'
| 'pink'
| 'monochrome'
type RandomColorLuminosity = 'bright' | 'light' | 'dark'

declare const cityssm: cityssmGlobal
declare const bulmaJS: BulmaJS
declare const exports: Record<string, unknown> & {
aliases: Record<string, string>
randomColor: (options?: {
hue?: RandomColorHue
luminosity?: RandomColorLuminosity
count?: number
seed?: number | string
format?: 'rgb' | 'rgba' | 'rgbArray' | 'hsl' | 'hsla' | 'hslArray' | 'hex'
alpha?: number
}) => string
}
;(() => {
/*
Expand Down Expand Up @@ -301,25 +320,35 @@ declare const exports: Record<string, unknown> & {
* Colours
*/

const hues = ['red', 'green', 'orange', 'blue', 'pink', 'yellow', 'purple']
const luminosity = ['bright', 'light', 'dark']
const hues = [
'red',
'green',
'orange',
'blue',
'pink',
'yellow',
'purple'
] as RandomColorHue[]
const luminosity = ['bright', 'light', 'dark'] as RandomColorLuminosity[]

function getRandomColor(seedString: string): string {
let actualSeedString = seedString

if (actualSeedString.length < 2) {
actualSeedString = actualSeedString + 'a1'
actualSeedString += 'a1'
}

return exports.randomColor({
seed: actualSeedString + actualSeedString,
hue: hues[
actualSeedString.codePointAt(actualSeedString.length - 1)! % hues.length
(actualSeedString.codePointAt(actualSeedString.length - 1) as number) %
hues.length
],
luminosity:
luminosity[
actualSeedString.codePointAt(actualSeedString.length - 2)! %
luminosity.length
(actualSeedString.codePointAt(
actualSeedString.length - 2
) as number) % luminosity.length
]
})
}
Expand Down
Loading

0 comments on commit 8fa4fcb

Please sign in to comment.