Skip to content

Commit f53595b

Browse files
committed
Fix all the various lint violations detected by eslint.
1 parent 65a85b0 commit f53595b

File tree

17 files changed

+75
-69
lines changed

17 files changed

+75
-69
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ modules/*/node_modules
33
tasks/*/node_modules
44
node_modules
55
js
6+
package.meta.js

apps/st2-actions/actions-details.component.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,11 @@ export default class ActionsDetails extends React.Component {
213213
},
214214
});
215215
}
216-
setWindowName(e){
217-
window.name="parent"
218-
}
216+
217+
setWindowName(e) {
218+
window.name = 'parent';
219+
}
220+
219221
handleRun(e, ...args) {
220222
e.preventDefault();
221223

@@ -259,7 +261,7 @@ setWindowName(e){
259261
target="_blank"
260262
to={`/action/${action.ref}`}
261263
className="st2-forms__button st2-details__toolbar-button"
262-
onClick ={e => this.setWindowName(e)}
264+
onClick={e => this.setWindowName(e)}
263265
>
264266
Edit
265267
</Link>

apps/st2-history/history-details.component.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default class HistoryDetails extends React.Component {
5656

5757
id: PropTypes.string,
5858
section: PropTypes.string,
59-
execution: PropTypes.object,
59+
execution: PropTypes.object, // eslint-disable-line react/no-unused-prop-types
6060
displayUTC: PropTypes.bool.isRequired,
6161
handleToggleUTC: PropTypes.func,
6262
}
@@ -74,7 +74,7 @@ export default class HistoryDetails extends React.Component {
7474
}
7575

7676
componentDidUpdate(prevProps) {
77-
const { id, execution } = this.props;
77+
const { id } = this.props;
7878

7979
if (id && id !== prevProps.id) {
8080
this.fetchExecution(id);

apps/st2-workflows/workflows.component.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default class Workflows extends Component {
7373
pack: PropTypes.string,
7474
meta: PropTypes.object,
7575
metaSource: PropTypes.string,
76-
setMeta: PropTypes.func,
76+
setMeta: PropTypes.func, // eslint-disable-line react/no-unused-prop-types
7777
input: PropTypes.array,
7878
workflowSource: PropTypes.string,
7979
dirty: PropTypes.bool,
@@ -243,7 +243,7 @@ export default class Workflows extends Component {
243243
}
244244

245245
save() {
246-
const { pack, meta, actions, workflowSource, metaSource, setMeta } = this.props;
246+
const { pack, meta, actions, workflowSource, metaSource } = this.props;
247247
const existingAction = actions.find(e => e.name === meta.name && e.pack === pack);
248248

249249
if (!meta.name) {

modules/st2-action-reporter/action-reporter.component.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@ const DEFAULT_MAX_RESULT_SIZE = 100 * 1024; // 100 KB
4242
*/
4343
function getBaseAPIUrl(api) {
4444
if (!api.server) {
45-
console.log("config.js is not correctly configured - it's missing API server URL entry")
45+
console.log('config.js is not correctly configured - it\'s missing API server URL entry');
4646
return null;
4747
}
4848

4949
if (!api.server.api) {
50-
console.log("config.js is not correctly configured - it's missing API server URL entry")
50+
console.log('config.js is not correctly configured - it\'s missing API server URL entry');
5151
return null;
5252
}
5353

54-
var url = api.server.api;
55-
var baseUrl;
54+
const url = api.server.api;
55+
let baseUrl;
5656

57-
if (!url.startsWith("http://") && !(url.startsWith("https://"))) {
57+
if (!url.startsWith('http://') && !(url.startsWith('https://'))) {
5858
baseUrl = `${window.location.protocol}${url}`;
5959
}
6060
else {
@@ -71,7 +71,7 @@ function getBaseAPIUrl(api) {
7171
* We specify a default value which can be overriden inside the config.
7272
*/
7373
function getMaxExecutionResultSizeForRender() {
74-
var maxResultSizeForRender;
74+
let maxResultSizeForRender;
7575

7676
try {
7777
maxResultSizeForRender = window.st2constants.st2Config.max_execution_result_size_for_render || DEFAULT_MAX_RESULT_SIZE;
@@ -88,6 +88,7 @@ export default class ActionReporter extends React.Component {
8888
className: PropTypes.string,
8989
runner: PropTypes.string.isRequired,
9090
execution: PropTypes.object.isRequired,
91+
api: PropTypes.object.isRequired,
9192
}
9293

9394
static utils = {
@@ -119,12 +120,12 @@ export default class ActionReporter extends React.Component {
119120

120121
return (
121122
<div {...props} className={cx(style.component, className)}>
122-
<div key="output" className={style.source}>Output</div>
123+
<div key="output" className={style.source}>Output</div>
123124
<p>
124-
Action output is too large to be displayed here ({`${resultSizeMB}`} MB).<br /><br />You can view raw execution output by clicking <a href={`${viewRawResultUrl}`} target="_blank">here</a> or you can download the output by clicking <a href={`${downloadRawResultUrl}`} target="_blank">here (uncompressed)</a> or <a href={`${downloadCompressedRawResultUrl}`} target="_blank">here (compressed)</a>.
125+
Action output is too large to be displayed here ({`${resultSizeMB}`} MB).<br /><br />You can view raw execution output by clicking <a href={`${viewRawResultUrl}`} target="_blank" rel="noopener noreferrer">here</a> or you can download the output by clicking <a href={`${downloadRawResultUrl}`} target="_blank" rel="noopener noreferrer">here (uncompressed)</a> or <a href={`${downloadCompressedRawResultUrl}`} target="_blank" rel="noopener noreferrer">here (compressed)</a>.
125126
</p>
126127
</div>
127-
);
128+
);
128129
}
129130

130131
return (

modules/st2-action-reporter/tests/test-action-reporter.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ describe(`${ActionReporter.name} Component`, () => {
2525
it('proxies className', () => {
2626
const instance = ReactTester.create(
2727
<ActionReporter
28-
className="foobar"
29-
runner="noop"
28+
className='foobar'
29+
runner='noop'
3030
execution={{}}
31-
api={{server: {api: "https://example.com:3000/v1"}}}
31+
api={{server: {api: 'https://example.com:3000/v1'}}}
3232
/>
3333
);
3434

@@ -38,10 +38,10 @@ describe(`${ActionReporter.name} Component`, () => {
3838
it('proxies extra props', () => {
3939
const instance = ReactTester.create(
4040
<ActionReporter
41-
foo="bar"
42-
runner="noop"
41+
foo='bar'
42+
runner='noop'
4343
execution={{}}
44-
api={{server: {api: "https://example.com:3000/v1"}}}
44+
api={{server: {api: 'https://example.com:3000/v1'}}}
4545
/>
4646
);
4747

@@ -51,16 +51,16 @@ describe(`${ActionReporter.name} Component`, () => {
5151
it('returns correct message on large result', () => {
5252
const instance = ReactTester.create(
5353
<ActionReporter
54-
foo="bar"
55-
runner="noop"
56-
execution={{id: "id1", result_size: 500 * 10244}}
57-
api={{server: {api: "https://example.com:3000/v1"}}}
54+
foo='bar'
55+
runner='noop'
56+
execution={{id: 'id1', result_size: 500 * 10244}}
57+
api={{server: {api: 'https://example.com:3000/v1'}}}
5858
/>
5959
);
6060

61-
const pElem = instance.toJSON()["children"][1].children.join("");
62-
expect(pElem).to.contain("Action output is too large to be displayed here")
63-
expect(pElem).to.contain("You can view raw")
61+
const pElem = instance.toJSON().children[1].children.join('');
62+
expect(pElem).to.contain('Action output is too large to be displayed here');
63+
expect(pElem).to.contain('You can view raw');
6464
});
6565
});
6666
});

modules/st2-api/api.js

+13-12
Original file line numberDiff line numberDiff line change
@@ -175,28 +175,29 @@ export class API {
175175

176176
const headers = {
177177
'content-type': 'application/json',
178-
179-
180178
};
181179

182180
if (this.token && this.token.token) {
183181
headers['x-auth-token'] = this.token.token;
184182
}
185-
183+
186184
const config = {
187185
method,
188186
url: this.route(opts),
189187
params: query,
190188
headers,
191-
transformResponse: [function transformResponse(data, headers) {
192-
if (typeof data === 'string' && headers["content-type"] === "application/json") {
193-
try {
194-
data = JSON.parse(data);
195-
} catch (e) { /* Ignore */ }
196-
}
197-
return data;
198-
}
199-
],
189+
transformResponse: [ function transformResponse(data, headers) {
190+
if (typeof data === 'string' && headers['content-type'] === 'application/json') {
191+
try {
192+
data = JSON.parse(data);
193+
}
194+
catch (e) {
195+
/* Ignore */
196+
}
197+
}
198+
199+
return data;
200+
} ],
200201
data,
201202
withCredentials: true,
202203
paramsSerializer: params => {

modules/st2-menu/menu.component.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ export default class Menu extends React.Component {
8484
const server = api.server;
8585
const showVersion = window.st2constants.st2Config.show_version_in_header || false;
8686
const hasPackageMeta = (window.st2constants.st2PackageMeta !== undefined);
87-
const st2webCommitsUrl = (showVersion && hasPackageMeta) ? "https://github.com/StackStorm/st2web/commit/" + window.st2constants.st2PackageMeta.git_sha : ""
87+
const st2webCommitsUrl = (showVersion && hasPackageMeta) ? `https://github.com/StackStorm/st2web/commit/${window.st2constants.st2PackageMeta.git_sha}` : '';
8888

8989
return (
9090
<header {...props} className={cx(style.component, className)}>
91-
<a href="#" className={style.logo} /> { (showVersion && hasPackageMeta) ? <span style={{ fontSize: 15, marginTop: 30 }}>st2: v{window.st2constants.st2PackageMeta.version}, st2web: <a href={st2webCommitsUrl} target="_blank">{window.st2constants.st2PackageMeta.git_sha}</a></span> : '' }
91+
<a href="#" className={style.logo} /> { (showVersion && hasPackageMeta) ? <span style={{ fontSize: 15, marginTop: 30 }}>st2: v{window.st2constants.st2PackageMeta.version}, st2web: <a href={st2webCommitsUrl} target="_blank" rel="noopener noreferrer">{window.st2constants.st2PackageMeta.git_sha}</a></span> : '' }
9292

9393
<div className={style.spacer} />
9494

modules/st2-pack-icon/pack-icon.component.js

+2
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ export default class PackIcon extends React.Component {
8282
<img src="img/icon.png" width="32" height="32" />
8383
);
8484
}
85+
/* Unreachable code, commented out :shrug:
8586
return (
8687
<img className={cx(style.image, small && style.imageSmall)} src={icons[name]} />
8788
);
89+
*/
8890
// ^^ WAT?
8991
}
9092

modules/st2-time/tests/test-time.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import { ReactTester } from '@stackstorm/module-test-utils';
2020
import Time from '..';
2121

2222
function isDST(d) {
23-
let jan = new Date(d.getFullYear(), 0, 1).getTimezoneOffset();
24-
let jul = new Date(d.getFullYear(), 6, 1).getTimezoneOffset();
25-
return Math.max(jan, jul) != d.getTimezoneOffset();
23+
const jan = new Date(d.getFullYear(), 0, 1).getTimezoneOffset();
24+
const jul = new Date(d.getFullYear(), 6, 1).getTimezoneOffset();
25+
return Math.max(jan, jul) !== d.getTimezoneOffset();
2626
}
2727

2828
describe(`${Time.name} Component`, () => {

modules/st2flow-canvas/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
TransitionInterface,
2323
} from '@stackstorm/st2flow-model/interfaces';
2424
import { NotificationInterface } from '@stackstorm/st2flow-notifications';
25-
import { Node } from 'react';
2625

2726
import React, { Component } from 'react';
2827
import { connect } from 'react-redux';
@@ -48,7 +47,6 @@ import PoissonRectangleSampler from './poisson-rect';
4847
import { origin } from './const';
4948

5049
import style from './style.css';
51-
import store from '../../apps/st2-workflows/store';
5250
type DOMMatrix = {
5351
m11: number,
5452
m22: number
@@ -228,6 +226,9 @@ export default class Canvas extends Component {
228226
nextTask: PropTypes.string,
229227
isCollapsed: PropTypes.object,
230228
toggleCollapse: PropTypes.func,
229+
dirtyflag: PropTypes.bool,
230+
fetchActionscalled: PropTypes.func,
231+
saveData: PropTypes.func,
231232
}
232233

233234
state = {

modules/st2flow-details/orquesta-properties.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ type TransitionProps = {
4646
})
4747
)
4848
export default class OrquestaTransition extends Component<TransitionProps, {}> {
49-
5049
static propTypes = {
5150
task: PropTypes.object.isRequired,
5251
issueModelCommand: PropTypes.func,
@@ -64,7 +63,10 @@ export default class OrquestaTransition extends Component<TransitionProps, {}> {
6463
}
6564

6665
getValue(value) {
67-
if(!isNaN(value) && value!== '') value = parseInt(value,10);
66+
if (!isNaN(value) && value !== '') {
67+
value = parseInt(value,10);
68+
}
69+
6870
return value;
6971
}
7072

@@ -119,20 +121,20 @@ export default class OrquestaTransition extends Component<TransitionProps, {}> {
119121
<Property key="delay" name="Delay" description="Add delay before task execution" value={task.delay != null} onChange={value => this.handleTaskProperty('delay', value ? '10' : false)}>
120122
{
121123
task.delay != null && (
122-
<div className={this.style.propertyChild}>
123-
<label htmlFor="delay" >
124+
<div className={this.style.propertyChild}>
125+
<label htmlFor="delay" >
124126
delay (seconds)
125127
<input
126128
type="text"
127129
id="delayField"
128130
size="3"
129131
className={this.style.delayField}
130132
value={(task.delay)}
131-
placeholder ="enter expression or integer"
133+
placeholder="enter expression or integer"
132134
onChange={e => this.handleTaskProperty('delay',this.getValue(e.target.value), true)}
133-
onBlur={ e => this.handleTaskProperty('delay',this.getValue(e.target.value), true)}
135+
onBlur={e => this.handleTaskProperty('delay',this.getValue(e.target.value), true)}
134136
/>
135-
</label>
137+
</label>
136138
</div>
137139
)
138140
}
@@ -143,7 +145,7 @@ export default class OrquestaTransition extends Component<TransitionProps, {}> {
143145
<div className={this.style.propertyChild}>
144146
<StringField name="when" value={task.retry.when} className="when-title" onChange={value => this.handleTaskProperty([ 'retry', 'when' ], value)} spec={{'default':'enter expression'}} />
145147
<StringField name="count" value={task.retry.count} className="count-title" onChange={value => this.handleTaskProperty([ 'retry', 'count' ], this.getValue(value))} spec={{'default':'enter expression or integer'}} />
146-
<StringField name="delay (seconds)" value={task.retry.delay} className="delay-title" onChange={value => this.handleTaskProperty([ 'retry', 'delay'], this.getValue(value))} spec={{'default':'enter expression or integer'}} />
148+
<StringField name="delay (seconds)" value={task.retry.delay} className="delay-title" onChange={value => this.handleTaskProperty([ 'retry', 'delay' ], this.getValue(value))} spec={{'default':'enter expression or integer'}} />
147149
</div>
148150
)
149151
}

modules/st2flow-header/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ export default class Header extends Component<{
5959

6060
return (
6161
<div className={cx(this.props.className, this.style.component)}>
62-
<a href="#" className={style.logo} />
63-
62+
<a href="#" className={style.logo} />
63+
6464
<div className={this.style.separator} />
6565
{
6666
api.token && api.server && (

modules/st2flow-model/base-class.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,11 @@ class BaseClass {
7676

7777
err.message = err.message.replace('JS-YAML:', 'YAML Parser:');
7878
notification.error(err.message);
79-
8079
});
8180

8281
this.yaml = yaml;
83-
8482
this.emitError(exception, STR_ERROR_YAML);
85-
return;
86-
83+
return;
8784
}
8885

8986
this.emitChange(oldTree);

modules/st2flow-notifications/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ class Notification extends Component {
4646
style = style
4747

4848
redirectLinkToParent = (e,newlink) => {
49-
e.preventDefault();
50-
var goBack = window.open(newlink, 'parent');
51-
goBack.focus();
49+
e.preventDefault();
50+
const goBack = window.open(newlink, 'parent');
51+
goBack.focus();
5252
}
5353

5454
render() {

modules/st2flow-palette/pack.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ export default class Action extends Component<{
7171
<i className={open ? 'icon-chevron_down palette-chevron-icon' : 'icon-chevron_right palette-chevron-icon'} />
7272
</div>
7373
<img ref={this.imgRef} src={api.route({ path: `/packs/views/file/${name}/icon.png` })} width="32" height="32" onError={() => this.handleImageError()} />
74-
<h2 className="pack-name-heading"> { name }</h2>
75-
74+
<h2 className="pack-name-heading"> { name }</h2>
7675
</div>
7776
{
7877
open && children

tasks/production/package-metadata.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ gulp.task('production-package-metadata', (done) => {
3333
fs.writeFileSync(file_path_1, data_1);
3434

3535
// Write it to .js file
36-
const data_2 = `angular.module('main').constant('st2PackageMeta', { version: "${pkg_version}", git_sha: "${git_sha}"});\n`
36+
const data_2 = `/* global angular */\nangular.module('main').constant('st2PackageMeta', { version: "${pkg_version}", git_sha: "${git_sha}"});\n`;
3737
const file_path_2 = path.join(path.resolve('./build'), 'package.meta.js');
3838
fs.writeFileSync(file_path_2, data_2);
3939

0 commit comments

Comments
 (0)