Skip to content

Commit a03bf1c

Browse files
authored
Convert code base to Typescript (#116)
* initial ts conversion * clean up * update rule to use auto LF * fix lint errors * remove tracking index.d.ts * clean up * clean up * enforce eol to lf
1 parent 17484bb commit a03bf1c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1722
-5173
lines changed

.eslintrc.js

Lines changed: 37 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,58 @@
11
module.exports = {
2+
root: true,
23
env: {
34
es6: true,
45
node: true,
56
browser: true,
6-
jest: true,
77
},
88
globals: {
99
Atomics: 'readonly',
1010
SharedArrayBuffer: 'readonly',
1111
},
12-
settings: {
13-
'import/parsers': {
14-
'@babel/eslint-parser': ['.js'],
15-
'@typescript-eslint/parser': ['.ts'],
16-
},
17-
'import/resolver': {
18-
node: true,
19-
'eslint-import-resolver-typescript': true,
20-
},
21-
},
22-
parser: '@babel/eslint-parser',
23-
parserOptions: {
24-
sourceType: 'module',
25-
babelOptions: {
26-
// configuration for @babel/eslint-parser
27-
configFile: './babel.config.js',
28-
},
29-
// configuration for @typescript-eslint
30-
project: 'tsconfig.json',
12+
parser: '@typescript-eslint/parser',
13+
plugins: ['@typescript-eslint', 'prettier'],
14+
extends: [
15+
'eslint:recommended',
16+
'plugin:@typescript-eslint/eslint-recommended',
17+
'plugin:@typescript-eslint/recommended',
18+
'prettier',
19+
'plugin:prettier/recommended',
20+
],
21+
rules: {
22+
'prettier/prettier': 'error',
23+
// too many tests to fix, disable for now
24+
'@typescript-eslint/ban-types': 'off',
25+
// customize argument ignore pattern
26+
'no-unused-vars': 'off',
27+
'@typescript-eslint/no-unused-vars': ['error', {argsIgnorePattern: '^_'}],
3128
},
3229
overrides: [
33-
// linting setup for JS files.
3430
{
35-
files: '**/*.js',
36-
parser: '@babel/eslint-parser',
37-
plugins: ['@babel', 'flowtype', 'prettier', 'import'],
38-
extends: ['airbnb-base', 'plugin:flowtype/recommended', 'prettier', 'plugin:prettier/recommended'],
31+
files: ['**/__tests__/**/*.ts', '**/*.test.ts', '**/*.spec.ts'],
32+
env: {
33+
jest: true,
34+
'jest/globals': true,
35+
},
36+
plugins: ['jest'],
37+
extends: ['plugin:jest/recommended'],
3938
rules: {
40-
'prettier/prettier': ['error', {endOfLine: 'auto'}],
41-
'no-underscore-dangle': 'off',
42-
camelcase: 'off',
43-
'no-param-reassign': ['error', {props: false}],
44-
'import/extensions': [0, 'never', {ts: 'never'}],
45-
'import/named': 'off',
46-
'import/namespace': 'off',
47-
'import/default': 'off',
48-
'import/no-named-as-default-member': 'off',
49-
'import/no-named-as-default': 'off',
50-
'max-classes-per-file': 'off',
51-
'prefer-object-spread': 'off',
39+
// Test-specific rules
40+
'no-empty-function': 'off',
41+
'no-unused-expressions': 'off',
42+
// jest specific
43+
'jest/no-conditional-expect': 'off',
44+
// Any other rule adjustments for test files
45+
'@typescript-eslint/no-empty-function': 'off',
46+
'@typescript-eslint/no-explicit-any': 'off',
47+
'@typescript-eslint/no-unsafe-call': 'off',
48+
'@typescript-eslint/no-unsafe-member-access': 'off',
49+
'@typescript-eslint/no-unsafe-assignment': 'off',
5250
},
5351
},
54-
// linting setup for TS files.
5552
{
56-
files: '**/*.ts',
57-
plugins: ['@babel', 'prettier', 'import', '@typescript-eslint'],
58-
extends: [
59-
'airbnb-typescript/base',
60-
'plugin:@typescript-eslint/eslint-recommended',
61-
'plugin:@typescript-eslint/recommended',
62-
'plugin:@typescript-eslint/recommended-requiring-type-checking',
63-
'prettier',
64-
'plugin:prettier/recommended',
65-
],
53+
files: ['src/**/*.ts'],
6654
rules: {
67-
'prettier/prettier': ['error', {endOfLine: 'auto'}],
68-
'no-underscore-dangle': 'off',
69-
camelcase: 'off',
70-
'no-param-reassign': ['error', {props: false}],
71-
'import/extensions': [0, 'never', {ts: 'never'}],
72-
'import/named': 'off',
73-
'import/namespace': 'off',
74-
'import/default': 'off',
75-
'import/no-named-as-default-member': 'off',
76-
'import/no-named-as-default': 'off',
77-
'max-classes-per-file': 'off',
78-
// TS specific
79-
'@typescript-eslint/explicit-function-return-type': 'off',
80-
'@typescript-eslint/prefer-regexp-exec': 'off',
81-
'@typescript-eslint/array-type': [
82-
'error',
83-
{
84-
default: 'array',
85-
readonly: 'array',
86-
},
87-
],
55+
// Source file specific rules
8856
},
8957
},
9058
],

.flowconfig

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

.gitattributes

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
* text=auto
1+
# all text files will be checked in with LF as eol
2+
* text=auto eol=lf
23

3-
*.example text eol=lf
4-
*.js text eol=lf

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ node_modules/
22
build/
33
coverage/
44
*.tgz
5-
.eslintcache
5+
.eslintcache
6+
index.d.ts

.husky/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.husky/pre-commit

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

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ fixtures
1010
babel.config.js
1111
prettier.config.js
1212
tsconfig.json
13+
tsconfig.*.json
1314
dangerfile.js
1415
yarn.lock
1516
*.tgz

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"typescript.validate.enable": true,
33
"javascript.validate.enable": false,
44
"editor.codeActionsOnSave": {
5-
"source.fixAll.eslint": true
5+
"source.fixAll.eslint": "explicit"
66
}
77
}

babel.config.js

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

0 commit comments

Comments
 (0)