Skip to content

Commit

Permalink
[eslint] Modules - fix max-len (aces#6761)
Browse files Browse the repository at this point in the history
- resolves all eslint max-len warnings
- raises max-len severity to error

Resolves (partially) aces#6750
  • Loading branch information
laemtl authored Jul 9, 2020
1 parent 3fed1e7 commit 200d3d9
Show file tree
Hide file tree
Showing 60 changed files with 1,314 additions and 419 deletions.
11 changes: 1 addition & 10 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"rules": {
"extends": ["eslint:recommended", "plugin:react/recommended", "google"],
"max-len": [2, 80, 2, {
"ignoreComments": true,
"ignoreStrings": true
"ignoreComments": true
}],
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error",
Expand All @@ -36,14 +35,6 @@
"allow": ["info", "warn", "error"]
}]
},
"overrides": [
{
"files": ["modules/**", "htdocs/**"],
"rules": {
"max-len": [1, 80, 2, {"ignoreComments": true}]
}
}
],
"globals": {
"React": true,
"ReactDOM": true,
Expand Down
110 changes: 61 additions & 49 deletions htdocs/js/helpHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,61 +23,73 @@ $(document).ready(function() {
if (loris.Subtest !== '') {
getParams.subtest = loris.Subtest;
}
$.get(loris.BaseURL + '/help_editor/ajax/help.php', getParams, function(content) {
let div = document.createElement('div');
let btn = document.createElement('BUTTON');
let edit = document.createElement('BUTTON');
let text = document.createTextNode('Edit');
let button = document.createTextNode('Close');
let wrap = document.createElement('div');
let markdownContent = document.createElement('div');
$.get(
loris.BaseURL + '/help_editor/ajax/help.php',
getParams,
function(content) {
let div = document.createElement('div');
let btn = document.createElement('BUTTON');
let edit = document.createElement('BUTTON');
let text = document.createTextNode('Edit');
let button = document.createTextNode('Close');
let wrap = document.createElement('div');
let markdownContent = document.createElement('div');

// Render Markdown in wrap div.
// If help content is from Markdown helpfile.
if (content.format === 'markdown') {
ReactDOM.render(RMarkdown({content: content.content}), wrap);
} else {
// If help content is from DB.
wrap.innerHTML = '<hr id=\'help-separator\'>';
if (content.topic) {
wrap.innerHTML = '<h3>' + content.topic + '</h3>';
// Render Markdown in wrap div.
// If help content is from Markdown helpfile.
if (content.format === 'markdown') {
ReactDOM.render(RMarkdown({content: content.content}), wrap);
} else {
// If help content is from DB.
wrap.innerHTML = '<hr id=\'help-separator\'>';
if (content.topic) {
wrap.innerHTML = '<h3>' + content.topic + '</h3>';
}
ReactDOM.render(
RMarkdown({content: content.content}),
markdownContent
);
wrap.appendChild(markdownContent);
if (content.updated) {
wrap.innerHTML = wrap.innerHTML
+ '<hr>Last updated: '
+ content.updated;
}
}
ReactDOM.render(RMarkdown({content: content.content}), markdownContent);
wrap.appendChild(markdownContent);
if (content.updated) {
wrap.innerHTML = wrap.innerHTML + '<hr>Last updated: ' + content.updated;
}
}
wrap.setAttribute('id', 'help-wrapper');
btn.appendChild(button);
btn.className = 'btn btn-default';
btn.setAttribute('id', 'helpclose');
edit.appendChild(text);
edit.className = 'btn btn-default';
edit.setAttribute('id', 'helpedit');
div.appendChild(btn);
wrap.setAttribute('id', 'help-wrapper');
btn.appendChild(button);
btn.className = 'btn btn-default';
btn.setAttribute('id', 'helpclose');
edit.appendChild(text);
edit.className = 'btn btn-default';
edit.setAttribute('id', 'helpedit');
div.appendChild(btn);

// If help content comes from DB `help` table and can
// be edited online.
if (loris.userHasPermission('context_help') && content.format !== 'markdown') {
div.appendChild(edit);
edit.addEventListener('click', function(e) {
// If help content comes from DB `help` table and can
// be edited online.
if (loris.userHasPermission('context_help')
&& content.format !== 'markdown'
) {
div.appendChild(edit);
edit.addEventListener('click', function(e) {
e.preventDefault();
window.open(loris.BaseURL
+ '/help_editor/edit_help_content/?section=' +
getParams.testName + '&subsection=' + getParams.subtest, '_self');
});
}
div.appendChild(wrap);
document.getElementById('wrap').appendChild(div);
div.setAttribute('class', 'help-content');
$(div).addClass('visible');
btn.addEventListener('click', function(e) {
$(div).hide();
$('.help-button').removeClass('help-open');
e.preventDefault();
window.open(loris.BaseURL + '/help_editor/edit_help_content/?section=' +
getParams.testName + '&subsection=' + getParams.subtest, '_self');
});
}
div.appendChild(wrap);
document.getElementById('wrap').appendChild(div);
div.setAttribute('class', 'help-content');
$(div).addClass('visible');
btn.addEventListener('click', function(e) {
$(div).hide();
$('.help-button').removeClass('help-open');
e.preventDefault();
});
e.preventDefault();
}, 'json');
},
'json');
});

$('.dynamictable').DynamicTable();
Expand Down
8 changes: 6 additions & 2 deletions htdocs/js/instrument_form_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ function notAnswered() {
} else {
$('.' + name).prop('disabled', true);
$(this).parent().addClass('has-warning');
$(this).after('<div class="col-xs-12 warning" id="' + name + '">Any entered data will not be saved</div>');
$(this).after('<div class="col-xs-12 warning" id="'
+ name
+ '">Any entered data will not be saved</div>');
}
} else if (index === 0) {
$('[name=' + name + ']').prop('disabled', false);
Expand All @@ -20,7 +22,9 @@ function notAnswered() {
} else {
$('[name=' + name + ']').prop('disabled', true);
$(this).parent().addClass('has-warning');
$(this).after('<div class="col-xs-12 warning" id="' + name + '">Any entered data will not be saved</div>');
$(this).after('<div class="col-xs-12 warning" id="'
+ name
+ '">Any entered data will not be saved</div>');
}
}

Expand Down
9 changes: 6 additions & 3 deletions htdocs/js/invalid_form_scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
$(document).ready(function bindInvalidFormListeners() {
// This will make sure that the flag indicating whether we scrolled
// to an invalid element when the form is submitted is reset
document.getElementsByName('fire_away')[0].addEventListener('click', function() {
bindInvalidFormListeners.scrollingDone = false;
});
document.getElementsByName('fire_away')[0].addEventListener(
'click',
function() {
bindInvalidFormListeners.scrollingDone = false;
}
);

// Override default event handler for invalid input elements
// This will make sure that the invalid element appears at the top
Expand Down
12 changes: 9 additions & 3 deletions htdocs/js/jquery.csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@

jQuery.extend({
csv: function(delim, quote, lined) {
delim = typeof delim === 'string' ? new RegExp('[' + (delim || ',') + ']') : typeof delim === 'undefined' ? ',' : delim;
quote = typeof quote === 'string' ? new RegExp('^[' + (quote || '"') + ']') : typeof quote === 'undefined' ? '"' : quote;
lined = typeof lined === 'string' ? new RegExp('[' + (lined || '\r\n') + ']+') : typeof lined === 'undefined' ? '\r\n' : lined;
delim = typeof delim === 'string' ?
new RegExp('[' + (delim || ',') + ']') :
typeof delim === 'undefined' ? ',' : delim;
quote = typeof quote === 'string' ?
new RegExp('^[' + (quote || '"') + ']') :
typeof quote === 'undefined' ? '"' : quote;
lined = typeof lined === 'string' ?
new RegExp('[' + (lined || '\r\n') + ']+') :
typeof lined === 'undefined' ? '\r\n' : lined;

function splitline(v) {
// Split the line using the delimitor
Expand Down
15 changes: 12 additions & 3 deletions htdocs/js/jquery.fileupload.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
(function($) {
let inputGroup = '<div class="input-group file-upload"></div>';
let fileNameDisplay = '<div tabindex="-1" class="form-control file-caption kv-fileinput-caption" title=""><span class="glyphicon glyphicon-file kv-caption-icon" style="display: none;"></span><div class="file-caption-name"></div></div>';
let fileNameDisplay = '<div tabindex="-1" ' +
'class="form-control file-caption kv-fileinput-caption" ' +
'title="">' +
'<span class="glyphicon glyphicon-file kv-caption-icon" ' +
'style="display: none;"></span>' +
'<div class="file-caption-name"></div>' +
'</div>';
let inputButtonGroup = '<div class="input-group-btn"></div>';
let inputButton = '<div class="btn btn-primary btn-file"></div>';
let buttonText = '<i class="glyphicon glyphicon-folder-open"></i>&nbsp;Browse …';
let buttonText = '<i class="glyphicon glyphicon-folder-open"></i>'
+ '&nbsp;Browse …';
let wrapper = function(element) {
$(element).wrap(inputGroup);
$(element).before(fileNameDisplay);
Expand All @@ -18,7 +25,9 @@
wrapper(element);
$(element).change(function() {
let filename = $(this).val().split('\\').pop();
let placeHolder = $(this).parent().parent().parent().find('.file-caption-name');
let placeHolder = $(this)
.parent().parent().parent()
.find('.file-caption-name');
$(placeHolder).html(filename);
});
});
Expand Down
3 changes: 2 additions & 1 deletion htdocs/js/util/queryString.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ let QueryString = {
let queryStringObj = JSON.parse(JSON.stringify(currentQuery));

// Make sure that key is of string type and value is of string or object type
if (typeof fieldName !== 'string' || (typeof fieldValue !== 'string' && typeof fieldValue !== 'object')) {
if (typeof fieldName !== 'string'
|| (typeof fieldValue !== 'string' && typeof fieldValue !== 'object')) {
console.error(
'Error in QueryString.set(): \n' +
'\tfieldName must be of type string and' +
Expand Down
20 changes: 16 additions & 4 deletions jsx/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,9 @@ class SelectElement extends Component {
}

// Add error message
if (this.props.hasError || (this.props.required && this.props.value === '')) {
if (this.props.hasError
|| (this.props.required && this.props.value === '')
) {
errorMessage = <span>{this.props.errorMessage}</span>;
elementClass = 'row form-group has-error';
}
Expand Down Expand Up @@ -905,7 +907,11 @@ class TextboxElement extends Component {
}

handleChange(e) {
this.props.onUserInput(this.props.name, e.target.value, e.target.id, 'textbox');
this.props.onUserInput(
this.props.name,
e.target.value,
e.target.id, 'textbox',
);
}

handleBlur(e) {
Expand Down Expand Up @@ -1039,7 +1045,12 @@ class DateElement extends Component {
}

handleChange(e) {
this.props.onUserInput(this.props.name, e.target.value, e.target.id, 'date');
this.props.onUserInput(
this.props.name,
e.target.value,
e.target.id,
'date',
);
}

render() {
Expand Down Expand Up @@ -1168,7 +1179,8 @@ class TimeElement extends Component {
required={required}
disabled={disabled}
pattern="([0-1][0-9]|2[0-4]|[1-9]):([0-5][0-9])(:([0-5][0-9]))?"
title="Input must be in one of the following formats: HH:MM or HH:MM:SS"
title={'Input must be in one of the following formats: '
+ 'HH:MM or HH:MM:SS'}
/>
</div>
</div>
Expand Down
15 changes: 11 additions & 4 deletions modules/acknowledgements/jsx/acknowledgementsIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ class AcknowledgementsIndex extends Component {
dataEntry: 'Data Entry',
databaseProgramming: 'Database Programming',
imagingProcessingAndEvaluation: 'Imaging Processing and Evaluation',
geneticAnalysisAndBiochemicalAssays: 'Genetic Analysis and Biochemical Assays',
randomizationAndPharmacyAllocation: 'Randomization and Pharmacy Allocation',
geneticAnalysisAndBiochemicalAssays: 'Genetic Analysis '
+ 'and Biochemical Assays',
randomizationAndPharmacyAllocation: 'Randomization '
+ 'and Pharmacy Allocation',
consultants: 'Consultants',
lpCsfCollection: 'LP/CSF Collection',
},
Expand Down Expand Up @@ -140,7 +142,11 @@ class AcknowledgementsIndex extends Component {
})
.then((resp) => {
if (resp.ok && resp.status === 200) {
swal.fire('Success!', 'Acknowledgement added.', 'success').then((result) => {
swal.fire(
'Success!',
'Acknowledgement added.',
'success'
).then((result) => {
if (result.value) {
this.closeModalForm();
this.fetchData();
Expand Down Expand Up @@ -312,7 +318,8 @@ class AcknowledgementsIndex extends Component {
label='End date'
value={this.state.formData.addEndDate}
maxYear={this.state.data.maxYear}
minYear={this.state.formData.addStartDate || this.state.data.minYear}
minYear={this.state.formData.addStartDate
|| this.state.data.minYear}
disabled={disableEndDate}
required={requireEndDate}
onUserInput={this.setFormData}
Expand Down
10 changes: 9 additions & 1 deletion modules/behavioural_qc/jsx/behavioural_qc_module.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,15 @@ class BehaviouralQCGraphics extends Component {
<div className='col-sm-12 col-md-5'>
<div className='panel panel-primary'>
<div className='panel-heading'>
At A Glance: {pscidStatus} - {visitStatus} - {instrumentStatus} - {siteStatus} -{projectStatus}
{'At A Glance: ' +
[
pscidStatus,
visitStatus,
instrumentStatus,
siteStatus,
projectStatus,
].join(' - ')
}
</div>
<div className='panel-body'>
<div id='completedChart'/>
Expand Down
8 changes: 5 additions & 3 deletions modules/bvl_feedback/jsx/react.behavioural_feedback_panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -548,9 +548,11 @@ class FeedbackSummaryPanel extends Component {
<tr key={key}>
<td>{row.QC_Class}</td>
<td>
<a href={loris.BaseURL + '/instruments/' + row.Instrument + '/?candID=' +
row.CandID + '&sessionID=' + row.SessionID + '&commentID=' +
row.CommentID}
<a href={loris.BaseURL
+ '/instruments/' + row.Instrument
+ '/?candID=' + row.CandID
+ '&sessionID=' + row.SessionID
+ '&commentID=' + row.CommentID}
>
{row.Instrument}
</a>
Expand Down
4 changes: 3 additions & 1 deletion modules/candidate_list/jsx/candidateListIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ class CandidateListIndex extends Component {
// FIXME: move toggle button in the filter component next to the clear button
const actions = [
{
label: this.state.hideFilter ? 'Show Advanced Filters' : 'Hide Advanced Filters',
label: this.state.hideFilter ?
'Show Advanced Filters' :
'Hide Advanced Filters',
action: this.toggleFilters,
name: 'advanced',
},
Expand Down
4 changes: 3 additions & 1 deletion modules/candidate_list/jsx/openProfileForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ class OpenProfileForm extends Component {
className: 'alert alert-info text-center',
};
if (this.props.betaProfileLink) {
window.location.href = loris.BaseURL + '/candidate_profile/' + state.CandID;
window.location.href = loris.BaseURL
+ '/candidate_profile/'
+ state.CandID;
} else {
window.location.href = loris.BaseURL + '/' + state.CandID;
}
Expand Down
3 changes: 2 additions & 1 deletion modules/candidate_parameters/jsx/CandidateDOB.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ class CandidateDOB extends Component {
/>
<StaticElement
label='Disclaimer:'
text='Any changes to the date of birth requires an administrator to run the fix_candidate_age script.'
text={'Any changes to the date of birth requires an administrator '
+ 'to run the fix_candidate_age script.'}
class='form-control-static text-danger bg-danger col-sm-10'
/>
<DateElement
Expand Down
Loading

0 comments on commit 200d3d9

Please sign in to comment.