Skip to content

Commit ba4699e

Browse files
csvnjayphelps
authored andcommitted
Convert project to Typescript and add es2015 build target (#672)
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.
1 parent 6d17bdc commit ba4699e

34 files changed

+336
-506
lines changed

.babelrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

.eslintrc

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
{
2-
"parser": "babel-eslint",
2+
"parser": "@typescript-eslint/parser",
3+
"plugins": ["@typescript-eslint"],
4+
"extends": [
5+
// Turn off problematic eslint rules
6+
"plugin:@typescript-eslint/eslint-recommended",
7+
// Recommended Typescript-eslint rules
8+
"plugin:@typescript-eslint/recommended",
9+
// Type checking Typescript-eslint rules
10+
"plugin:@typescript-eslint/recommended-requiring-type-checking"
11+
],
312
"rules": {
413
// Enforces getter/setter pairs in objects
514
"accessor-pairs": 0,
@@ -23,8 +32,6 @@
2332
"eqeqeq": 2,
2433
// make sure for-in loops have an if statement
2534
"guard-for-in": 2,
26-
// disabled use of an undefined variable
27-
"no-undef": 2,
2835
// disallow the use of console
2936
"no-console": 0,
3037
// disallow the use of alert, confirm, and prompt
@@ -84,8 +91,6 @@
8491
"no-process-env": 0,
8592
// disallow usage of __proto__ property
8693
"no-proto": 2,
87-
// disallow declaring the same variable more then once
88-
"no-redeclare": 2,
8994
// disallow use of assignment in return statement
9095
"no-return-assign": 2,
9196
// disallow use of `javascript:` urls.
@@ -98,8 +103,6 @@
98103
"no-throw-literal": 2,
99104
// disallow usage of expressions in statement position
100105
"no-unused-expressions": 2,
101-
// disallow unused variables/imports
102-
"no-unused-vars": [2, { "vars": "all", "args": "none" }],
103106
// disallow unnecessary .call() and .apply()
104107
"no-useless-call": 0,
105108
// disallow use of void operator
@@ -238,16 +241,29 @@
238241
// disallow using `var`. Must use `let` or `const`
239242
"no-var": 2,
240243
"no-class-assign": 2,
241-
"no-const-assign": 2,
242-
"no-dupe-class-members": 2,
243-
"no-this-before-super": 2,
244244
"prefer-const": 0,
245245
"prefer-spread": 2,
246246
// require object literal shorthand
247247
"object-shorthand": [2, "always"],
248248
"arrow-spacing": 2,
249249
"prefer-arrow-callback": 2,
250250
"arrow-parens": [0, "as-needed"],
251+
252+
/* Typescript */
253+
// turn off troublesome rules
254+
"@typescript-eslint/explicit-function-return-type": "off",
255+
"@typescript-eslint/no-non-null-assertion": "off",
256+
"@typescript-eslint/no-explicit-any": "off",
257+
"@typescript-eslint/unbound-method": "off",
258+
"@typescript-eslint/ban-ts-ignore": "off",
259+
// disallow unused variables/imports
260+
"@typescript-eslint/no-unused-vars": [2, {
261+
"vars": "all",
262+
"args": "none",
263+
"varsIgnorePattern": "^_"
264+
}],
265+
// TODO: Use this rule instead of eslint's "camelcase"?
266+
"@typescript-eslint/camelcase": "off"
251267
},
252268
"env": {
253269
"browser": true,
@@ -260,6 +276,11 @@
260276
"parserOptions": {
261277
"ecmaFeatures": {
262278
"jsx": true
263-
}
279+
},
280+
"project": [
281+
"./src/tsconfig.json",
282+
"./test/tsconfig.json"
283+
],
284+
"tsconfigRootDir": "."
264285
}
265286
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.vscode
12
npm-debug.log
23
node_modules
34
lib

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ node_js:
33
- "stable"
44
- "lts/*"
55

6+
env:
7+
# Avoids file watcher error "ENOSPC" from using chokidar with linting
8+
- PARSER_NO_WATCH=true
9+
610
script: npm run test
711

812
cache:

configs/tsconfig.cjs.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.defaults.json",
3+
"compilerOptions": {
4+
"outDir": "../dist/cjs",
5+
"module": "commonjs"
6+
},
7+
"include": [
8+
"../src/**/*.ts"
9+
]
10+
}

configs/tsconfig.defaults.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compileOnSave": false,
3+
"compilerOptions": {
4+
"target": "es5",
5+
"module": "es2015",
6+
"moduleResolution": "node",
7+
"outDir": "dist",
8+
"importHelpers": true,
9+
"strict": true,
10+
"noUnusedLocals": false,
11+
"noUnusedParameters": false,
12+
"noImplicitReturns": true,
13+
"noFallthroughCasesInSwitch": true,
14+
"lib": ["es5", "dom"],
15+
"types": ["node"]
16+
}
17+
}

