Skip to content

Commit

Permalink
Convert project to Typescript and add es2015 build target (#672)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: the TS type definition for `combineEpics()` no longer accepts any unsafe overloads. Cast to `any` if you need to provide unsafe/untyped Epics.
  • Loading branch information
csvn authored and jayphelps committed Oct 16, 2019
1 parent 6d17bdc commit ba4699e
Show file tree
Hide file tree
Showing 34 changed files with 336 additions and 506 deletions.
6 changes: 0 additions & 6 deletions .babelrc

This file was deleted.

43 changes: 32 additions & 11 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"parser": "babel-eslint",
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": [
// Turn off problematic eslint rules
"plugin:@typescript-eslint/eslint-recommended",
// Recommended Typescript-eslint rules
"plugin:@typescript-eslint/recommended",
// Type checking Typescript-eslint rules
"plugin:@typescript-eslint/recommended-requiring-type-checking"
],
"rules": {
// Enforces getter/setter pairs in objects
"accessor-pairs": 0,
Expand All @@ -23,8 +32,6 @@
"eqeqeq": 2,
// make sure for-in loops have an if statement
"guard-for-in": 2,
// disabled use of an undefined variable
"no-undef": 2,
// disallow the use of console
"no-console": 0,
// disallow the use of alert, confirm, and prompt
Expand Down Expand Up @@ -84,8 +91,6 @@
"no-process-env": 0,
// disallow usage of __proto__ property
"no-proto": 2,
// disallow declaring the same variable more then once
"no-redeclare": 2,
// disallow use of assignment in return statement
"no-return-assign": 2,
// disallow use of `javascript:` urls.
Expand All @@ -98,8 +103,6 @@
"no-throw-literal": 2,
// disallow usage of expressions in statement position
"no-unused-expressions": 2,
// disallow unused variables/imports
"no-unused-vars": [2, { "vars": "all", "args": "none" }],
// disallow unnecessary .call() and .apply()
"no-useless-call": 0,
// disallow use of void operator
Expand Down Expand Up @@ -238,16 +241,29 @@
// disallow using `var`. Must use `let` or `const`
"no-var": 2,
"no-class-assign": 2,
"no-const-assign": 2,
"no-dupe-class-members": 2,
"no-this-before-super": 2,
"prefer-const": 0,
"prefer-spread": 2,
// require object literal shorthand
"object-shorthand": [2, "always"],
"arrow-spacing": 2,
"prefer-arrow-callback": 2,
"arrow-parens": [0, "as-needed"],

/* Typescript */
// turn off troublesome rules
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/ban-ts-ignore": "off",
// disallow unused variables/imports
"@typescript-eslint/no-unused-vars": [2, {
"vars": "all",
"args": "none",
"varsIgnorePattern": "^_"
}],
// TODO: Use this rule instead of eslint's "camelcase"?
"@typescript-eslint/camelcase": "off"
},
"env": {
"browser": true,
Expand All @@ -260,6 +276,11 @@
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
},
"project": [
"./src/tsconfig.json",
"./test/tsconfig.json"
],
"tsconfigRootDir": "."
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vscode
npm-debug.log
node_modules
lib
Expand Down
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ node_js:
- "stable"
- "lts/*"

env:
# Avoids file watcher error "ENOSPC" from using chokidar with linting
- PARSER_NO_WATCH=true

script: npm run test

cache:
Expand Down
10 changes: 10 additions & 0 deletions configs/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.defaults.json",
"compilerOptions": {
"outDir": "../dist/cjs",
"module": "commonjs"
},
"include": [
"../src/**/*.ts"
]
}
17 changes: 17 additions & 0 deletions configs/tsconfig.defaults.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compileOnSave": false,
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"outDir": "dist",
"importHelpers": true,
"strict": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"lib": ["es5", "dom"],
"types": ["node"]
}
}
10 changes: 10 additions & 0 deletions configs/tsconfig.es2015.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.defaults.json",
"compilerOptions": {
"outDir": "../dist/es2015",
"target": "es2015"
},
"include": [
"../src/**/*.ts"
]
}
9 changes: 9 additions & 0 deletions configs/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.defaults.json",
"compilerOptions": {
"outDir": "../dist/esm"
},
"include": [
"../src/**/*.ts"
]
}
13 changes: 13 additions & 0 deletions configs/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "./tsconfig.defaults.json",
"compilerOptions": {
"outDir": "../temp",
"module": "commonjs",
// For `sinon` import in unit tests
"esModuleInterop": true,
"types": ["mocha", "node"]
},
"include": [
"../test/**/*.ts"
]
}
12 changes: 12 additions & 0 deletions configs/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./tsconfig.defaults.json",
"compilerOptions": {
"outDir": "../dist/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": [
"../src/**/*.ts"
]
}
16 changes: 0 additions & 16 deletions gulpfile.babel.js

This file was deleted.

