Skip to content

Commit

Permalink
New prettier changes due to upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
PeteCoward committed May 11, 2023
1 parent b1eaba2 commit 53d9d8e
Show file tree
Hide file tree
Showing 19 changed files with 125 additions and 125 deletions.
12 changes: 6 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ module.exports = {
extends: ['torchbox', 'plugin:@typescript-eslint/recommended'],
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module'
sourceType: 'module',
},
rules: {
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'react/jsx-filename-extension': [1, { extensions: ['.jsx', '.tsx'] }]
'react/jsx-filename-extension': [1, { extensions: ['.jsx', '.tsx'] }],
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx']
}
}
}
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
},
};
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
needs: lint
strategy:
matrix:
python: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python: ['3.7', '3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v3
Expand All @@ -55,8 +55,8 @@ jobs:
needs: lint
strategy:
matrix:
python: ["3.7", "3.8", "3.9", "3.10", "3.11"]
database: ["postgres"]
python: ['3.7', '3.8', '3.9', '3.10', '3.11']
database: ['postgres']

services:
postgres:
Expand Down
10 changes: 5 additions & 5 deletions scripts/extract-translatable-strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ extractor
JsExtractors.callExpression('gettext', {
arguments: {
text: 0,
context: 1
}
context: 1,
},
}),
JsExtractors.callExpression('ngettext', {
arguments: {
text: 1,
textPlural: 2,
context: 3
}
})
context: 3,
},
}),
])
.parseFilesGlob('./wagtail_localize/static_src/**/*.@(ts|js|tsx|jsx)');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ interface ActionMenuProps {
const ActionMenu: FunctionComponent<ActionMenuProps> = ({
defaultAction,
actions,
previewModes
previewModes,
}) => {
const wrappedActions = actions.map(action => <li>{action}</li>);
const wrappedActions = actions.map((action) => <li>{action}</li>);

return (
<nav aria-label="Actions">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ const Avatar: FunctionComponent<AvatarProps> = ({ username, avatarUrl }) => {
if (ref.current) {
$(ref.current).tooltip({
animation: false,
title: function() {
title: function () {
return username;
},
trigger: 'hover',
placement: 'bottom'
placement: 'bottom',
});
}
}, [ref]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface DocumentChooserProps {

const DocumentChooser: FunctionComponent<DocumentChooserProps> = ({
adminBaseUrl,
documentId
documentId,
}) => {
const [documentInfo, setDocumentInfo] = React.useState<DocumentAPI | null>(
null
Expand All @@ -24,7 +24,7 @@ const DocumentChooser: FunctionComponent<DocumentChooserProps> = ({

if (documentId) {
fetch(`${adminBaseUrl}api/main/documents/${documentId}/`)
.then(response => response.json())
.then((response) => response.json())
.then(setDocumentInfo);
}
}, [documentId]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const HeaderButtonAction: FunctionComponent<HeaderButtonActionProps> = ({
onClick,
title,
classes,
icon
icon,
}) => {
let classNames = ['button'];

Expand Down Expand Up @@ -66,7 +66,7 @@ export const HeaderLinkAction: FunctionComponent<HeaderLinkActionProps> = ({
href,
title,
classes,
icon
icon,
}) => {
let classNames = ['button'];

Expand Down Expand Up @@ -96,7 +96,7 @@ interface HeaderMetaProps {
export const HeaderMeta: FunctionComponent<HeaderMetaProps> = ({
name,
value,
icon
icon,
}) => {
return (
<li className={`header-meta--${name}`}>
Expand Down Expand Up @@ -125,7 +125,7 @@ export const HeaderMetaDropdown: FunctionComponent<HeaderMetaDropdownProps> = ({
options,
icon,
title,
classes
classes,
}) => {
let classNames = ['c-dropdown', 't-inverted'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface ImageChooserProps {

const ImageChooser: FunctionComponent<ImageChooserProps> = ({
adminBaseUrl,
imageId
imageId,
}) => {
const [imageInfo, setImageInfo] = React.useState<ImageAPI | null>(null);

Expand All @@ -27,7 +27,7 @@ const ImageChooser: FunctionComponent<ImageChooserProps> = ({

if (imageId) {
fetch(`${adminBaseUrl}api/main/images/${imageId}/`)
.then(response => response.json())
.then((response) => response.json())
.then(setImageInfo);
}
}, [imageId]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface PageChooserProps {

const PageChooser: FunctionComponent<PageChooserProps> = ({
adminBaseUrl,
pageId
pageId,
}) => {
const [pageInfo, setPageInfo] = React.useState<PageAPI | null>(null);

Expand All @@ -22,7 +22,7 @@ const PageChooser: FunctionComponent<PageChooserProps> = ({

if (pageId) {
fetch(`${adminBaseUrl}api/main/pages/${pageId}/`)
.then(response => response.json())
.then((response) => response.json())
.then(setPageInfo);
}
}, [pageId]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface SnippetChooserProps {
const SnippetChooser: FunctionComponent<SnippetChooserProps> = ({
adminBaseUrl,
snippetModel,
snippetId
snippetId,
}) => {
const [snippetInfo, setSnippetInfo] = React.useState<SnippetAPI | null>(
null
Expand All @@ -34,7 +34,7 @@ const SnippetChooser: FunctionComponent<SnippetChooserProps> = ({
fetch(
`${adminBaseUrl}localize/api/snippets/${snippetModel.app_label}/${snippetModel.model_name}/${snippetId}/`
)
.then(response => response.json())
.then((response) => response.json())
.then(setSnippetInfo);
}
}, [snippetId]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const Tabs: FunctionComponent<TabsProps> = ({ tabs, children }) => {
<div className="w-tabs">
<div className="w-tabs__wrapper">
<div className="w-tabs__list" role="tablist">
{tabs.map(tab => {
{tabs.map((tab) => {
const onClick = (
e: React.MouseEvent<HTMLAnchorElement>
) => {
Expand Down
4 changes: 2 additions & 2 deletions wagtail_localize/static_src/component_form/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ document.addEventListener('DOMContentLoaded', () => {
// Component enable buttons
document
.querySelectorAll('.component-form__enable-button')
.forEach(enableButton => {
.forEach((enableButton) => {
enableButton.addEventListener('click', () => {
toggleInput(enableButton, true);
});
Expand All @@ -29,7 +29,7 @@ document.addEventListener('DOMContentLoaded', () => {
// Component disable buttons
document
.querySelectorAll('.component-form__disable-button')
.forEach(disableButton => {
.forEach((disableButton) => {
disableButton.addEventListener('click', () => {
toggleInput(disableButton, false);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const EditorFooter: FunctionComponent<EditorProps> = ({
perms,
links,
previewModes,
locale
locale,
}) => {
let actions = [
<form method="POST" action={links.stopTranslationUrl}>
Expand All @@ -27,7 +27,7 @@ const EditorFooter: FunctionComponent<EditorProps> = ({
<Icon name="cross" />
{gettext('Stop Synced translation')}
</button>
</form>
</form>,
];

if (links.convertToAliasUrl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const LocaleMeta: FunctionComponent<LocaleMetaProps> = ({
name,
translations,
sourceLocale,
targetLocale
targetLocale,
}) => {
// Render source
const sourceTranslation = translations
Expand All @@ -41,7 +41,7 @@ const LocaleMeta: FunctionComponent<LocaleMetaProps> = ({
.map(({ locale, editUrl }) => {
return {
label: locale.displayName,
href: editUrl
href: editUrl,
};
});

Expand Down Expand Up @@ -108,7 +108,7 @@ interface EditorHeaderProps extends EditorProps, EditorState {}
const EditorHeader: FunctionComponent<EditorHeaderProps> = ({
sourceLocale,
locale,
translations
translations,
}) => {
return (
<header className="w-flex w-flex-col sm:w-flex-row w-items-center w-justify-between w-bg-grey-50 w-border-b w-border-grey-100 w-px-0 w-py-0 w-mb-0 w-relative w-top-0 sm:w-sticky w-min-h-slim-header">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,37 +190,37 @@ export interface EditorProps {
initialOverrides: SegmentOverrideAPI[];
}

const TranslationEditor: FunctionComponent<EditorProps> = props => {
const TranslationEditor: FunctionComponent<EditorProps> = (props) => {
// Convert initialStringTranslations into a Map that maps segment ID to translation info
const stringTranslations: Map<number, StringTranslation> = new Map();
props.initialStringTranslations.forEach(translation => {
props.initialStringTranslations.forEach((translation) => {
stringTranslations.set(translation.segment_id, {
value: translation.data,
isSaving: false,
isErrored: !!translation.error,
comment: translation.error
? translation.error
: translation.comment,
translatedBy: translation.last_translated_by
translatedBy: translation.last_translated_by,
});
});

// Same with initialSegmentOverrides
const segmentOverrides: Map<number, SegmentOverride> = new Map();
props.initialOverrides.forEach(override => {
props.initialOverrides.forEach((override) => {
segmentOverrides.set(override.segment_id, {
value: override.data,
isSaving: false,
isErrored: !!override.error,
comment: override.error || gettext('Changed')
comment: override.error || gettext('Changed'),
});
});

// Set up initial state
const initialState: EditorState = {
stringTranslations,
segmentOverrides,
editingSegments: new Set()
editingSegments: new Set(),
};

const [state, dispatch] = React.useReducer(reducer, initialState);
Expand All @@ -246,31 +246,31 @@ const TranslationEditor: FunctionComponent<EditorProps> = props => {
}, [state.editingSegments]);

const tabData = props.tabs
.map(tab => {
.map((tab) => {
const segments = props.segments.filter(
segment => segment.location.tab == tab.slug
(segment) => segment.location.tab == tab.slug
);
const translations = segments.map(
segment =>
(segment) =>
segment.type == 'string' &&
state.stringTranslations.get(segment.id)
);

return {
numErrors: translations.filter(
translation => translation && translation.isErrored
(translation) => translation && translation.isErrored
).length,
segments,
...tab
...tab,
};
})
.filter(tab => tab.segments.length > 0);
.filter((tab) => tab.segments.length > 0);

let tabs = <></>;
if (tabData.length > 1) {
tabs = (
<Tabs tabs={tabData}>
{tabData.map(tab => {
{tabData.map((tab) => {
return (
<TabContent key={tab.slug} {...tab}>
<EditorToolbox
Expand Down
Loading

0 comments on commit 53d9d8e

Please sign in to comment.