Skip to content

Commit 3fc2147

Browse files
author
Saket Hatwar
committed
lint
1 parent 4013d76 commit 3fc2147

File tree

7 files changed

+80
-36
lines changed

7 files changed

+80
-36
lines changed

jsx/I18nSetup.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
declare module "I18nSetup" {
2-
import i18n from "i18next";
1+
declare module 'I18nSetup' {
2+
import i18n from 'i18next';
33
export default i18n;
44
}

modules/dataquery/jsx/definefilters.addfiltermodal.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function AddFilterModal(props: {
132132
if (fieldDictionary) {
133133
let valueSelect;
134134
if (op) {
135-
valueSelect = valueInput(fieldDictionary, op, value, setValue,t);
135+
valueSelect = valueInput(fieldDictionary, op, value, setValue, t);
136136
}
137137

138138
criteriaSelect = <div>
@@ -154,7 +154,8 @@ function AddFilterModal(props: {
154154

155155
if (fieldDictionary.scope == 'session' && fieldDictionary.visits) {
156156
visitSelect = <div onClick={(e) => e.stopPropagation()}>
157-
<h3>{t('for at least one of the following visits', {ns: 'dataquery'})}</h3>
157+
<h3>{t('for at least one of the following visits',
158+
{ns: 'dataquery'})}</h3>
158159
<VisitList options={fieldDictionary.visits}
159160
selected={selectedVisits || []}
160161
onChange={setSelectedVisits}
@@ -176,7 +177,10 @@ function AddFilterModal(props: {
176177
<div style={{
177178
color: 'white',
178179
padding: '1em',
179-
}}>{t('This field may exist multiple times for a single {{scope}}. Adding a criteria based on it means that it must match for <i>at least one</i> of the data points.', {ns: 'dataquery', scope: fieldDictionary.scope})}</div>
180+
}}>{t('This field may exist multiple times for a single {{scope}}.'
181+
+' Adding a criteria based on it means that it must match for '
182+
+'<i>at least one</i> of the data points.', {ns: 'dataquery',
183+
scope: fieldDictionary.scope})}</div>
180184
</div>;
181185
}
182186
}
@@ -194,7 +198,8 @@ function AddFilterModal(props: {
194198
swal.fire({
195199
type: 'error',
196200
title: t('Invalid field', {ns: 'dataquery'}),
197-
text: t('You must select a field for the criteria.', {ns: 'dataquery'}),
201+
text: t('You must select a field for the criteria.',
202+
{ns: 'dataquery'}),
198203
});
199204
reject();
200205
return;
@@ -203,7 +208,8 @@ function AddFilterModal(props: {
203208
swal.fire({
204209
type: 'error',
205210
title: t('Invalid operator', {ns: 'dataquery'}),
206-
text: t('You must select an operator for the criteria.', {ns: 'dataquery'}),
211+
text: t('You must select an operator for the criteria.',
212+
{ns: 'dataquery'}),
207213
});
208214
reject();
209215
return;
@@ -215,7 +221,8 @@ function AddFilterModal(props: {
215221
swal.fire({
216222
type: 'error',
217223
title: t('Invalid value', {ns: 'dataquery'}),
218-
text: t('You must enter a value to compare the field against.', {ns: 'dataquery'}),
224+
text: t('You must enter a value to compare the field against.',
225+
{ns: 'dataquery'}),
219226
});
220227
reject();
221228
return;
@@ -362,6 +369,7 @@ function getOperatorOptions(dict: FieldDictionary) {
362369
* @param {string} op - The operator selected
363370
* @param {string|string[]} value - The current value
364371
* @param {string} setValue - a callback when a new value is selected
372+
* @param {function} t - Translation function from i18next
365373
* @returns {React.ReactElement} - the react element
366374
*/
367375
function valueInput(fielddict: FieldDictionary,

modules/dataquery/jsx/definefilters.importcsvmodal.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ function ImportCSVModal(props: {
6161
swal.fire({
6262
type: 'error',
6363
title: t('Invalid CSV', {ns: 'dataquery'}),
64-
text: t('Expected {{expectedLength}} columns in CSV. Got {{gotLength}} on line {{line}}.', {ns: 'dataquery', expectedLength, gotLength: value.data[i].length, line: i+1}),
64+
text: t('Expected {{expectedLength}} columns in CSV. '
65+
+'Got {{gotLength}} on line {{line}}.', {ns: 'dataquery',
66+
expectedLength, gotLength: value.data[i].length, line: i+1}),
6567
});
6668
return;
6769
}
@@ -70,7 +72,8 @@ function ImportCSVModal(props: {
7072
swal.fire({
7173
type: 'error',
7274
title: t('Invalid DCC ID', {ns: 'dataquery'}),
73-
text: t('Invalid DCC ID ({{id}}) on line {{line}}.', {ns: 'dataquery', id: value.data[i][0], line: i+1}),
75+
text: t('Invalid DCC ID ({{id}}) on line {{line}}.',
76+
{ns: 'dataquery', id: value.data[i][0], line: i+1}),
7477
});
7578
return;
7679
}
@@ -131,7 +134,8 @@ function ImportCSVModal(props: {
131134
<fieldset>
132135
<div>
133136
<dl>
134-
<dt style={dtstyle}>{t('CSV containing list of', {ns: 'dataquery'})}</dt>
137+
<dt style={dtstyle}>{t('CSV containing list of',
138+
{ns: 'dataquery'})}</dt>
135139
<dd>
136140
<input type="radio" name="csvtype"
137141
checked={csvType == 'candidate'}
@@ -143,7 +147,8 @@ function ImportCSVModal(props: {
143147
onChange={() => setCSVType('session')}
144148
/> {t('Sessions', {ns: 'dataquery'})}
145149
</dd>
146-
<dt style={dtstyle}>{t('Candidate identifier type', {ns: 'dataquery'})}</dt>
150+
<dt style={dtstyle}>{t('Candidate identifier type',
151+
{ns: 'dataquery'})}</dt>
147152
<dd><input type="radio" name="candidtype"
148153
checked={idType == 'CandID'}
149154
onChange={() => setIdType('CandID')}

modules/dataquery/jsx/definefilters.tsx

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ function DefineFilters(props: {
120120
const mapModuleName = props.mapModuleName;
121121
const mapCategoryName = props.mapCategoryName;
122122

123-
const advancedLabel = showAdvanced ? t('Hide Advanced', {ns: 'dataquery'}) : t('Show Advanced', {ns: 'dataquery'});
123+
const advancedLabel = showAdvanced ? t('Hide Advanced',
124+
{ns: 'dataquery'}) : t('Show Advanced', {ns: 'dataquery'});
124125
let advancedButtons;
125126
const toggleAdvancedButton = (
126127
<div>
@@ -140,7 +141,11 @@ function DefineFilters(props: {
140141
if (showAdvanced) {
141142
advancedButtons = (
142143
<div>
143-
<p>{t('The "nested groups" options are advanced options for queries that do not have any specific condition at the base of the query. Use Add nested "or" condition groups if you need to build a query of the form. (a or b) and (c or d) [or (e and f)..]', {ns: 'dataquery'})}</p>
144+
<p>{t('The "nested groups" options are advanced options for '
145+
+'queries that do not have any specific condition at the base'
146+
+' of the query. Use Add nested "or" condition groups if you'
147+
+' need to build a query of the form. (a or b) and (c or d)'
148+
+' [or (e and f)..]', {ns: 'dataquery'})}</p>
144149
<div style={bGroupStyle}>
145150
<ButtonElement
146151
label={t('Add nested "or" condition groups', {ns: 'dataquery'})}
@@ -151,7 +156,9 @@ function DefineFilters(props: {
151156
}}
152157
/>
153158
</div>
154-
<p>{t('Use Add nested "and" condition groups if you need to build a query of the form (a and b) or (c and d) [or (e and f)..]', {ns: 'dataquery'})}</p>
159+
<p>{t('Use Add nested "and" condition groups if you need to '
160+
+'build a query of the form (a and b) or (c and d) '
161+
+'[or (e and f)..]', {ns: 'dataquery'})}</p>
155162
<div style={bGroupStyle}>
156163
<ButtonElement
157164
label={t('Add nested "and" condition groups', {ns: 'dataquery'})}
@@ -171,10 +178,15 @@ function DefineFilters(props: {
171178
<div style={{paddingLeft: '2em',
172179
paddingRight: '2em'}}>
173180
<p>{t('Currently querying for ALL candidates.', {ns: 'dataquery'})}</p>
174-
<p>{t('You can add conditions by clicking one of the buttons below.', {ns: 'dataquery'})}</p>
175-
<p>{t('Click Add Condition to add one or more conditions to your filters (ie. "Date Of Birth < 2015-02-15"). This is most likely where you want to start your filters.', {ns: 'dataquery'})}</p>
176-
<p>{t('You can also import a population from a CSV by clicking the Import from CSV button.', {ns: 'dataquery'})}</p>
177-
<p>{t('The advanced options are for queries that do not have a condition to add at the base of the query.', {ns: 'dataquery'})}</p>
181+
<p>{t('You can add conditions by clicking one of the buttons below.',
182+
{ns: 'dataquery'})}</p>
183+
<p>{t('Click Add Condition to add one or more conditions to your'
184+
+' filters (ie. "Date Of Birth < 2015-02-15"). This is most likely'
185+
+' where you want to start your filters.', {ns: 'dataquery'})}</p>
186+
<p>{t('You can also import a population from a CSV by clicking the'
187+
+' Import from CSV button.', {ns: 'dataquery'})}</p>
188+
<p>{t('The advanced options are for queries that do not have a '
189+
+'condition to add at the base of the query.', {ns: 'dataquery'})}</p>
178190
</div>
179191
<form>
180192
<fieldset>
@@ -218,15 +230,23 @@ function DefineFilters(props: {
218230
advancedButtons = (
219231
<div>
220232
<div style={bGroupStyle}>
221-
<p>{t('Use New "and" subgroup if the rest of the query you need to write is a subgroup consisting of "and" conditions. ie your query is of the form: (your condition above) or (c and d [and e and f..])', {ns: 'dataquery'})}</p>
233+
<p>{t('Use New "and" subgroup if the rest of the query you'
234+
+' need to write is a subgroup consisting of "and" '
235+
+'conditions. ie your query is of the form: (your condition'
236+
+' above) or (c and d [and e and f..])',
237+
{ns: 'dataquery'})}</p>
222238
<ButtonElement
223239
label={t('New "and" subgroup', {ns: 'dataquery'})}
224240
onUserInput={(e: React.MouseEvent) => {
225241
e.preventDefault();
226242
props.query.operator = 'or';
227243
props.addNewQueryGroup(props.query);
228244
}} />
229-
<p>{t('Use New "or" subgroup if the rest of the query you need to write is a subgroup consisting of "or" conditions. ie your query is of the form: (your condition above) and (c or d [or e or f..])', {ns: 'dataquery'})}</p>
245+
<p>{t('Use New "or" subgroup if the rest of the query you '
246+
+'need to write is a subgroup consisting of "or" '
247+
+'conditions. ie your query is of the form: (your '
248+
+'condition above) and (c or d [or e or f..])',
249+
{ns: 'dataquery'})}</p>
230250
<ButtonElement
231251
label={t('New "or" subgroup', {ns: 'dataquery'})}
232252
onUserInput={(e: React.MouseEvent) => {
@@ -240,7 +260,8 @@ function DefineFilters(props: {
240260
}
241261
// buttons for 1. Add "and" condition 2. Add "or" condition
242262
displayquery = (<div>
243-
<p>{t('Currently querying for any candidates with:', {ns: 'dataquery'})}</p>
263+
<p>{t('Currently querying for any candidates with:',
264+
{ns: 'dataquery'})}</p>
244265

245266
<form>
246267
<fieldset>
@@ -300,7 +321,8 @@ function DefineFilters(props: {
300321
// Add buttons are delegated to the QueryTree rendering so they
301322
// can be placed at the right level
302323
displayquery = <div>
303-
<p>{t('Currently querying for any candidates with:', {ns: 'dataquery'})}</p>
324+
<p>{t('Currently querying for any candidates with:',
325+
{ns: 'dataquery'})}</p>
304326
<form>
305327
<fieldset>
306328
<QueryTree
@@ -352,7 +374,8 @@ function DefineFilters(props: {
352374

353375
const matchCount = queryMatches === null
354376
? <div>&nbsp;</div> // So the header doesn't jump around
355-
: <div>{t('Query matches <b>{{count}}</b> candidates', {ns: 'dataquery', count: queryMatches})}</div>;
377+
: <div>{t('Query matches <b>{{count}}</b> candidates',
378+
{ns: 'dataquery', count: queryMatches})}</div>;
356379
return (<div>
357380
{modal}
358381
{csvModalHTML}
@@ -365,7 +388,10 @@ function DefineFilters(props: {
365388
{matchCount}
366389
</div>
367390
<InfoPanel>
368-
{t('Note that only candidates which you have permission to access in LORIS are included in results. Number of results may vary from other users running the same query.', {ns: 'dataquery'})}
391+
{t('Note that only candidates which you have permission to '
392+
+'access in LORIS are included in results. Number of results'
393+
+' may vary from other users running the same query.',
394+
{ns: 'dataquery'})}
369395
</InfoPanel>
370396
{displayquery}
371397
</div>

modules/dataquery/jsx/fielddisplay.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ function FieldDisplay(props: {
3535
{description}
3636
</div>
3737
<div style={{fontSize: '0.8em', color: '#aaa'}}>
38-
{t('Category', {ns: 'dataquery'})}: {props.mapCategoryName(props.module, props.category)}
39-
&nbsp;({t('Module', {ns: 'dataquery'})}: {props.mapModuleName(props.module)})
38+
{t('Category', {ns: 'dataquery'})}:
39+
{props.mapCategoryName(props.module, props.category)}
40+
&nbsp;({t('Module', {ns: 'dataquery'})}:
41+
{props.mapModuleName(props.module)})
4042
</div>
4143
</div>
4244
);

modules/dataquery/jsx/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ import {useDataDictionary, useCategories} from './hooks/usedatadictionary';
1818
import {ModuleDictionary, DictionaryCategory} from './types';
1919
// @ts-ignore
2020
import i18n from 'I18nSetup';
21-
import {useTranslation, withTranslation} from 'react-i18next';
22-
const hiStrings = require('../locale/hi/LC_MESSAGES/dataquery.json');
21+
import {withTranslation} from 'react-i18next';
22+
23+
import hiStrings from '../locale/hi/LC_MESSAGES/dataquery.json';
2324

2425
type ActiveCategoryType = {
2526
module: string,
@@ -249,7 +250,8 @@ function DataQueryApp(props: {
249250
declare const loris: any;
250251
window.addEventListener('load', () => {
251252
i18n.addResourceBundle('hi', 'dataquery', hiStrings);
252-
const TranslatedDataQueryApp = withTranslation(['dataquery','loris'])(DataQueryApp);
253+
const TranslatedDataQueryApp = withTranslation(
254+
['dataquery', 'loris'])(DataQueryApp);
253255

254256
const element = document.getElementById('lorisworkspace');
255257
if (!element) {

modules/dataquery/jsx/querytree.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import {QueryGroup, QueryTerm} from './querydef';
33
import {CriteriaTerm} from './criteriaterm';
44
import {ButtonElement} from 'jsx/Form';
55
import {FullDictionary} from './types';
6-
import {useEffect} from 'react'; // already present
7-
import {useTranslation} from 'react-i18next'; // <-- ADD THIS
6+
import {useEffect} from 'react';
7+
import {useTranslation} from 'react-i18next';
88

99
/**
1010
* Alternate background colour for a QueryTree
@@ -40,7 +40,7 @@ function alternateColour(c: string): string {
4040
* @param {object} props.mapModuleName - Function to map the backend module name to a user friendly name
4141
* @param {object} props.mapCategoryName - Function to map the backend category name to a user friendly name
4242
* @param {object} props.fulldictionary - The dictionary of all modules that have been loaded
43-
* @param props.setDeleteItemIndex
43+
* @param {function} props.setDeleteItemIndex - Callback to set or clear the index of the item marked for deletion
4444
* @returns {React.ReactElement} - the react element
4545
*/
4646
function QueryTree(props: {
@@ -63,7 +63,7 @@ function QueryTree(props: {
6363
mapCategoryName: (module: string, category: string) => string,
6464
}) {
6565
const [deleteItemIndex, setDeleteItemIndex] = useState<number|null>(null);
66-
const {t} = useTranslation('dataquery'); // <-- ADD THIS
66+
const {t} = useTranslation('dataquery');
6767

6868
useEffect(() => {
6969
// Reset strikethrough when group is empty or changed
@@ -271,8 +271,9 @@ function QueryTree(props: {
271271
<div style={{...props.buttonGroupStyle, width: '100%'}}>
272272
<div style={{margin: 5}}>
273273
<ButtonElement
274-
label={t('Add "{{operator}}" condition to group', {ns: 'dataquery',
275-
operator: props.items.operator})}
274+
label={t('Add "{{operator}}" condition to group',
275+
{ns: 'dataquery',
276+
operator: props.items.operator})}
276277
onUserInput={newItemClick}
277278
style={props.buttonStyle}
278279
columnSize='col-sm-12'

0 commit comments

Comments
 (0)