Skip to content
This repository was archived by the owner on Dec 4, 2022. It is now read-only.

Commit 43a0bed

Browse files
authored
Convert Bit javascript from Flow to TypeScript (#119)
* rename all files from .js to .ts * configure babel to compile typescript * fix all typescript syntax errors * reconfigure eslint to work with typescript * fix many lint errors * automatically add @ts-ignore for all tsc errors * add lint and check_types scripts for the bit-bin CI to run
1 parent 8872877 commit 43a0bed

Some content is hidden

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

69 files changed

+7235
-10085
lines changed

.babelrc

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

.eslintrc

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

.eslintrc.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
parserOptions: {
4+
project: './tsconfig.json'
5+
},
6+
extends: [
7+
'airbnb-typescript/base',
8+
// 'plugin:@typescript-eslint/recommended-requiring-type-checking',
9+
'plugin:@typescript-eslint/recommended',
10+
// 'plugin:eslint-comments/recommended',
11+
'plugin:promise/recommended',
12+
// 'plugin:unicorn/recommended',
13+
// 'plugin:mocha/recommended',
14+
'prettier',
15+
'prettier/@typescript-eslint'
16+
],
17+
plugins: [
18+
'@typescript-eslint',
19+
// 'eslint-comments',
20+
'promise'
21+
// 'mocha',
22+
// 'unicorn'
23+
],
24+
rules: {
25+
'@typescript-eslint/no-use-before-define': [
26+
'error',
27+
{ functions: false, classes: true, variables: true, typedefs: true }
28+
],
29+
30+
// ERRORS OF plugin:@typescript-eslint/recommended
31+
'@typescript-eslint/no-var-requires': 'off',
32+
'@typescript-eslint/ban-ts-ignore': 'off',
33+
'@typescript-eslint/no-explicit-any': 'off',
34+
// END ERRORS OF plugin:@typescript-eslint/recommended
35+
36+
// ERRORS OF 'plugin:promise/recommended'
37+
'promise/always-return': 'off',
38+
'promise/no-nesting': 'off',
39+
// END ERRORS OF 'plugin:promise/recommended'
40+
41+
'import/export': 'off', // typescript does allow multiple export default when overloading. not sure why it's enabled here. rule source: https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md
42+
'prefer-object-spread': 'off',
43+
'import/no-duplicates': 'off',
44+
'@typescript-eslint/explicit-function-return-type': 'off',
45+
'import/no-cycle': 'off',
46+
'import/no-useless-path-segments': 'off',
47+
'lines-between-class-members': 'off',
48+
radix: 'off',
49+
'no-underscore-dangle': 'off',
50+
'no-param-reassign': 'off',
51+
'no-return-assign': [0, 'except-parens'],
52+
'class-methods-use-this': 'off',
53+
'prefer-destructuring': 'off',
54+
'import/no-extraneous-dependencies': 'off',
55+
'no-restricted-syntax': [2, 'ForInStatement', 'LabeledStatement', 'WithStatement'],
56+
'no-unused-expressions': 'off',
57+
'max-len': [
58+
2,
59+
120,
60+
2,
61+
{
62+
ignoreUrls: true,
63+
ignoreComments: true,
64+
ignoreRegExpLiterals: true,
65+
ignoreStrings: true,
66+
ignoreTemplateLiterals: true
67+
}
68+
],
69+
'max-lines': [2, 1700],
70+
'func-names': [0]
71+
},
72+
env: {
73+
node: true,
74+
mocha: true
75+
}
76+
};

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"printWidth": 120,
3-
"parser": "flow",
3+
"parser": "typescript",
44
"singleQuote": true,
55
"tabWidth": 2,
66
"useTabs": false,

babel-register.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('@babel/register')({ extensions: ['.js', '.jsx', '.ts', '.tsx'] });

babel.config.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
module.exports = function (api) {
2+
api.cache(true);
3+
4+
const presets = [
5+
'@babel/typescript',
6+
[
7+
'@babel/preset-env',
8+
{
9+
targets: {
10+
node: 8
11+
}
12+
}
13+
]
14+
];
15+
const plugins = [
16+
[
17+
'@babel/plugin-transform-modules-commonjs',
18+
{
19+
lazy: () => true
20+
}
21+
],
22+
['@babel/plugin-transform-runtime'],
23+
['@babel/plugin-proposal-object-rest-spread'],
24+
['@babel/plugin-proposal-class-properties'],
25+
[
26+
'@babel/plugin-transform-async-to-generator',
27+
{
28+
module: 'bluebird',
29+
method: 'coroutine'
30+
}
31+
]
32+
];
33+
34+
return {
35+
presets,
36+
plugins,
37+
only: ['**/*.ts'],
38+
ignore: ['components/*']
39+
};
40+
};

0 commit comments

Comments
 (0)