Skip to content

Commit

Permalink
fix: Fix propTypes and lint warnings (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
markdalgleish committed Dec 3, 2018
1 parent 406f2aa commit 2bd2721
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -7,15 +7,15 @@
"playroom": "bin/cli.js"
},
"scripts": {
"test": "npm run cypress",
"test": "npm run lint && npm run cypress",
"cypress": "start-server-and-test cypress:prepare http://localhost:9000 cypress:run",
"cypress:dev": "start-server-and-test cypress:prepare http://localhost:9000 cypress:open",
"cypress:prepare": "./bin/cli.js start --config cypress/projects/basic/playroom.config.js",
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"commit": "git-cz",
"lint": "eslint .",
"format": "prettier --config ./.prettierrc --write '**/*.{js,md,less}'",
"lint": "eslint . && prettier --list-different '**/*.{js,md,less}'",
"format": "prettier --write '**/*.{js,md,less}'",
"semantic-release": "semantic-release"
},
"husky": {
Expand Down
11 changes: 5 additions & 6 deletions src/Playroom/Playroom.js
@@ -1,5 +1,4 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import parsePropTypes from 'parse-prop-types';
import flatMap from 'lodash/flatMap';
import debounce from 'lodash/debounce';
Expand Down Expand Up @@ -36,13 +35,13 @@ const resizableConfig = {

const completeAfter = (cm, predicate) => {
const CodeMirror = cm.constructor;
const cur = cm.getCursor();
if (!predicate || predicate())
if (!predicate || predicate()) {
setTimeout(() => {
if (!cm.state.completionActive) {
cm.showHint({ completeSingle: false });
}
}, 100);
}

return CodeMirror.Pass;
};
Expand All @@ -52,6 +51,7 @@ const completeIfAfterLt = cm => {

return completeAfter(cm, () => {
const cur = cm.getCursor();
// eslint-disable-next-line new-cap
return cm.getRange(CodeMirror.Pos(cur.line, cur.ch - 1), cur) === '<';
});
};
Expand All @@ -62,9 +62,9 @@ const completeIfInTag = cm => {
return completeAfter(cm, () => {
const tok = cm.getTokenAt(cm.getCursor());
if (
tok.type == 'string' &&
tok.type === 'string' &&
(!/['"]/.test(tok.string.charAt(tok.string.length - 1)) ||
tok.string.length == 1)
tok.string.length === 1)
) {
return false;
}
Expand Down Expand Up @@ -189,7 +189,6 @@ export default class Playroom extends Component {
const tags = Object.assign(
{},
...componentNames.map(componentName => {
const { propTypes = {} } = components[componentName];
const parsedPropTypes = parsePropTypes(components[componentName]);
const filteredPropTypes = omit(
parsedPropTypes,
Expand Down
6 changes: 3 additions & 3 deletions src/Playroom/Preview/Preview.js
Expand Up @@ -10,15 +10,15 @@ import styles from './Preview.less';
export default class Preview extends Component {
static propTypes = {
code: PropTypes.string.isRequired,
components: PropTypes.node.isRequired,
components: PropTypes.object.isRequired,
themes: PropTypes.object,
frames: PropTypes.arrayOf(
PropTypes.shape({
theme: PropTypes.string.isRequired,
width: PropTypes.string.isRequired
width: PropTypes.number.isRequired
})
),
frameComponent: PropTypes.node.isRequired
frameComponent: PropTypes.func.isRequired
};

static defaultProps = { themes: [], frames: [] };
Expand Down

0 comments on commit 2bd2721

Please sign in to comment.