Skip to content

Commit e7437af

Browse files
kwhubergithub-actions[bot]
authored andcommitted
Lint code with ESLint and Prettier
Triggered by 756f77c on branch refs/heads/issue-5168
1 parent 756f77c commit e7437af

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

specifyweb/frontend/js_src/lib/components/AppResources/Editor.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,21 @@ export function AppResourceEditor({
101101
useErrorContext('resourceData', resourceData);
102102

103103
React.useEffect(() => {
104-
// If the stored data hasn't been edited by the user, keep the
105-
// top-level <viewset name="..."> in sync with the resource name.
104+
/*
105+
* If the stored data hasn't been edited by the user, keep the
106+
* top-level <viewset name="..."> in sync with the resource name.
107+
*/
106108
if (resourceData === undefined) return;
107109
if (isChanged) return;
108110
const resourceName = (resource as any)?.name ?? '';
109111
if (typeof resourceName !== 'string' || resourceName.length === 0) return;
110112
const escapeXml = (s: string): string =>
111113
s
112-
.replace(/&/g, '&amp;')
113-
.replace(/</g, '&lt;')
114-
.replace(/>/g, '&gt;')
115-
.replace(/"/g, '&quot;')
116-
.replace(/'/g, '&apos;');
114+
.replaceAll('&', '&amp;')
115+
.replaceAll('<', '&lt;')
116+
.replaceAll('>', '&gt;')
117+
.replaceAll('"', '&quot;')
118+
.replaceAll('\'', '&apos;');
117119

118120
const newData = (resourceData.data ?? '').replace(
119121
/(<viewset\b[^>]*\bname=)(["'])(.*?)\2/,

specifyweb/frontend/js_src/lib/components/AppResources/EditorWrapper.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,25 +206,26 @@ function useInitialData(
206206
React.useCallback(async () => {
207207
const escapeXml = (s: string): string =>
208208
s
209-
.replace(/&/g, '&amp;')
210-
.replace(/</g, '&lt;')
211-
.replace(/>/g, '&gt;')
212-
.replace(/"/g, '&quot;');
209+
.replaceAll('&', '&amp;')
210+
.replaceAll('<', '&lt;')
211+
.replaceAll('>', '&gt;')
212+
.replaceAll('"', '&quot;');
213213

214214
const replaceViewsetName = (data: string | null | undefined): string => {
215215
const xml = data ?? '';
216216
const resourceName = (resource as any)?.name ?? '';
217217
if (typeof resourceName !== 'string' || resourceName.length === 0)
218218
return xml;
219219
return xml.replace(
220-
/(<viewset\b[^>]*\bname=)(["])(.*?)\2/,
220+
/(<viewset\b[^>]*\bname=)(")(.*?)\2/,
221221
(_match, p1, p2) => `${p1}${p2}${escapeXml(resourceName)}${p2}`
222222
);
223223
};
224224

225225
if (typeof initialDataFrom === 'number')
226226
return fetchResource('SpAppResourceData', initialDataFrom).then(
227-
({ data }) => replaceViewsetName(data ?? ''));
227+
({ data }) => replaceViewsetName(data ?? '')
228+
);
228229
else if (typeof templateFile === 'string') {
229230
if (templateFile.includes('..'))
230231
console.error(

0 commit comments

Comments
 (0)