52 changes: 25 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,34 @@
"name": "redux-observable",
"version": "1.2.0",
"description": "RxJS based middleware for Redux. Compose and cancel async actions and more.",
"module": "lib/esm/index.js",
"main": "lib/cjs/index.js",
"module": "./dist/esm/index.js",
"main": "./dist/cjs/index.js",
"es2015": "./dist/es2015/index.js",
"sideEffects": false,
"scripts": {
"lint": "eslint src && eslint test",
"build": "npm run build:esm && npm run build:cjs && npm run build:umd && npm run build:umd:min",
"build:esm": "gulp build:esm",
"build:cjs": "babel src -d lib/cjs",
"build:umd": "cross-env NODE_ENV=development webpack src/index.js -o dist/redux-observable.js",
"build:umd:min": "cross-env NODE_ENV=production webpack src/index.js -o dist/redux-observable.min.js",
"build:tests": "rimraf temp && babel test -d temp",
"clean": "rimraf lib temp dist",
"lint": "eslint --ext .ts src && eslint --ext .ts test",
"build": "npm run build:esm && npm run build:es2015 && npm run build:cjs && npm run build:types && npm run build:umd && npm run build:umd:min",
"build:esm": "tsc -p configs/tsconfig.esm.json",
"build:es2015": "tsc -p configs/tsconfig.es2015.json",
"build:cjs": "tsc -p configs/tsconfig.cjs.json",
"build:types": "tsc -p configs/tsconfig.types.json",
"build:umd": "cross-env NODE_ENV=development webpack -o dist/redux-observable.js",
"build:umd:min": "cross-env NODE_ENV=production webpack -o dist/redux-observable.min.js",
"build:tests": "rimraf temp && tsc -p configs/tsconfig.test.json",
"clean": "rimraf temp dist",
"check": "npm run lint && npm run test",
"test": "npm run lint && npm run build && npm run build:tests && mocha temp && npm run test:typings",
"test:typings": "tsc --strict index.d.ts test/typings.ts --outDir temp --target ES5 --moduleResolution node --lib dom,es2015 && cd temp && node typings.js",
"test": "npm run lint && npm run build && npm run build:tests && mocha temp",
"shipit": "npm run clean && npm run build && npm run lint && npm test && scripts/publish.sh",
"docs:clean": "rimraf _book",
"docs:prepare": "gitbook install",
"docs:build": "npm run docs:prepare && gitbook build -g redux-observable/redux-observable && cp logo/favicon.ico _book/gitbook/images",
"docs:watch": "gitbook serve",
"docs:publish": "npm run docs:clean && npm run docs:build && cp CNAME _book && cd _book && git init && git commit --allow-empty -m 'update book' && git checkout -b gh-pages && touch .nojekyll && git add . && git commit -am 'update book' && git push [email protected]:redux-observable/redux-observable gh-pages --force"
},
"typings": "./index.d.ts",
"typings": "./dist/types/index.d.ts",
"files": [
"dist",
"lib",
"index.d.ts",
"src",
"README.md",
"LICENSE"
],
Expand Down Expand Up @@ -65,40 +66,37 @@
"homepage": "https://github.com/redux-observable/redux-observable#README.md",
"peerDependencies": {
"redux": ">=4 <5",
"rxjs": ">=6.0.0-beta.0 <7"
"rxjs": ">=6.0.0-beta.0 <7",
"tslib": "^1.9.0"
},
"devDependencies": {
"@types/chai": "^3.5.2",
"@types/mocha": "^2.2.48",
"@types/node": "^12.7.12",
"@types/sinon": "^4.3.1",
"babel-cli": "^6.11.4",
"babel-core": "^6.26.0",
"babel-eslint": "^7.0.0",
"babel-loader": "^7.0.0",
"babel-plugin-transform-object-rest-spread": "^6.8.0",
"@typescript-eslint/eslint-plugin": "^2.4.0",
"@typescript-eslint/parser": "^2.4.0",
"babel-polyfill": "^6.13.0",
"babel-preset-env": "^1.6.1",
"babel-register": "^6.11.6",
"chai": "^4.1.2",
"conventional-changelog-cli": "1.3.3",
"cross-env": "^5.0.0",
"eslint": "^4.6.0",
"eslint": "^6.5.1",
"esm": "^3.2.25",
"gitbook-cli": "^2.3.0",
"gitbook-plugin-addcssjs": "^1.0.2",
"gitbook-plugin-anker-enable": "^0.0.4",
"gitbook-plugin-edit-link": "^2.0.2",
"gitbook-plugin-github": "^2.0.0",
"gitbook-plugin-prism": "^2.0.1",
"gitbook-plugin-theme-default": "^1.0.5",
"gulp": "^4.0.1",
"gulp-babel": "^6.1.2",
"json-server": "^0.10.0",
"mocha": "^3.5.3",
"redux": "^4.0.0",
"rimraf": "^2.5.4",
"rxjs": "^6.0.0",
"sinon": "^4.5.0",
"typescript": "^2.1.4",
"ts-loader": "^6.2.0",
"typescript": "^3.6.4",
"webpack": "^4.29.3",
"webpack-cli": "^3.2.3",
"webpack-rxjs-externals": "~2.0.0"
Expand Down
27 changes: 0 additions & 27 deletions src/ActionsObservable.js

This file was deleted.

Loading

0 comments on commit ba4699e

Please sign in to comment.