configs/tsconfig.es2015.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.defaults.json",
3+
"compilerOptions": {
4+
"outDir": "../dist/es2015",
5+
"target": "es2015"
6+
},
7+
"include": [
8+
"../src/**/*.ts"
9+
]
10+
}

configs/tsconfig.esm.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.defaults.json",
3+
"compilerOptions": {
4+
"outDir": "../dist/esm"
5+
},
6+
"include": [
7+
"../src/**/*.ts"
8+
]
9+
}

configs/tsconfig.test.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "./tsconfig.defaults.json",
3+
"compilerOptions": {
4+
"outDir": "../temp",
5+
"module": "commonjs",
6+
// For `sinon` import in unit tests
7+
"esModuleInterop": true,
8+
"types": ["mocha", "node"]
9+
},
10+
"include": [
11+
"../test/**/*.ts"
12+
]
13+
}

configs/tsconfig.types.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "./tsconfig.defaults.json",
3+
"compilerOptions": {
4+
"outDir": "../dist/types",
5+
"emitDeclarationOnly": true,
6+
"declaration": true,
7+
"declarationMap": true
8+
},
9+
"include": [
10+
"../src/**/*.ts"
11+
]
12+
}

gulpfile.babel.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

package.json

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,34 @@
22
"name": "redux-observable",
33
"version": "1.2.0",
44
"description": "RxJS based middleware for Redux. Compose and cancel async actions and more.",
5-
"module": "lib/esm/index.js",
6-
"main": "lib/cjs/index.js",
5+
"module": "./dist/esm/index.js",
6+
"main": "./dist/cjs/index.js",
7+
"es2015": "./dist/es2015/index.js",
78
"sideEffects": false,
89
"scripts": {
9-
"lint": "eslint src && eslint test",
10-
"build": "npm run build:esm && npm run build:cjs && npm run build:umd && npm run build:umd:min",
11-
"build:esm": "gulp build:esm",
12-
"build:cjs": "babel src -d lib/cjs",
13-
"build:umd": "cross-env NODE_ENV=development webpack src/index.js -o dist/redux-observable.js",
14-
"build:umd:min": "cross-env NODE_ENV=production webpack src/index.js -o dist/redux-observable.min.js",
15-
"build:tests": "rimraf temp && babel test -d temp",
16-
"clean": "rimraf lib temp dist",
10+
"lint": "eslint --ext .ts src && eslint --ext .ts test",
11+
"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",
12+
"build:esm": "tsc -p configs/tsconfig.esm.json",
13+
"build:es2015": "tsc -p configs/tsconfig.es2015.json",
14+
"build:cjs": "tsc -p configs/tsconfig.cjs.json",
15+
"build:types": "tsc -p configs/tsconfig.types.json",
16+
"build:umd": "cross-env NODE_ENV=development webpack -o dist/redux-observable.js",
17+
"build:umd:min": "cross-env NODE_ENV=production webpack -o dist/redux-observable.min.js",
18+
"build:tests": "rimraf temp && tsc -p configs/tsconfig.test.json",
19+
"clean": "rimraf temp dist",
1720
"check": "npm run lint && npm run test",
18-
"test": "npm run lint && npm run build && npm run build:tests && mocha temp && npm run test:typings",
19-
"test:typings": "tsc --strict index.d.ts test/typings.ts --outDir temp --target ES5 --moduleResolution node --lib dom,es2015 && cd temp && node typings.js",
21+
"test": "npm run lint && npm run build && npm run build:tests && mocha temp",
2022
"shipit": "npm run clean && npm run build && npm run lint && npm test && scripts/publish.sh",
2123
"docs:clean": "rimraf _book",
2224
"docs:prepare": "gitbook install",
2325
"docs:build": "npm run docs:prepare && gitbook build -g redux-observable/redux-observable && cp logo/favicon.ico _book/gitbook/images",
2426
"docs:watch": "gitbook serve",
2527
"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 git@github.com:redux-observable/redux-observable gh-pages --force"
2628
},
27-
"typings": "./index.d.ts",
29+
"typings": "./dist/types/index.d.ts",
2830
"files": [
2931
"dist",
30-
"lib",
31-
"index.d.ts",
32+
"src",
3233
"README.md",
3334
"LICENSE"
3435
],
@@ -65,40 +66,37 @@
6566
"homepage": "https://github.com/redux-observable/redux-observable#README.md",
6667
"peerDependencies": {
6768
"redux": ">=4 <5",
68-
"rxjs": ">=6.0.0-beta.0 <7"
69+
"rxjs": ">=6.0.0-beta.0 <7",
70+
"tslib": "^1.9.0"
6971
},
7072
"devDependencies": {
7173
"@types/chai": "^3.5.2",
7274
"@types/mocha": "^2.2.48",
75+
"@types/node": "^12.7.12",
7376
"@types/sinon": "^4.3.1",
74-
"babel-cli": "^6.11.4",
75-
"babel-core": "^6.26.0",
76-
"babel-eslint": "^7.0.0",
77-
"babel-loader": "^7.0.0",
78-
"babel-plugin-transform-object-rest-spread": "^6.8.0",
77+
"@typescript-eslint/eslint-plugin": "^2.4.0",
78+
"@typescript-eslint/parser": "^2.4.0",
7979
"babel-polyfill": "^6.13.0",
80-
"babel-preset-env": "^1.6.1",
81-
"babel-register": "^6.11.6",
8280
"chai": "^4.1.2",
8381
"conventional-changelog-cli": "1.3.3",
8482
"cross-env": "^5.0.0",
85-
"eslint": "^4.6.0",
83+
"eslint": "^6.5.1",
84+
"esm": "^3.2.25",
8685
"gitbook-cli": "^2.3.0",
8786
"gitbook-plugin-addcssjs": "^1.0.2",
8887
"gitbook-plugin-anker-enable": "^0.0.4",
8988
"gitbook-plugin-edit-link": "^2.0.2",
9089
"gitbook-plugin-github": "^2.0.0",
9190
"gitbook-plugin-prism": "^2.0.1",
9291
"gitbook-plugin-theme-default": "^1.0.5",
93-
"gulp": "^4.0.1",
94-
"gulp-babel": "^6.1.2",
9592
"json-server": "^0.10.0",
9693
"mocha": "^3.5.3",
9794
"redux": "^4.0.0",
9895
"rimraf": "^2.5.4",
9996
"rxjs": "^6.0.0",
10097
"sinon": "^4.5.0",
101-
"typescript": "^2.1.4",
98+
"ts-loader": "^6.2.0",
99+
"typescript": "^3.6.4",
102100
"webpack": "^4.29.3",
103101
"webpack-cli": "^3.2.3",
104102
"webpack-rxjs-externals": "~2.0.0"

src/ActionsObservable.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)