Skip to content

Commit

Permalink
Lint hard
Browse files Browse the repository at this point in the history
  • Loading branch information
nkbt committed Jan 10, 2018
1 parent ab8cd8f commit 12cc271
Show file tree
Hide file tree
Showing 24 changed files with 81 additions and 70 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ version: 2

jobs:
build:
working_directory: ~/react-collapse
working_directory: ~/app
docker:
- image: circleci/node:8
- image: circleci/node:8.4.0
- image: selenium/standalone-firefox:3.4.0

steps:
Expand Down
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"babel/semi": 2,
"jsx-a11y/href-no-hash": 0,
"jsx-a11y/label-has-for": 0,
"jsx-a11y/click-events-have-key-events": 0,
"react/forbid-prop-types": 0,
"react/jsx-filename-extension": [2, {"extensions": [".js"]}],
"react/jsx-closing-bracket-location": [2, {"nonEmpty": "after-props", "selfClosing": "after-props"}],
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Don't forget to manually install peer dependencies (`react`, `react-motion`) if

### 1998 Script Tag:
```html
<script src="https://unpkg.com/react/dist/react.js"></script>
<script src="https://unpkg.com/react/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-motion/build/react-motion.js"></script>
<script src="https://unpkg.com/react-collapse/build/react-collapse.js"></script>
(Module exposed as `ReactCollapse`)
Expand Down Expand Up @@ -309,6 +309,9 @@ yarn lint
yarn test

# to run end-to-end tests
# first, run `selenium/standalone-firefox:3.4.0` docker image
docker run -p 4444:4444 selenium/standalone-firefox:3.4.0
# then run test
yarn e2e
```

