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

Commit

Permalink
Convert Bit javascript from Flow to TypeScript (#119)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
davidfirst authored Oct 19, 2019
1 parent 8872877 commit 43a0bed
Show file tree
Hide file tree
Showing 69 changed files with 7,235 additions and 10,085 deletions.
42 changes: 0 additions & 42 deletions .babelrc

This file was deleted.

44 changes: 0 additions & 44 deletions .eslintrc

This file was deleted.

76 changes: 76 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json'
},
extends: [
'airbnb-typescript/base',
// 'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@typescript-eslint/recommended',
// 'plugin:eslint-comments/recommended',
'plugin:promise/recommended',
// 'plugin:unicorn/recommended',
// 'plugin:mocha/recommended',
'prettier',
'prettier/@typescript-eslint'
],
plugins: [
'@typescript-eslint',
// 'eslint-comments',
'promise'
// 'mocha',
// 'unicorn'
],
rules: {
'@typescript-eslint/no-use-before-define': [
'error',
{ functions: false, classes: true, variables: true, typedefs: true }
],

// ERRORS OF plugin:@typescript-eslint/recommended
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/no-explicit-any': 'off',
// END ERRORS OF plugin:@typescript-eslint/recommended

// ERRORS OF 'plugin:promise/recommended'
'promise/always-return': 'off',
'promise/no-nesting': 'off',
// END ERRORS OF 'plugin:promise/recommended'

'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
'prefer-object-spread': 'off',
'import/no-duplicates': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'import/no-cycle': 'off',
'import/no-useless-path-segments': 'off',
'lines-between-class-members': 'off',
radix: 'off',
'no-underscore-dangle': 'off',
'no-param-reassign': 'off',
'no-return-assign': [0, 'except-parens'],
'class-methods-use-this': 'off',
'prefer-destructuring': 'off',
'import/no-extraneous-dependencies': 'off',
'no-restricted-syntax': [2, 'ForInStatement', 'LabeledStatement', 'WithStatement'],
'no-unused-expressions': 'off',
'max-len': [
2,
120,
2,
{
ignoreUrls: true,
ignoreComments: true,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true
}
],
'max-lines': [2, 1700],
'func-names': [0]
},
env: {
node: true,
mocha: true
}
};
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"printWidth": 120,
"parser": "flow",
"parser": "typescript",
"singleQuote": true,
"tabWidth": 2,
"useTabs": false,
Expand Down
1 change: 1 addition & 0 deletions babel-register.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require('@babel/register')({ extensions: ['.js', '.jsx', '.ts', '.tsx'] });
40 changes: 40 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module.exports = function (api) {
api.cache(true);

const presets = [
'@babel/typescript',
[
'@babel/preset-env',
{
targets: {
node: 8
}
}
]
];
const plugins = [
[
'@babel/plugin-transform-modules-commonjs',
{
lazy: () => true
}
],
['@babel/plugin-transform-runtime'],
['@babel/plugin-proposal-object-rest-spread'],
['@babel/plugin-proposal-class-properties'],
[
'@babel/plugin-transform-async-to-generator',
{
module: 'bluebird',
method: 'coroutine'
}
]
];

return {
presets,
plugins,
only: ['**/*.ts'],
ignore: ['components/*']
};
};
Loading

0 comments on commit 43a0bed

Please sign in to comment.