From 91db4f0bb13fcb5f117046ce11af78e255f37122 Mon Sep 17 00:00:00 2001
From: Max Schmitt
Date: Thu, 22 Aug 2019 10:42:22 +0200
Subject: [PATCH] feat: updated dependencies (#1855)
* feat: updated dependencies
* feat: bumped eslint
* fix: build
* fix: docs
* fix: cleanup
* fix: warnings warning
* fix: tests
* fix: Cannot find module 'babel-helpers'
* fix: use latest firefox
* fix: cleanup
* fix: warning
* feat: cleanup
* fix: readded .flowconfig
* feat: added mocha reporter
* fix: unit tests
* fix: added npm cache
* fix: cleanup babelrc config
* feat: reduce bundle size of docs
---
.babelrc | 3 -
.babelrc.js | 52 +-
.gitignore | 110 +-
.travis.yml | 6 +-
README.md | 15 +-
docs-site/src/boot.jsx | 2 +
docs-site/src/example_components.jsx | 4 +-
docs-site/{ => src}/images/logo.png | Bin
docs-site/{ => src}/images/ribbon.png | Bin
docs-site/src/root.jsx | 8 +-
karma.conf.js | 22 +-
package.json | 124 +-
rollup.config.js | 10 +-
rollup.umd.config.js | 36 +-
scripts/{buildDocs.sh => buildDocs.js} | 2 +-
...enerateMarkdown.sh => generateMarkdown.js} | 0
src/time.jsx | 2 +-
test/datepicker_test.js | 15 +-
test/exclude_time_period_test.js | 2 +-
test/exclude_times_test.js | 2 +-
test/helper_components/custom_input.jsx | 6 +-
test/include_times_test.js | 2 +-
test/index.js | 6 +-
test/inject_times_test.js | 2 +-
test/month_dropdown_test.js | 2 +-
test/month_year_dropdown_test.js | 2 +-
test/show_time_test.js | 2 +-
test/time_format_test.js | 2 +-
test/time_input_test.js | 2 +-
test/year_dropdown_options_test.js | 22 +-
test/year_dropdown_test.js | 2 +-
webpack.docs.config.js | 50 +-
yarn.lock | 7684 ++++++++++-------
33 files changed, 5065 insertions(+), 3134 deletions(-)
delete mode 100644 .babelrc
rename docs-site/{ => src}/images/logo.png (100%)
rename docs-site/{ => src}/images/ribbon.png (100%)
rename scripts/{buildDocs.sh => buildDocs.js} (95%)
rename scripts/{generateMarkdown.sh => generateMarkdown.js} (100%)
diff --git a/.babelrc b/.babelrc
deleted file mode 100644
index c268c77e7..000000000
--- a/.babelrc
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "presets": ["./.babelrc.js"]
-}
diff --git a/.babelrc.js b/.babelrc.js
index b3e008ffa..99e6ed69b 100644
--- a/.babelrc.js
+++ b/.babelrc.js
@@ -1,45 +1,19 @@
-var NODE_ENV = process.env.NODE_ENV;
-var MODULES = process.env.MODULES;
+const { NODE_ENV, MODULES } = process.env;
-var modules = MODULES === "false" || NODE_ENV === "test" ? "commonjs" : false;
+const modules = MODULES === "false" || NODE_ENV === "test" ? "commonjs" : false;
-var config = {
- presets: [
- [
- "env",
- {
- loose: true,
- modules: modules,
- forceAllTransforms: NODE_ENV === "production"
- }
- ],
- "stage-0",
- "react"
- ],
- plugins: []
-};
-
-if (NODE_ENV === "development") {
- config.plugins = config.plugins.concat([
- "transform-class-properties",
- [
- "react-transform",
- {
- transforms: [
- {
- transform: "react-transform-hmr",
- imports: ["react"],
- locals: ["module"]
- }
- ]
- }
- ],
- "add-react-displayname"
- ]);
-}
+const presets = [
+ "@babel/preset-env",
+ "@babel/preset-react",
+ "@babel/preset-flow"
+];
+const plugins = [
+ "@babel/plugin-transform-react-jsx",
+ "@babel/plugin-proposal-class-properties"
+];
if (NODE_ENV === "production") {
- config.plugins = config.plugins.concat(["transform-react-remove-prop-types"]);
+ plugins.push("transform-react-remove-prop-types");
}
-module.exports = config;
+module.exports = { presets, plugins };
diff --git a/.gitignore b/.gitignore
index 6058210ea..42f5287b7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,20 +1,110 @@
-node_modules
-.sass-cache
-npm-debug.log
-.DS_Store
-.idea
-.vscode
-.history
+# Created by https://www.gitignore.io/api/node
+# Edit at https://www.gitignore.io/?templates=node
+
+### Node ###
+# Logs
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+lerna-debug.log*
+
+# Diagnostic reports (https://nodejs.org/api/report.html)
+report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
+
+# Runtime data
+pids
+*.pid
+*.seed
+*.pid.lock
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+*.lcov
+
+# nyc test coverage
+.nyc_output
+
+# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
+.grunt
+
+# Bower dependency directory (https://bower.io/)
+bower_components
+
+# node-waf configuration
+.lock-wscript
+
+# Compiled binary addons (https://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directories
+node_modules/
+jspm_packages/
+
+# TypeScript v1 declaration files
+typings/
+
+# TypeScript cache
+*.tsbuildinfo
+
+# Optional npm cache directory
+.npm
+
+# Optional eslint cache
+.eslintcache
+
+# Optional REPL history
+.node_repl_history
+
+# Output of 'npm pack'
+*.tgz
+
+# Yarn Integrity file
+.yarn-integrity
+
+# dotenv environment variables file
+.env
+.env.test
+
+# parcel-bundler cache (https://parceljs.org/)
+.cache
+
+# next.js build output
+.next
+
+# nuxt.js build output
+.nuxt
+
+# vuepress build output
+.vuepress/dist
+
+# Serverless directories
+.serverless/
+
+# FuseBox cache
+.fusebox/
+
+# DynamoDB Local files
+.dynamodb/
+
+# End of https://www.gitignore.io/api/node
+
dist
lib
es
tmp
-coverage
-docs-site/bundle.js
-docs-site/style.css
+
+.vscode
*.iml
.idea
+docs-site/*bundle.js
+docs-site/style.css
+
docs/calendar.md
docs/date_input.md
docs/day.md
diff --git a/.travis.yml b/.travis.yml
index be330f0bb..3bbda1035 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,9 @@
language: node_js
node_js:
- "node"
-cache: yarn
+cache:
+ - npm
+ - yarn
script:
- yarn lint
- yarn test
@@ -15,6 +17,8 @@ deploy:
local_dir: docs-site
on:
branch: master
+addons:
+ firefox: latest
notifications:
slack:
secure: kAmrLltV0ZLuhl6rKk26fDLGuoCch6AYaObRQje4UZlxVQjR2467k430vOZLqv39Mr3U5XmYl6VLcCGmBr3tjM/9c1zjoXnRT8MRy4eIYaUr/thXeh2FlfHKOk8rXnNOoRZ1kBsCzCDFCNDYZZA4jya8S5ITcQyGyYcOqBWVy1w=
diff --git a/README.md b/README.md
index c96952bcc..e2b74e10f 100644
--- a/README.md
+++ b/README.md
@@ -32,19 +32,15 @@ import "react-datepicker/dist/react-datepicker.css";
// import 'react-datepicker/dist/react-datepicker-cssmodules.css';
class Example extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- startDate: new Date()
- };
- this.handleChange = this.handleChange.bind(this);
- }
+ state = {
+ startDate: new Date()
+ };
- handleChange(date) {
+ handleChange = date => {
this.setState({
startDate: date
});
- }
+ };
render() {
return (
@@ -117,7 +113,6 @@ registerLocale('es', es)
Locales can be changed in the following way:
- **Globally** - `setDefaultLocale('es');`
-
## Compatibility
diff --git a/docs-site/src/boot.jsx b/docs-site/src/boot.jsx
index 376ad6133..7166d4fd1 100644
--- a/docs-site/src/boot.jsx
+++ b/docs-site/src/boot.jsx
@@ -1,3 +1,5 @@
+import "core-js/stable";
+
import React from "react";
import ReactDOM from "react-dom";
import Root from "./root";
diff --git a/docs-site/src/example_components.jsx b/docs-site/src/example_components.jsx
index 4d6fcab75..fd23fe9c8 100644
--- a/docs-site/src/example_components.jsx
+++ b/docs-site/src/example_components.jsx
@@ -1,5 +1,6 @@
import React from "react";
-import hljs from "highlight.js";
+import hljs from "highlight.js/lib/highlight";
+import hljsJavaScriptLanguage from "highlight.js/lib/languages/javascript";
import Default from "./examples/default";
import CodeExampleComponent from "./code_example_component";
@@ -66,6 +67,7 @@ import "./style.scss";
export default class exampleComponents extends React.Component {
componentDidMount() {
hljs.initHighlightingOnLoad();
+ hljs.registerLanguage("javascript", hljsJavaScriptLanguage);
}
examples = [
diff --git a/docs-site/images/logo.png b/docs-site/src/images/logo.png
similarity index 100%
rename from docs-site/images/logo.png
rename to docs-site/src/images/logo.png
diff --git a/docs-site/images/ribbon.png b/docs-site/src/images/ribbon.png
similarity index 100%
rename from docs-site/images/ribbon.png
rename to docs-site/src/images/ribbon.png
diff --git a/docs-site/src/root.jsx b/docs-site/src/root.jsx
index d40b680c8..19d6de923 100644
--- a/docs-site/src/root.jsx
+++ b/docs-site/src/root.jsx
@@ -17,7 +17,7 @@ export default class Root extends React.Component {
Crafted by{" "}
npm install react-datepicker --save
+
@@ -79,7 +83,7 @@ export default class Root extends React.Component {
diff --git a/karma.conf.js b/karma.conf.js
index 6f876ca05..c7b4a6eb6 100644
--- a/karma.conf.js
+++ b/karma.conf.js
@@ -1,9 +1,6 @@
// Karma configuration
-// Generated on Tue Jul 28 2015 16:29:51 GMT+0200 (CEST)
-var webpack = require("webpack");
-var path = require("path");
-
-var CONTINUOUS_INTEGRATION = process.env.CONTINUOUS_INTEGRATION === "true";
+const webpack = require("webpack");
+const path = require("path");
module.exports = function(config) {
config.set({
@@ -11,24 +8,23 @@ module.exports = function(config) {
browsers: ["FirefoxHeadless"],
- singleRun: CONTINUOUS_INTEGRATION,
-
files: ["test/index.js"],
preprocessors: {
"test/index.js": ["webpack", "sourcemap"]
},
- reporters: ["dots", "coverage"],
+ reporters: ["mocha", "coverage"],
webpack: {
+ mode: "development",
devtool: "inline-source-map",
module: {
- loaders: [
+ rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
- loader: "babel",
+ loader: "babel-loader",
query: {
presets: ["airbnb"]
}
@@ -36,7 +32,9 @@ module.exports = function(config) {
{
test: /\.jsx?$/,
include: path.resolve(__dirname, "src"),
- loader: "isparta"
+ loader: "istanbul-instrumenter-loader",
+ enforce: "post",
+ options: { esModules: true }
}
]
},
@@ -46,7 +44,7 @@ module.exports = function(config) {
})
],
resolve: {
- extensions: ["", ".jsx", ".js"]
+ extensions: [".jsx", ".js"]
},
externals: {
cheerio: "window",
diff --git a/package.json b/package.json
index 6d4ac1de2..3fac836c9 100644
--- a/package.json
+++ b/package.json
@@ -31,82 +31,84 @@
"url": "https://github.com/Hacker0x01/react-datepicker/issues"
},
"devDependencies": {
- "babel-core": "^6.26.0",
- "babel-eslint": "^8.0.2",
- "babel-loader": "^6.2.10",
- "babel-plugin-add-react-displayname": "^0.0.4",
+ "@babel/core": "^7.5.5",
+ "@babel/helpers": "^7.5.5",
+ "@babel/plugin-external-helpers": "^7.2.0",
+ "@babel/plugin-proposal-class-properties": "^7.5.5",
+ "@babel/preset-env": "^7.5.5",
+ "@babel/preset-flow": "^7.0.0",
+ "@babel/preset-react": "^7.0.0",
+ "babel-eslint": "^10.0.2",
+ "babel-loader": "^8.0.6",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-react-transform": "^3.0.0",
- "babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
- "babel-polyfill": "^6.26.0",
- "babel-preset-airbnb": "^2.4.0",
- "babel-preset-env": "^1.7.0",
- "babel-preset-react": "^6.24.1",
- "babel-preset-stage-0": "^6.24.1",
- "chai": "^3.5.0",
- "codecov": "^3.1.0",
- "cross-env": "^5.1.1",
- "css-loader": "^0.28.7",
- "enzyme": "^3.7.0",
- "enzyme-adapter-react-16": "^1.6.0",
- "eslint": "^4.10.0",
- "eslint-plugin-import": "^2.8.0",
- "eslint-plugin-node": "^5.2.1",
- "eslint-plugin-promise": "^3.6.0",
- "eslint-plugin-react": "^7.4.0",
- "express": "^4.16.4",
- "extract-text-webpack-plugin": "^1.0.1",
- "flow-bin": "^0.68.0",
- "highlight.js": "^9.13.1",
- "husky": "^0.14.3",
- "isparta-loader": "^2.0.0",
- "karma": "^4.1.0",
+ "babel-preset-airbnb": "^4.0.1",
+ "chai": "^4.2.0",
+ "codecov": "^3.5.0",
+ "core-js": "^3.2.1",
+ "cross-env": "^5.2.0",
+ "css-loader": "^3.2.0",
+ "enzyme": "^3.10.0",
+ "enzyme-adapter-react-16": "^1.14.0",
+ "eslint": "^6.2.1",
+ "eslint-plugin-import": "^2.18.2",
+ "eslint-plugin-node": "^9.1.0",
+ "eslint-plugin-promise": "^4.2.1",
+ "eslint-plugin-react": "^7.14.3",
+ "express": "^4.17.1",
+ "flow-bin": "^0.105.2",
+ "highlight.js": "^9.15.10",
+ "husky": "^3.0.4",
+ "istanbul-instrumenter-loader": "^3.0.1",
+ "karma": "^4.2.0",
"karma-chai": "^0.1.0",
- "karma-coverage": "^1.1.2",
- "karma-firefox-launcher": "^1.0.1",
+ "karma-coverage": "^2.0.1",
+ "karma-firefox-launcher": "^1.2.0",
"karma-mocha": "^1.3.0",
+ "karma-mocha-reporter": "^2.2.5",
"karma-sinon": "^1.0.5",
"karma-sourcemap-loader": "^0.3.7",
- "karma-webpack": "^2.0.5",
- "lint-staged": "^6.0.0",
- "mocha": "^4.0.1",
+ "karma-webpack": "^4.0.2",
+ "lint-staged": "^9.2.3",
+ "mini-css-extract-plugin": "^0.8.0",
+ "mocha": "^6.2.0",
"node-sass": "^4.12.0",
- "npm-run-all": "^4.1.2",
- "prettier": "^1.9.2",
- "react": "^16.1.0",
- "react-docgen": "^2.20.0",
- "react-dom": "^16.1.0",
- "react-test-renderer": "^16.1.0",
+ "npm-run-all": "^4.1.5",
+ "prettier": "^1.18.2",
+ "react": "^16.9.0",
+ "react-docgen": "^4.1.1",
+ "react-dom": "^16.9.0",
+ "react-test-renderer": "^16.9.0",
"react-transform-hmr": "^1.0.4",
- "rimraf": "^2.6.2",
- "rollup": "^0.51.3",
- "rollup-plugin-babel": "^3.0.2",
- "rollup-plugin-commonjs": "^8.2.6",
- "rollup-plugin-node-resolve": "^3.0.0",
- "rollup-plugin-uglify": "^2.0.1",
+ "rollup": "^1.19.4",
+ "rollup-plugin-babel": "^4.3.3",
+ "rollup-plugin-commonjs": "^10.0.2",
+ "rollup-plugin-node-resolve": "^5.2.0",
+ "rollup-plugin-uglify": "^6.0.2",
"sass-lint": "^1.13.1",
- "sass-loader": "^4.1.1",
- "sinon": "^4.1.2",
- "style-loader": "^0.19.0",
- "webpack": "^1.13.0",
- "webpack-dev-middleware": "^1.12.0",
- "webpack-dev-server": "^1.16.5",
- "webpack-hot-middleware": "^2.20.0"
+ "sass-loader": "^7.3.1",
+ "sinon": "^7.4.1",
+ "style-loader": "^1.0.0",
+ "webpack": "^4.39.2",
+ "webpack-cli": "^3.3.7",
+ "webpack-dev-middleware": "^3.7.0",
+ "webpack-dev-server": "^3.8.0",
+ "webpack-hot-middleware": "^2.25.0"
},
"peerDependencies": {
- "react": "^16.0.0",
- "react-dom": "^16.0.0"
+ "react": "^16.9.0",
+ "react-dom": "^16.9.0"
},
"dependencies": {
- "classnames": "^2.2.5",
+ "classnames": "^2.2.6",
"date-fns": "^2.0.0",
- "prop-types": "^15.6.0",
- "react-onclickoutside": "^6.7.1",
- "react-popper": "^1.0.2"
+ "prop-types": "^15.7.2",
+ "react-onclickoutside": "^6.9.0",
+ "react-popper": "^1.3.4"
},
"scripts": {
- "eslint": "eslint {src,test,docs-site/src}/**/*.{js,jsx} *.js",
+ "eslint": "eslint --ext .js,.jsx src test docs-site/src",
"flow": "flow",
"precommit": "lint-staged",
"sass-lint": "sass-lint --config .sass-lint.yml 'src/stylesheets/*.scss, docs-site/src/*.scss' -i 'docs-site/src/higlight.scss, docs-site/src/reset.scss'",
@@ -114,10 +116,6 @@
"start": "cross-env MODULES=false node server.js",
"test": "cross-env NODE_ENV=test karma start karma.conf.js --single-run",
"test:watch": "cross-env NODE_ENV=test karma start karma.conf.js --watch",
- "prepublish": "test $(npm -v | tr . '\\n' | head -n 1) -ge '4' || exit 1",
- "prepare": "npm run build",
- "codecov": "cat coverage/*/lcov.info | ./node_modules/.bin/codecov",
- "prebuild": "rimraf es lib dist",
"build": "cross-env NODE_ENV=production run-p build:** && run-p css:**",
"build-dev": "cross-env NODE_ENV=development run-p build:** && run-p css:**",
"css:prod": "node-sass --output-style compressed src/stylesheets/datepicker.scss > dist/react-datepicker.min.css",
diff --git a/rollup.config.js b/rollup.config.js
index aa9010518..9ad481875 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -4,7 +4,7 @@ import path from "path";
import nodeResolve from "rollup-plugin-node-resolve";
import babel from "rollup-plugin-babel";
import commonjs from "rollup-plugin-commonjs";
-import { list as babelHelpersList } from "babel-helpers";
+import { list as babelHelpersList } from "@babel/helpers";
import pkg from "./package.json";
// it's important to mark all subpackages of data-fns as externals
@@ -19,12 +19,16 @@ const config = {
},
plugins: [
nodeResolve({
- jsnext: true,
+ mainFields: ["module"],
extensions: [".js", ".jsx"]
}),
babel({
exclude: "node_modules/**",
- plugins: ["external-helpers"],
+ plugins: [
+ "@babel/plugin-external-helpers",
+ "@babel/plugin-proposal-class-properties"
+ ],
+ runtimeHelpers: true,
externalHelpersWhitelist: babelHelpersList.filter(
helperName => helperName !== "asyncGenerator"
)
diff --git a/rollup.umd.config.js b/rollup.umd.config.js
index 803769c00..574ff50c9 100644
--- a/rollup.umd.config.js
+++ b/rollup.umd.config.js
@@ -1,31 +1,31 @@
import config from "./rollup.config.js";
-import uglify from "rollup-plugin-uglify";
+import { uglify } from "rollup-plugin-uglify";
-const env = process.env.NODE_ENV;
-
-const umdConfig = Object.assign({}, config, {
- output: Object.assign({}, config.output, {
+const umdConfig = {
+ ...config,
+ output: {
+ ...config.output,
format: "umd",
- name: "DatePicker"
- }),
- globals: {
- react: "React",
- "prop-types": "PropTypes",
- "react-onclickoutside": "onClickOutside",
- "react-popper": "ReactPopper",
- classnames: "classNames"
+ name: "DatePicker",
+ globals: {
+ react: "React",
+ "prop-types": "PropTypes",
+ "react-onclickoutside": "onClickOutside",
+ "react-popper": "ReactPopper",
+ classnames: "classNames"
+ }
}
-});
+};
-if (env === "production") {
+if (process.env.NODE_ENV === "production") {
config.plugins.push(
uglify({
compress: {
pure_getters: true,
unsafe: true,
- unsafe_comps: true,
- warnings: false
- }
+ unsafe_comps: true
+ },
+ warnings: false
})
);
}
diff --git a/scripts/buildDocs.sh b/scripts/buildDocs.js
similarity index 95%
rename from scripts/buildDocs.sh
rename to scripts/buildDocs.js
index feca7534a..e6659a76b 100755
--- a/scripts/buildDocs.sh
+++ b/scripts/buildDocs.js
@@ -6,7 +6,7 @@
*/
var fs = require('fs');
-var generateMarkdown = require('./generateMarkdown.sh');
+var generateMarkdown = require('./generateMarkdown');
var path = require('path');
var json = '';
diff --git a/scripts/generateMarkdown.sh b/scripts/generateMarkdown.js
similarity index 100%
rename from scripts/generateMarkdown.sh
rename to scripts/generateMarkdown.js
diff --git a/src/time.jsx b/src/time.jsx
index e53bebdf0..3f830814a 100644
--- a/src/time.jsx
+++ b/src/time.jsx
@@ -185,7 +185,7 @@ export default class Time extends React.Component {
}}
style={height ? { height } : {}}
>
- {this.renderTimes.bind(this)()}
+ {this.renderTimes()}
diff --git a/test/datepicker_test.js b/test/datepicker_test.js
index 3a95470f1..2175830bc 100644
--- a/test/datepicker_test.js
+++ b/test/datepicker_test.js
@@ -46,7 +46,7 @@ describe("DatePicker", () => {
let sandbox;
beforeEach(() => {
- sandbox = sinon.sandbox.create();
+ sandbox = sinon.createSandbox();
});
afterEach(() => {
@@ -1124,15 +1124,10 @@ describe("DatePicker", () => {
});
it("should fire onInputClick when input is clicked", () => {
const onInputClickSpy = sinon.spy();
- var datePicker = TestUtils.renderIntoDocument(
-