Skip to content

Commit

Permalink
Convert code base to Typescript (#116)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
connectdotz committed Apr 20, 2024
1 parent 17484bb commit a03bf1c
Show file tree
Hide file tree
Showing 42 changed files with 1,722 additions and 5,173 deletions.
106 changes: 37 additions & 69 deletions .eslintrc.js
@@ -1,90 +1,58 @@
module.exports = {
root: true,
env: {
es6: true,
node: true,
browser: true,
jest: true,
},
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
settings: {
'import/parsers': {
'@babel/eslint-parser': ['.js'],
'@typescript-eslint/parser': ['.ts'],
},
'import/resolver': {
node: true,
'eslint-import-resolver-typescript': true,
},
},
parser: '@babel/eslint-parser',
parserOptions: {
sourceType: 'module',
babelOptions: {
// configuration for @babel/eslint-parser
configFile: './babel.config.js',
},
// configuration for @typescript-eslint
project: 'tsconfig.json',
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'prettier'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'plugin:prettier/recommended',
],
rules: {
'prettier/prettier': 'error',
// too many tests to fix, disable for now
'@typescript-eslint/ban-types': 'off',
// customize argument ignore pattern
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['error', {argsIgnorePattern: '^_'}],
},
overrides: [
// linting setup for JS files.
{
files: '**/*.js',
parser: '@babel/eslint-parser',
plugins: ['@babel', 'flowtype', 'prettier', 'import'],
extends: ['airbnb-base', 'plugin:flowtype/recommended', 'prettier', 'plugin:prettier/recommended'],
files: ['**/__tests__/**/*.ts', '**/*.test.ts', '**/*.spec.ts'],
env: {
jest: true,
'jest/globals': true,
},
plugins: ['jest'],
extends: ['plugin:jest/recommended'],
rules: {
'prettier/prettier': ['error', {endOfLine: 'auto'}],
'no-underscore-dangle': 'off',
camelcase: 'off',
'no-param-reassign': ['error', {props: false}],
'import/extensions': [0, 'never', {ts: 'never'}],
'import/named': 'off',
'import/namespace': 'off',
'import/default': 'off',
'import/no-named-as-default-member': 'off',
'import/no-named-as-default': 'off',
'max-classes-per-file': 'off',
'prefer-object-spread': 'off',
// Test-specific rules
'no-empty-function': 'off',
'no-unused-expressions': 'off',
// jest specific
'jest/no-conditional-expect': 'off',
// Any other rule adjustments for test files
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
},
},
// linting setup for TS files.
{
files: '**/*.ts',
plugins: ['@babel', 'prettier', 'import', '@typescript-eslint'],
extends: [
'airbnb-typescript/base',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier',
'plugin:prettier/recommended',
],
files: ['src/**/*.ts'],
rules: {
'prettier/prettier': ['error', {endOfLine: 'auto'}],
'no-underscore-dangle': 'off',
camelcase: 'off',
'no-param-reassign': ['error', {props: false}],
'import/extensions': [0, 'never', {ts: 'never'}],
'import/named': 'off',
'import/namespace': 'off',
'import/default': 'off',
'import/no-named-as-default-member': 'off',
'import/no-named-as-default': 'off',
'max-classes-per-file': 'off',
// TS specific
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/prefer-regexp-exec': 'off',
'@typescript-eslint/array-type': [
'error',
{
default: 'array',
readonly: 'array',
},
],
// Source file specific rules
},
},
],
Expand Down
22 changes: 0 additions & 22 deletions .flowconfig

This file was deleted.

5 changes: 2 additions & 3 deletions .gitattributes
@@ -1,4 +1,3 @@
* text=auto
# all text files will be checked in with LF as eol
* text=auto eol=lf

*.example text eol=lf
*.js text eol=lf
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -2,4 +2,5 @@ node_modules/
build/
coverage/
*.tgz
.eslintcache
.eslintcache
index.d.ts
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

1 change: 1 addition & 0 deletions .npmignore
Expand Up @@ -10,6 +10,7 @@ fixtures
babel.config.js
prettier.config.js
tsconfig.json
tsconfig.*.json
dangerfile.js
yarn.lock
*.tgz
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Expand Up @@ -2,6 +2,6 @@
"typescript.validate.enable": true,
"javascript.validate.enable": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
}
}
7 changes: 0 additions & 7 deletions babel.config.js

This file was deleted.

0 comments on commit a03bf1c

Please sign in to comment.