Expand Down
2 changes: 1 addition & 1 deletion example/App/AutoUnmount.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class AutoUnmount extends React.PureComponent {

constructor(props) {
super(props);
this.state = {isOpened: this.props.isOpened, shouldRender: false};
this.state = {isOpened: this.props.isOpened};
}


Expand Down
9 changes: 6 additions & 3 deletions example/App/Hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ export class Hooks extends React.PureComponent {
this.state = {
isOpened: false,
isResting: false,
renderHeight: -1,
keepContent: false,
height: -1,
width: -1,
paragraphs: 0
Expand Down Expand Up @@ -43,7 +41,12 @@ export class Hooks extends React.PureComponent {
};

render() {
const {isOpened, height, width, paragraphs} = this.state;
const {
isOpened,
height,
width,
paragraphs
} = this.state;

return (
<div>
Expand Down
16 changes: 7 additions & 9 deletions example/App/Issue163.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ import {Collapse} from '../../src';


export class Issue163 extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
isOpened: true,
isOverflowOpened: true
};
}
state = {
isOpened: true,
isOverflowOpened: true
};

onClick = () => this.setState({opened: !this.state.opened});

render() {
const {isOpened, isOverflowOpened} = this.state;
Expand Down Expand Up @@ -41,7 +37,9 @@ export class Issue163 extends React.PureComponent {
onChange={({target: {checked}}) => this.setState({isOverflowOpened: checked})} />
</label>
{isOverflowOpened && (
<div style={{width: 200, height: 200, background: 'black', position: 'absolute'}} />
<div style={{
width: 200, height: 200, background: 'black', position: 'absolute'
}} />
)}
</div>
</div>
Expand Down
16 changes: 8 additions & 8 deletions example/App/Issue59.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ const styles = {


export class Issue59 extends React.PureComponent {
constructor(props) {
super(props);
this.state = {opened: 1};
}
state = {opened: 1, whatever: 'b'};


onClick1 = () => {
Expand All @@ -42,26 +39,29 @@ export class Issue59 extends React.PureComponent {


onClick2 = () => {
this.setState({opened: 2}, () => setTimeout(() => this.setState({whatever: 1}), 50));
this.setState({opened: 2}, () => setTimeout(() => this.setState({whatever: 'bb'}), 50));
};


render() {
const {opened, whatever} = this.state;
return (
<div>
<div style={styles.mb3}>
<div style={styles.ba} onClick={this.onClick1}>Header 1</div>
<Collapse isOpened={this.state.opened === 1}>
<Collapse isOpened={opened === 1}>
<div style={{...styles.ba, ...styles.pa3}}>
<div style={{...styles.h3, ...styles.w3, ...styles.bgBlack}}>a</div>
</div>
</Collapse>
</div>
<div style={styles.mb3}>
<div style={styles.ba} onClick={this.onClick2}>Header 2</div>
<Collapse isOpened={this.state.opened === 2}>
<Collapse isOpened={opened === 2}>
<div style={{...styles.ba, ...styles.pa3}}>
<div style={{...styles.h3, ...styles.w3, ...styles.bgBlack}}>b</div>
<div style={{...styles.h3, ...styles.w3, ...styles.bgBlack}}>
{whatever}
</div>
</div>
</Collapse>
</div>
Expand Down
23 changes: 14 additions & 9 deletions example/App/SpringConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import {Collapse} from '../../src';


export class SpringConfig extends React.PureComponent {
constructor(props) {
super(props);

const preset = 'stiff';
const {stiffness, damping} = presets[preset];

this.state = {isOpened: false, height: 100, preset: 'stiff', stiffness, damping};
}
state = {
isOpened: false,
height: 100,
preset: 'stiff',
stiffness: presets.stiff.stiffness,
damping: presets.stiff.damping
};


onChangePreset = ({target: {value: preset}}) => {
Expand All @@ -22,7 +21,13 @@ export class SpringConfig extends React.PureComponent {


render() {
const {isOpened, height, preset, stiffness, damping} = this.state;
const {
isOpened,
height,
preset,
stiffness,
damping
} = this.state;

return (
<div>
Expand Down
4 changes: 2 additions & 2 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
'use strict';


require(`./lib`);
require(`./dist`);
require('./lib');
require('./dist');
2 changes: 1 addition & 1 deletion scripts/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';


const {npm, CWD} = require(`./utils/bash`);
const {npm, CWD} = require('./utils/bash');


npm(`webpack-dev-server --config ${require.resolve(`./utils/webpack/dev.config.js`)}`, {
Expand Down
2 changes: 1 addition & 1 deletion scripts/dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';


const {npm, CWD} = require(`./utils/bash`);
const {npm, CWD} = require('./utils/bash');


npm(`rimraf build`, {cwd: CWD});
Expand Down
16 changes: 8 additions & 8 deletions scripts/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
'use strict';


const path = require(`path`);
const nightwatch = require(`nightwatch`);
const finalhandler = require(`finalhandler`);
const http = require(`http`);
const serveStatic = require(`serve-static`);
const {CWD} = require(`./utils/bash`);
const portfinder = require(`portfinder`);
const path = require('path');
const nightwatch = require('nightwatch');
const finalhandler = require('finalhandler');
const http = require('http');
const serveStatic = require('serve-static');
const {CWD} = require('./utils/bash');
const portfinder = require('portfinder');


const {
Expand Down Expand Up @@ -101,7 +101,7 @@ const run = async ({cwd}) => {
};


require(`./pub`);
require('./pub');


run({cwd: CWD});
8 changes: 4 additions & 4 deletions scripts/ghPages.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
'use strict';


const path = require(`path`);
const {publish} = require(`gh-pages`);
const {CWD} = require(`./utils/bash`);
const path = require('path');
const {publish} = require('gh-pages');
const {CWD} = require('./utils/bash');


require(`./pub`);
require('./pub');


const {name} = require(path.join(CWD, `package.json`));
Expand Down
2 changes: 1 addition & 1 deletion scripts/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';


const {npm, CWD} = require(`./utils/bash`);
const {npm, CWD} = require('./utils/bash');


npm(`rimraf lib`, {cwd: CWD});
Expand Down
2 changes: 1 addition & 1 deletion scripts/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';


const {npm, CWD} = require(`./utils/bash`);
const {npm, CWD} = require('./utils/bash');


npm(`eslint .`, {cwd: CWD});
2 changes: 1 addition & 1 deletion scripts/pub.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';


const {npm, CWD} = require(`./utils/bash`);
const {npm, CWD} = require('./utils/bash');


npm(`rimraf lib`, {cwd: CWD});
Expand Down
8 changes: 4 additions & 4 deletions scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
'use strict';


const path = require(`path`);
const glob = require(`glob`);
const {CWD} = require(`./utils/bash`);
const path = require('path');
const glob = require('glob');
const {CWD} = require('./utils/bash');


require(`babel-register`)({
require('babel-register')({
babelrc: false,
plugins: [
`transform-object-rest-spread`,
Expand Down
7 changes: 4 additions & 3 deletions scripts/utils/bash.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';


const {execSync} = require(`child_process`);
const {resolve} = require(`path`);
const {execSync} = require('child_process');
const {resolve} = require('path');


const {NODE_DEBUG = ``} = process.env;
Expand All @@ -26,7 +26,8 @@ const bash = (cmd, options = {}) => {
const result = execSync(cleanCmd, Object.assign(
{stdio: `inherit`},
options,
{env: Object.assign({}, process.env, options.env)}));
{env: Object.assign({}, process.env, options.env)}
));
const stringResult = result ? result.toString().trim() : ``;
debug(`<<`, stringResult);
return stringResult;
Expand Down
2 changes: 1 addition & 1 deletion scripts/utils/ci.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';


const {CWD: SRC, bash} = require(`./bash`);
const {CWD: SRC, bash} = require('./bash');


const BUILD_HASH = bash(`git rev-parse --short HEAD`, {stdio: `pipe`});
Expand Down
10 changes: 5 additions & 5 deletions scripts/utils/webpack/common.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';


const webpack = require(`webpack`);
const HtmlWebpackPlugin = require(`html-webpack-plugin`);
const HtmlWebpackIncludeAssetsPlugin = require(`html-webpack-include-assets-plugin`);
const path = require(`path`);
const BabiliPlugin = require(`babili-webpack-plugin`);
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackIncludeAssetsPlugin = require('html-webpack-include-assets-plugin');
const path = require('path');
const BabiliPlugin = require('babili-webpack-plugin');


const {NODE_ENV = `development`} = process.env;
Expand Down
2 changes: 1 addition & 1 deletion scripts/utils/webpack/dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const {
loaders,
resolve,
stats
} = require(`./common`);
} = require('./common');


module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion scripts/utils/webpack/dist.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const {
resolve,
stats,
externals
} = require(`./common`);
} = require('./common');


module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion scripts/utils/webpack/min.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const {
resolve,
stats,
externals
} = require(`./common`);
} = require('./common');


module.exports = {
Expand Down
4 changes: 2 additions & 2 deletions scripts/utils/webpack/pub.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';


const ExtractTextPlugin = require(`extract-text-webpack-plugin`);
const ExtractTextPlugin = require('extract-text-webpack-plugin');

const {
pathTo,
Expand All @@ -11,7 +11,7 @@ const {
stats,
externals,
INCLUDE_JS
} = require(`./common`);
} = require('./common');


module.exports = {
Expand Down

0 comments on commit 12cc271

Please sign in to comment.