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+
}

0 commit comments

Comments
 (0)