Skip to content

Commit

Permalink
Upgrade to Prettier 3 (mastodon#25902)
Browse files Browse the repository at this point in the history
  • Loading branch information
renchap authored Jul 13, 2023
1 parent 0d73403 commit 73b64b8
Show file tree
Hide file tree
Showing 20 changed files with 82 additions and 56 deletions.
2 changes: 1 addition & 1 deletion app/javascript/mastodon/components/animated_number.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const AnimatedNumber: React.FC<Props> = ({ value, obfuscate }) => {
const willEnter = useCallback(() => ({ y: -1 * direction }), [direction]);
const willLeave = useCallback(
() => ({ y: spring(1 * direction, { damping: 35, stiffness: 400 }) }),
[direction]
[direction],
);

if (reduceMotion) {
Expand Down
6 changes: 3 additions & 3 deletions app/javascript/mastodon/components/counters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FormattedMessage } from 'react-intl';

export const StatusesCounter = (
displayNumber: React.ReactNode,
pluralReady: number
pluralReady: number,
) => (
<FormattedMessage
id='account.statuses_counter'
Expand All @@ -18,7 +18,7 @@ export const StatusesCounter = (

export const FollowingCounter = (
displayNumber: React.ReactNode,
pluralReady: number
pluralReady: number,
) => (
<FormattedMessage
id='account.following_counter'
Expand All @@ -32,7 +32,7 @@ export const FollowingCounter = (

export const FollowersCounter = (
displayNumber: React.ReactNode,
pluralReady: number
pluralReady: number,
) => (
<FormattedMessage
id='account.followers_counter'
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/components/gifv.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const GIFV: React.FC<Props> = ({
onClick();
}
},
[onClick]
[onClick],
);

return (
Expand Down
14 changes: 7 additions & 7 deletions app/javascript/mastodon/components/relative_timestamp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const timeAgoString = (
now: number,
year: number,
timeGiven: boolean,
short?: boolean
short?: boolean,
) => {
const delta = now - date.getTime();

Expand All @@ -118,28 +118,28 @@ export const timeAgoString = (
relativeTime = intl.formatMessage(messages.today);
} else if (delta < 10 * SECOND) {
relativeTime = intl.formatMessage(
short ? messages.just_now : messages.just_now_full
short ? messages.just_now : messages.just_now_full,
);
} else if (delta < 7 * DAY) {
if (delta < MINUTE) {
relativeTime = intl.formatMessage(
short ? messages.seconds : messages.seconds_full,
{ number: Math.floor(delta / SECOND) }
{ number: Math.floor(delta / SECOND) },
);
} else if (delta < HOUR) {
relativeTime = intl.formatMessage(
short ? messages.minutes : messages.minutes_full,
{ number: Math.floor(delta / MINUTE) }
{ number: Math.floor(delta / MINUTE) },
);
} else if (delta < DAY) {
relativeTime = intl.formatMessage(
short ? messages.hours : messages.hours_full,
{ number: Math.floor(delta / HOUR) }
{ number: Math.floor(delta / HOUR) },
);
} else {
relativeTime = intl.formatMessage(
short ? messages.days : messages.days_full,
{ number: Math.floor(delta / DAY) }
{ number: Math.floor(delta / DAY) },
);
}
} else if (date.getFullYear() === year) {
Expand All @@ -158,7 +158,7 @@ const timeRemainingString = (
intl: IntlShape,
date: Date,
now: number,
timeGiven = true
timeGiven = true,
) => {
const delta = date.getTime() - now;

Expand Down
4 changes: 2 additions & 2 deletions app/javascript/mastodon/components/short_number.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { toShortNumber, pluralReady, DECIMAL_UNITS } from '../utils/numbers';

type ShortNumberRenderer = (
displayNumber: JSX.Element,
pluralReady: number
pluralReady: number,
) => JSX.Element;

interface ShortNumberProps {
Expand All @@ -25,7 +25,7 @@ export const ShortNumberRenderer: React.FC<ShortNumberProps> = ({

if (children && renderer) {
console.warn(
'Both renderer prop and renderer as a child provided. This is a mistake and you really should fix that. Only renderer passed as a child will be used.'
'Both renderer prop and renderer as a child provided. This is a mistake and you really should fix that. Only renderer passed as a child will be used.',
);
}

Expand Down
4 changes: 2 additions & 2 deletions app/javascript/mastodon/features/emoji/emoji_compressed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type SearchData = [
BaseEmoji['native'],
Emoji['short_names'],
Search,
Emoji['unified']
Emoji['unified'],
];

export interface ShortCodesToEmojiData {
Expand All @@ -38,7 +38,7 @@ export type EmojiCompressed = [
Skins,
Category[],
Data['aliases'],
EmojisWithoutShortCodes
EmojisWithoutShortCodes,
];

/*
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/polyfills/base_polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (!HTMLCanvasElement.prototype.toBlob) {
this: HTMLCanvasElement,
callback: BlobCallback,
type = 'image/png',
quality: unknown
quality: unknown,
) {
const dataURL: string = this.toDataURL(type, quality);
let data;
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const initialRootState = Object.fromEntries(
reducer(undefined, {
// empty action
}),
])
]),
);

const RootStateRecord = ImmutableRecord(initialRootState, 'RootState');
Expand Down
14 changes: 7 additions & 7 deletions app/javascript/mastodon/reducers/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface PopModalOption {
}
const popModal = (
state: State,
{ modalType, ignoreFocus }: PopModalOption
{ modalType, ignoreFocus }: PopModalOption,
): State => {
if (
modalType === undefined ||
Expand All @@ -52,12 +52,12 @@ const popModal = (
const pushModal = (
state: State,
modalType: ModalType,
modalProps: ModalProps
modalProps: ModalProps,
): State => {
return state.withMutations((record) => {
record.set('ignoreFocus', false);
record.update('stack', (stack) =>
stack.unshift(Modal({ modalType, modalProps }))
stack.unshift(Modal({ modalType, modalProps })),
);
});
};
Expand All @@ -68,14 +68,14 @@ export function modalReducer(
modalType: ModalType;
ignoreFocus: boolean;
modalProps: Record<string, unknown>;
}>
}>,
) {
switch (action.type) {
case openModal.type:
return pushModal(
state,
action.payload.modalType,
action.payload.modalProps
action.payload.modalProps,
);
case closeModal.type:
return popModal(state, action.payload);
Expand All @@ -85,8 +85,8 @@ export function modalReducer(
return state.update('stack', (stack) =>
stack.filterNot(
// @ts-expect-error TIMELINE_DELETE action is not typed yet.
(modal) => modal.get('modalProps').statusId === action.id
)
(modal) => modal.get('modalProps').statusId === action.id,
),
);
default:
return state;
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/mastodon/scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ const easingOutQuint = (
t: number,
b: number,
c: number,
d: number
d: number,
) => c * ((t = t / d - 1) * t * t * t * t + 1) + b;
const scroll = (
node: Element,
key: 'scrollTop' | 'scrollLeft',
target: number
target: number,
) => {
const startTime = Date.now();
const offset = node[key];
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const store = configureStore({
.concat(
loadingBarMiddleware({
promiseTypeSuffixes: ['REQUEST', 'SUCCESS', 'FAIL'],
})
}),
)
.concat(errorsMiddleware)
.concat(soundsMiddleware()),
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/store/middlewares/loading_bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const defaultTypeSuffixes: Config['promiseTypeSuffixes'] = [
];

export const loadingBarMiddleware = (
config: Config = {}
config: Config = {},
): Middleware<Record<string, never>, RootState> => {
const promiseTypeSuffixes = config.promiseTypeSuffixes || defaultTypeSuffixes;

Expand Down
4 changes: 2 additions & 2 deletions app/javascript/mastodon/utils/hashtags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const buildHashtagPatternRegex = () => {
try {
return new RegExp(
`(?:^|[^\\/\\)\\w])#(([${WORD}_][${WORD}${HASHTAG_SEPARATORS}]*[${ALPHA}${HASHTAG_SEPARATORS}][${WORD}${HASHTAG_SEPARATORS}]*[${WORD}_])|([${WORD}_]*[${ALPHA}][${WORD}_]*))`,
'iu'
'iu',
);
} catch {
return /(?:^|[^/)\w])#(\w*[a-zA-Z·]\w*)/i;
Expand All @@ -17,7 +17,7 @@ const buildHashtagRegex = () => {
try {
return new RegExp(
`^(([${WORD}_][${WORD}${HASHTAG_SEPARATORS}]*[${ALPHA}${HASHTAG_SEPARATORS}][${WORD}${HASHTAG_SEPARATORS}]*[${WORD}_])|([${WORD}_]*[${ALPHA}][${WORD}_]*))$`,
'iu'
'iu',
);
} catch {
return /^(\w*[a-zA-Z·]\w*)$/i;
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/utils/numbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function toShortNumber(sourceNumber: number): ShortNumber {
*/
export function pluralReady(
sourceNumber: number,
division: DecimalUnits
division: DecimalUnits,
): number {
if (division == null || division < DECIMAL_UNITS.HUNDRED) {
return sourceNumber;
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/styles/fonts/roboto-mono.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@font-face {
font-family: mastodon-font-monospace;
src: local('Roboto Mono'),
src:
local('Roboto Mono'),
url('../fonts/roboto-mono/robotomono-regular-webfont.woff2') format('woff2'),
url('../fonts/roboto-mono/robotomono-regular-webfont.woff') format('woff'),
url('../fonts/roboto-mono/robotomono-regular-webfont.ttf')
Expand Down
12 changes: 8 additions & 4 deletions app/javascript/styles/fonts/roboto.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@font-face {
font-family: mastodon-font-sans-serif;
src: local('Roboto Italic'),
src:
local('Roboto Italic'),
url('../fonts/roboto/roboto-italic-webfont.woff2') format('woff2'),
url('../fonts/roboto/roboto-italic-webfont.woff') format('woff'),
url('../fonts/roboto/roboto-italic-webfont.ttf') format('truetype'),
Expand All @@ -13,7 +14,8 @@

@font-face {
font-family: mastodon-font-sans-serif;
src: local('Roboto Bold'),
src:
local('Roboto Bold'),
url('../fonts/roboto/roboto-bold-webfont.woff2') format('woff2'),
url('../fonts/roboto/roboto-bold-webfont.woff') format('woff'),
url('../fonts/roboto/roboto-bold-webfont.ttf') format('truetype'),
Expand All @@ -26,7 +28,8 @@

@font-face {
font-family: mastodon-font-sans-serif;
src: local('Roboto Medium'),
src:
local('Roboto Medium'),
url('../fonts/roboto/roboto-medium-webfont.woff2') format('woff2'),
url('../fonts/roboto/roboto-medium-webfont.woff') format('woff'),
url('../fonts/roboto/roboto-medium-webfont.ttf') format('truetype'),
Expand All @@ -39,7 +42,8 @@

@font-face {
font-family: mastodon-font-sans-serif;
src: local('Roboto'),
src:
local('Roboto'),
url('../fonts/roboto/roboto-regular-webfont.woff2') format('woff2'),
url('../fonts/roboto/roboto-regular-webfont.woff') format('woff'),
url('../fonts/roboto/roboto-regular-webfont.ttf') format('truetype'),
Expand Down
16 changes: 13 additions & 3 deletions app/javascript/styles/mastodon/basics.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,19 @@ body {
// Droid Sans => Older Androids (<4.0)
// Helvetica Neue => Older macOS <10.11
// $font-sans-serif => web-font (Roboto) fallback and newer Androids (>=4.0)
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
$font-sans-serif, sans-serif;
font-family:
system-ui,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
Oxygen,
Ubuntu,
Cantarell,
'Fira Sans',
'Droid Sans',
'Helvetica Neue',
$font-sans-serif,
sans-serif;
}

&.app-body {
Expand Down
21 changes: 15 additions & 6 deletions app/javascript/styles/mastodon/components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,9 @@ body > [data-popper-placement] {
}

.no-reduce-motion .spoiler-input {
transition: height 0.4s ease, opacity 0.4s ease;
transition:
height 0.4s ease,
opacity 0.4s ease;
}

.sign-in-banner {
Expand Down Expand Up @@ -3954,7 +3956,9 @@ a.status-card.compact:hover {
overflow-y: auto;
border-bottom: 1px solid lighten($ui-base-color, 8%);
color: $darker-text-color;
transition: max-height 150ms ease-in-out, opacity 300ms linear;
transition:
max-height 150ms ease-in-out,
opacity 300ms linear;
opacity: 1;
z-index: 1;
position: relative;
Expand Down Expand Up @@ -6935,7 +6939,8 @@ noscript {
.navigation-bar {
& > a:first-child {
will-change: margin-top, margin-inline-start, margin-inline-end, width;
transition: margin-top $duration $delay,
transition:
margin-top $duration $delay,
margin-inline-start $duration ($duration + $delay),
margin-inline-end $duration ($duration + $delay);
}
Expand All @@ -6948,12 +6953,15 @@ noscript {
.navigation-bar__actions {
& > .icon-button.close {
will-change: opacity transform;
transition: opacity $duration * 0.5 $delay, transform $duration $delay;
transition:
opacity $duration * 0.5 $delay,
transform $duration $delay;
}

& > .compose__action-bar .icon-button {
will-change: opacity transform;
transition: opacity $duration * 0.5 $delay + $duration * 0.5,
transition:
opacity $duration * 0.5 $delay + $duration * 0.5,
transform $duration $delay;
}
}
Expand Down Expand Up @@ -9094,7 +9102,8 @@ noscript {
backdrop-filter: blur(8px);
border: 1px solid rgba(lighten($classic-base-color, 4%), 0.85);
border-radius: 8px;
box-shadow: 0 10px 15px -3px rgba($base-shadow-color, 0.25),
box-shadow:
0 10px 15px -3px rgba($base-shadow-color, 0.25),
0 4px 6px -4px rgba($base-shadow-color, 0.25);
cursor: default;
transition: 0.5s cubic-bezier(0.89, 0.01, 0.5, 1.1);
Expand Down
Loading

0 comments on commit 73b64b8

Please sign in to comment.