Skip to content

Commit

Permalink
TASK: Apply ts linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebobo committed Aug 20, 2019
1 parent 3743765 commit 50862f9
Show file tree
Hide file tree
Showing 17 changed files with 1,427 additions and 228 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.tsx]
indent_size = 4

[*.{yml,yaml,json}]
indent_size = 2

[*.md]
indent_size = 2
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.js
26 changes: 26 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"extends": [
"@neos-project/eslint-config-neos",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"globals": {
"expect": true,
"sinon": false
},
"env": {
"node": true,
"mocha": true
},
"rules": {
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/semi": ["error"],
"@typescript-eslint/explicit-function-return-type": 0,
"comma-dangle": 0,
"semi": 0,
"no-alert": 0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ prototype(Neos.RedirectHandler.Ui:Component.ImportProtocol) < prototype(Neos.Fus
<i class="fas fa-plus-circle" @if.type={entry.type == 'created'}></i>
<i class="fas fa-equals" @if.type={entry.type == 'unchanged'}></i>
</td>
<td class={props.className + '-entry-label'}>
<td class={props.className + '-entry__label'}>
{entry.message}
<span @if.hasRedirect={entry.redirect}>
{entry.redirect.host}/{entry.redirect.sourceUriPath} &rarr; /{entry.redirect.targetUriPath} ({entry.redirect.statusCode})
Expand Down
73 changes: 35 additions & 38 deletions Resources/Private/JavaScript/components/RedirectForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface RedirectFormProps {
actions: {
create: string;
update: string;
}
};
redirect: Redirect;
idPrefix: string;
statusCodes: { [index: string]: string };
Expand Down Expand Up @@ -51,7 +51,6 @@ const initialState: RedirectFormState = {
};

export class RedirectForm extends PureComponent<RedirectFormProps, RedirectFormState> {

constructor(props: RedirectFormProps) {
super(props);
this.state = {
Expand Down Expand Up @@ -96,7 +95,7 @@ export class RedirectForm extends PureComponent<RedirectFormProps, RedirectFormS
}

const data = {
'__csrfToken': csrfToken,
__csrfToken: csrfToken,
moduleArguments: {
originalHost: redirect ? redirect.host : null,
originalSourceUriPath: redirect ? redirect.sourceUriPath : null,
Expand All @@ -109,13 +108,13 @@ export class RedirectForm extends PureComponent<RedirectFormProps, RedirectFormS
this.setState({isSendingData: true});

fetch(redirect ? actions.update : actions.create, {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify(data),
}
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify(data),
}
)
.then(response => response.json())
.then(data => {
Expand Down Expand Up @@ -177,7 +176,7 @@ export class RedirectForm extends PureComponent<RedirectFormProps, RedirectFormS
* @param property
* @param datetime
*/
private handleDatePickerChange(property: string, datetime: Date | string) {
private handleDatePickerChange(property: string, datetime: Date | string): void {
const formattedValue = typeof datetime === 'string' ? datetime : formatReadable(datetime);
this.setState({
[property]: formattedValue,
Expand All @@ -191,7 +190,7 @@ export class RedirectForm extends PureComponent<RedirectFormProps, RedirectFormS
* @param dateTimeString
* @param placeholder
*/
private renderDatePicker = (property: string, dateTimeString: string, placeholder: string) => {
private renderDatePicker = (property: string, dateTimeString: string, placeholder: string): React.ReactElement => {
const {translate} = this.props;
const dateTime = dateTimeString ? new Date(dateTimeString) : null;

Expand All @@ -205,7 +204,7 @@ export class RedirectForm extends PureComponent<RedirectFormProps, RedirectFormS
placeholderText={placeholder}
selected={dateTime}
timeCaption={translate('datepicker.time', 'Time')}
onChange={(value) => this.handleDatePickerChange(property, value)}/>
onChange={value => this.handleDatePickerChange(property, value)}/>
);
};

Expand All @@ -216,14 +215,12 @@ export class RedirectForm extends PureComponent<RedirectFormProps, RedirectFormS
*/
private renderChangedRedirects = (changedRedirects: Array<Redirect>): string => {
const {translate} = this.props;
return (
'<p>' + translate('message.relatedChanges', 'Related changes') + '</p>' +
'<ul>' +
changedRedirects.map((redirect, index) => (
'<li>' + (redirect.host || '') + '/' + redirect.sourceUriPath + '&rarr;' + redirect.targetUriPath + '</li>'
)).join('') +
'</ul>'
);
return `
<p>${translate('message.relatedChanges', 'Related changes')}</p>
<ul>
${changedRedirects.map(redirect => `<li>${redirect.host || ''}/${redirect.sourceUriPath}&rarr;${redirect.targetUriPath}</li>`).join('')}
</ul>`;
};
};

render() {
Expand Down Expand Up @@ -253,35 +250,35 @@ export class RedirectForm extends PureComponent<RedirectFormProps, RedirectFormS
<div className="neos-control-group">
<label className="neos-control-label" htmlFor={idPrefix + 'host'}>{translate('host')}</label>
<input name="host" id={idPrefix + 'host'} type="text"
placeholder="www.example.org" value={host || ''} onChange={this.handleInputChange}/>
placeholder="www.example.org" value={host || ''} onChange={this.handleInputChange}/>
</div>
<div className="neos-control-group">
<label className="neos-control-label"
htmlFor={idPrefix + 'sourceUriPath'}>{translate('sourceUriPath')}*</label>
<input name="sourceUriPath" id={idPrefix + 'sourceUriPath'} type="text"
title={validSourceUriPathPattern} onChange={this.handleInputChange}
autoFocus={true} required={true} placeholder="the-old-url/product-a"
pattern={validSourceUriPathPattern} value={sourceUriPath || ''}/>
title={validSourceUriPathPattern} onChange={this.handleInputChange}
autoFocus={true} required={true} placeholder="the-old-url/product-a"
pattern={validSourceUriPathPattern} value={sourceUriPath || ''}/>
</div>
<div className="neos-control-group">
<label className="neos-control-label"
htmlFor={idPrefix + 'statusCode'}>{translate('statusCode')}</label>
htmlFor={idPrefix + 'statusCode'}>{translate('statusCode')}</label>
<select name="statusCode" id={idPrefix + 'statusCode'} value={statusCode}
onChange={this.handleInputChange}>
{Object.keys(statusCodes).map((code) => (
onChange={this.handleInputChange}>
{Object.keys(statusCodes).map(code => (
<option value={code} key={code}
title={statusCodes[code] != 'i18n' ? statusCodes[code] : translate('statusCodes.' + code + '.tooltip')}>
{statusCodes[code] != 'i18n' ? statusCodes[code] : translate('statusCodes.' + code + '.label')}
title={statusCodes[code] === 'i18n' ? translate('statusCodes.' + code + '.tooltip') : statusCodes[code]}>
{statusCodes[code] === 'i18n' ? translate('statusCodes.' + code + '.label') : statusCodes[code]}
</option>
))}
</select>
</div>
<div className="neos-control-group">
<label className="neos-control-label"
htmlFor={idPrefix + 'targetUriPath'}>{translate('targetUriPath')}*</label>
htmlFor={idPrefix + 'targetUriPath'}>{translate('targetUriPath')}*</label>
<input name="targetUriPath" id={idPrefix + 'targetUriPath'} type="text"
required={true} placeholder="(https://)the-new-url/product-a"
value={targetUriPath || ''} onChange={this.handleInputChange}/>
required={true} placeholder="(https://)the-new-url/product-a"
value={targetUriPath || ''} onChange={this.handleInputChange}/>
</div>
<div className="neos-control-group">
<label className="neos-control-label">{translate('startDateTime')}</label>
Expand All @@ -293,11 +290,11 @@ export class RedirectForm extends PureComponent<RedirectFormProps, RedirectFormS
</div>
<div className="neos-control-group neos-control-group--large">
<label className="neos-control-label"
htmlFor={idPrefix + 'comment'}>{translate('comment')}</label>
htmlFor={idPrefix + 'comment'}>{translate('comment')}</label>
<div className="textarea-wrap">
<textarea name="comment" id={idPrefix + 'comment'} value={comment || ''}
placeholder={translate('comment.placeholder')} rows={4}
onChange={this.handleInputChange}>
placeholder={translate('comment.placeholder')} rows={4}
onChange={this.handleInputChange}>
</textarea>
</div>
</div>
Expand All @@ -308,13 +305,13 @@ export class RedirectForm extends PureComponent<RedirectFormProps, RedirectFormS
</div>
{redirect && (
<div className="neos-control-group neos-control-group--auto">
<a className="neos-button add-redirect-form__cancel" onClick={() => handleCancelAction()}>
<a role="button" className="neos-button add-redirect-form__cancel" onClick={() => handleCancelAction()}>
{translate('action.cancel', 'Cancel')}
</a>
</div>
)}
</div>
</form>
)
);
}
}
Loading

0 comments on commit 50862f9

Please sign in to comment.