diff --git a/.eslintrc b/.eslintrc index 58b1abbaf..e9c306bef 100644 --- a/.eslintrc +++ b/.eslintrc @@ -5,8 +5,11 @@ "comma-dangle": 0, "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }], "import/no-extraneous-dependencies": 0, + "import/prefer-default-export": 1, "import/extensions": 0, "import/no-unresolved": 0, + "property": 0, + "no-mixed-operators": 0, "strict": 0 }, "ecmaFeatures": { @@ -38,7 +41,9 @@ mixpanel: true, "expect": true, "browser": true, + "import": true, "FB": true, + "window": true, sinon: true }, "env": { diff --git a/package.json b/package.json index 044377b8e..fdfced3a1 100644 --- a/package.json +++ b/package.json @@ -12,14 +12,28 @@ "test:dev:lint": "./node_modules/eslint/bin/eslint.js ./src", "test:stylelint": "stylelint './src/**/*.scss' --config ./webpack/.stylelintrc", "dev-old": "env NODE_PATH='./src' PORT=8000 UV_THREADPOOL_SIZE=100 node ./webpack/webpack-dev-server.js & env NODE_PATH='./src' PORT=8000 node ./bin/server.js", - "dev": "env NODE_PATH='./src' PORT=8000 UV_THREADPOOL_SIZE=100 node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --config ./webpack/dev.config.js & env NODE_PATH='./src' PORT=8000 node ./bin/server.js", + "dev": "env NODE_PATH='./src' PORT=8000 UV_THREADPOOL_SIZE=100 node --expose-gc ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --config ./webpack/dev.config.js & env NODE_PATH='./src' PORT=8000 node --expose-gc ./bin/server.js", "start": "NODE_PATH='src' node ./start", "build": "npm run build:client & npm run build:server", "build:server": "babel ./src -d ./dist -D", "build:client": "webpack --config ./webpack/prod.config.js", "validate": "npm ls", "analyze:build": "env NODE_ENV=production webpack --json --config ./webpack/prod.config.js > bundle-stats.json", - "analyze:json": "webpack-bundle-size-analyzer bundle-stats.json" + "analyze:json": "webpack-bundle-size-analyzer bundle-stats.json", + "lint:fix": "npm run test:dev:lint -- --fix", + "prettier": "prettier --single-quote --write", + "precommit": "lint-staged" + }, + "pre-commit": [ + "test:stylelint", + "precommit" + ], + "lint-staged": { + "*.js": [ + "npm run prettier", + "npm run lint:fix", + "git add" + ] }, "engines": { "node": ">= 6.3.0" @@ -72,6 +86,7 @@ "file-loader": "0.8.5", "fontfaceobserver": "1.7.3", "history": "^3.0.0", + "html-pdf": "^2.1.0", "html-webpack-plugin": "1.7.0", "http-proxy": "1.14.0", "humps": "2.0.0", @@ -100,7 +115,7 @@ "react-hot-loader": "3.0.0-beta.6", "react-inlinesvg": "0.5.4", "react-intl": "2.1.5", - "react-loadable": "^3.0.1", + "react-loadable": "^3.3.1", "react-metrics": "1.2.1", "react-paginate": "4.1.0", "react-redux": "5.0.1", @@ -158,6 +173,7 @@ "karma-sinon": "1.0.4", "karma-sourcemap-loader": "0.3.7", "karma-webpack": "1.8.0", + "lint-staged": "^3.4.0", "mocha": "2.2.5", "nodemon": "1.7.1", "path": "0.11.14", @@ -165,6 +181,7 @@ "phantomjs-polyfill": "0.0.1", "piping": "0.3.0", "pre-commit": "1.1.3", + "prettier": "^1.2.2", "react-addons-test-utils": "15.4.1", "react-transform-catch-errors": "1.0.0", "react-transform-hmr": "1.0.1", @@ -179,9 +196,5 @@ "webpack-bundle-analyzer": "2.2.1", "webpack-dev-server": "2.1.0-beta.0", "webpack-hot-middleware": "2.12.2" - }, - "pre-commit": [ - "test:dev:lint", - "test:stylelint" - ] + } } diff --git a/src/components/Audioplayer/RepeatDropdown/index.js b/src/components/Audioplayer/RepeatDropdown/index.js index 6b58449c1..c712c3abe 100644 --- a/src/components/Audioplayer/RepeatDropdown/index.js +++ b/src/components/Audioplayer/RepeatDropdown/index.js @@ -12,7 +12,6 @@ import LocaleFormattedMessage from 'components/LocaleFormattedMessage'; const style = require('../style.scss'); class RepeatButton extends Component { - handleToggle = () => { const { repeat, setRepeat, current } = this.props; @@ -41,7 +40,7 @@ class RepeatButton extends Component { from: current, to: current + 3 }); - } + }; renderRangeAyahs() { const { chapter, repeat, setRepeat } = this.props; @@ -54,14 +53,16 @@ class RepeatButton extends Component { {' '}: + /> + {' '} + :
{ let to = parseInt(event.target.value, 10) + 3; - to = to < chapter.ayat ? to : chapter.ayat; + to = to < chapter.versesCount ? to : chapter.versesCount; setRepeat({ ...repeat, from: parseInt(event.target.value, 10), @@ -69,18 +70,17 @@ class RepeatButton extends Component { }); }} > - { - array.reduce((options, ayah, index) => { - if (index + 1 < chapter.ayat) { // Exclude last verse - options.push( - - ); - } - return options; - }, []) - } + {array.reduce((options, ayah, index) => { + if (index + 1 < chapter.versesCount) { + // Exclude last verse + options.push( + + ); + } + return options; + }, [])}
  • -
  • @@ -88,25 +88,30 @@ class RepeatButton extends Component { {' '}: + /> + {' '} + :
    setRepeat({ ...repeat, to: parseInt(event.target.value, 10) })} + onChange={event => + setRepeat({ ...repeat, to: parseInt(event.target.value, 10) })} > - { - array.reduce((options, ayah, index) => { - if ((repeat.from ? repeat.from : 1) < index + 1 && index + 1 <= chapter.ayat) { - options.push( - - ); - } - return options; - }, []) - } + {array.reduce((options, ayah, index) => { + if ( + (repeat.from ? repeat.from : 1) < index + 1 && + index + 1 <= chapter.versesCount + ) { + // eslint-disable-line max-len + options.push( + + ); + } + return options; + }, [])} @@ -123,23 +128,26 @@ class RepeatButton extends Component { {' '}:
    + /> + {' '} + : + {' '} +
    setRepeat({ - ...repeat, - from: parseInt(event.target.value, 10), - to: parseInt(event.target.value, 10) - })} + onChange={event => + setRepeat({ + ...repeat, + from: parseInt(event.target.value, 10), + to: parseInt(event.target.value, 10) + })} > - { - array.map((ayah, index) => ( - - )) - } + {array.map((ayah, index) => ( + + ))} ); @@ -179,7 +187,9 @@ class RepeatButton extends Component { return (
    - {repeat.from === repeat.to ? this.renderSingleAyah() : this.renderRangeAyahs()} + {repeat.from === repeat.to + ? this.renderSingleAyah() + : this.renderRangeAyahs()}
    ); } @@ -194,27 +204,30 @@ class RepeatButton extends Component { :
    + /> + : + {' '} +
    setRepeat({ - ...repeat, - times: parseInt(event.target.value, 10) - })} + onChange={event => + setRepeat({ + ...repeat, + times: parseInt(event.target.value, 10) + })} > - { - times.map((ayah, index) => ( - - )) - } + {times.map((ayah, index) => ( + + ))} @@ -234,7 +247,8 @@ class RepeatButton extends Component { {' '} + /> + {' '} { if (isLoading) { - return pastDelay ?
    Loading...
    : null; + return pastDelay ? - { - React.cloneElement( - nav || , - { - handleSidebarToggle: () => this.setState({ sidebarOpen: !this.state.sidebarOpen }) - } - ) - } - this.setState({ sidebarOpen: open })} - /> + {React.cloneElement(nav || , { + handleSidebarToggle: () => + this.setState({ sidebarOpen: !this.state.sidebarOpen }) + })} + {__CLIENT__ && + this.setState({ sidebarOpen: open })} + />} {children || main}