Skip to content

Commit

Permalink
Fix eslint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Hypnosphi committed Jun 5, 2018
1 parent 691d09b commit aebf131
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 39 deletions.
24 changes: 12 additions & 12 deletions addons/events/src/components/Event.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ const Wrapper = styled('div')({
width: '100%',
});

function getJSONFromString(str) {
try {
return JSON.parse(str);
} catch (e) {
return str;
}
}

class Item extends Component {
static propTypes = {
name: PropTypes.string.isRequired,
Expand All @@ -89,32 +97,24 @@ class Item extends Component {
payload: {},
};

static getJSONFromString(str) {
try {
return JSON.parse(str);
} catch (e) {
return str;
}
}
state = {
isTextAreaShowed: false,
};

static getDerivedStateFromProps = ({ payload }, { prevPayload }) => {
if (payload !== prevPayload) {
const payloadString = json.plain(payload);

return {
failed: false,
payload: Item.getJSONFromString(payloadString),
payload: getJSONFromString(payloadString),
payloadString,
prevPayload,
};
}
return null;
};

state = {
isTextAreaShowed: false,
};

onChange = ({ target: { value } }) => {
const newState = {
payloadString: value,
Expand Down
4 changes: 2 additions & 2 deletions addons/jest/src/components/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ const SuiteTotals = styled(({ successNumber, failedNumber, result, className })

const SuiteProgress = styled(({ successNumber, result, className }) => (
<div className={className} role="progressbar">
<span style={{ width: `${successNumber / result.assertionResults.length * 100}%` }}>
{`${successNumber / result.assertionResults.length * 100}%`}
<span style={{ width: `${(successNumber / result.assertionResults.length) * 100}%` }}>
{`${(successNumber / result.assertionResults.length) * 100}%`}
</span>
</div>
))(() => ({
Expand Down
34 changes: 15 additions & 19 deletions addons/storysource/src/StoryPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,27 @@ const styles = {
},
};

export default class StoryPanel extends Component {
static areLocationsEqual(a, b) {
return (
a.startLoc.line === b.startLoc.line &&
a.startLoc.col === b.startLoc.col &&
a.endLoc.line === b.endLoc.line &&
a.endLoc.col === b.endLoc.col
);
}

static getLocationKeys(locationsMap) {
return locationsMap
? Array.from(Object.keys(locationsMap)).sort(
(key1, key2) => locationsMap[key1].startLoc.line - locationsMap[key2].startLoc.line
)
: [];
}
const areLocationsEqual = (a, b) =>
a.startLoc.line === b.startLoc.line &&
a.startLoc.col === b.startLoc.col &&
a.endLoc.line === b.endLoc.line &&
a.endLoc.col === b.endLoc.col;

const getLocationKeys = locationsMap =>
locationsMap
? Array.from(Object.keys(locationsMap)).sort(
(key1, key2) => locationsMap[key1].startLoc.line - locationsMap[key2].startLoc.line
)
: [];

export default class StoryPanel extends Component {
state = { source: '// Here will be dragons 🐉' };

componentDidMount() {
const { channel } = this.props;

channel.on(EVENT_ID, ({ source, currentLocation, locationsMap }) => {
const locationsKeys = StoryPanel.getLocationKeys(locationsMap);
const locationsKeys = getLocationKeys(locationsMap);

this.setState({
source,
Expand Down Expand Up @@ -116,7 +112,7 @@ export default class StoryPanel extends Component {
const story = this.createPart(storyRows, stylesheet, useInlineStyles);
const storyKey = `${first}-${last}`;

if (StoryPanel.areLocationsEqual(location, currentLocation)) {
if (areLocationsEqual(location, currentLocation)) {
return (
<div key={storyKey} ref={this.setSelectedStoryRef} style={styles.selectedStory}>
{story}
Expand Down
10 changes: 5 additions & 5 deletions addons/viewport/src/manager/components/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ const getViewports = viewports =>
const setStoryDefaultViewportWait = 100;

export class Panel extends Component {
static propTypes = {
channel: PropTypes.shape({}).isRequired,
api: PropTypes.shape({}).isRequired,
};

static defaultOptions = {
viewports: INITIAL_VIEWPORTS,
defaultViewport: DEFAULT_VIEWPORT,
};

static propTypes = {
channel: PropTypes.shape({}).isRequired,
api: PropTypes.shape({}).isRequired,
};

constructor(props, context) {
super(props, context);
this.state = {
Expand Down
2 changes: 1 addition & 1 deletion dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ collectors:
settings:
batch_mode: true
batch_bootstrap: true
bootstrap_command: yarn --ignore-scripts --ignore-engines --silent
bootstrap_command: yarn --ignore-scripts --ignore-engines --silent && yarn lint:ts . --fix && yarn lint:js . --fix
github_labels:
- dependencies:update
github_assignees:
Expand Down

0 comments on commit aebf131

Please sign in to comment.