Skip to content

Migrate to TypeScript #340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .babelrc-npm.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"plugins": ["@babel/plugin-transform-typescript"],
"presets": [
[
"@babel/preset-env",
Expand Down
2 changes: 1 addition & 1 deletion .babelrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"plugins": ["@babel/plugin-transform-typescript"],
"presets": [
[
"@babel/preset-env",
Expand Down
3 changes: 0 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@
node_modules
coverage
npmDist

# Ignore Flow typings for 3rd-party libraries
/flow-typed
67 changes: 6 additions & 61 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -428,61 +428,6 @@ rules:
yield-star-spacing: off

overrides:
- files: 'src/**/*.js'
parser: '@babel/eslint-parser'
parserOptions:
sourceType: module
plugins:
- flowtype

rules:
##############################################################################
# `eslint-plugin-flowtype` rule list based on `v5.3.x`
# https://github.com/gajus/eslint-plugin-flowtype#eslint-plugin-flowtype
##############################################################################

flowtype/array-style-complex-type: error
flowtype/array-style-simple-type: error
flowtype/define-flow-type: error
flowtype/newline-after-flow-annotation: error
flowtype/no-dupe-keys: error
flowtype/no-existential-type: off # checked by Flow
flowtype/no-flow-fix-me-comments: off
flowtype/no-mixed: off
flowtype/no-mutable-array: off
flowtype/no-primitive-constructor-types: error
flowtype/no-types-missing-file-annotation: off
flowtype/no-unused-expressions: off
flowtype/no-weak-types: [error, { any: false }]
flowtype/require-compound-type-alias: off
flowtype/require-exact-type: [error, never]
flowtype/require-indexer-name: error
flowtype/require-inexact-type: off # checked by Flow
flowtype/require-parameter-type: off
flowtype/require-readonly-react-props: off
flowtype/require-return-type: off
flowtype/require-types-at-top: off
flowtype/require-valid-file-annotation: off
flowtype/require-variable-type: off
flowtype/sort-keys: off
flowtype/spread-exact-type: off
flowtype/type-id-match: [error, '^[A-Z]']
flowtype/type-import-style: [error, declaration]
flowtype/use-flow-type: error

# Bellow rules are disabled because coflicts with Prettier, see:
# https://github.com/prettier/eslint-config-prettier/blob/master/flowtype.js
flowtype/arrow-parens: off
flowtype/boolean-style: off
flowtype/delimiter-dangle: off
flowtype/generic-spacing: off
flowtype/object-type-curly-spacing: off
flowtype/object-type-delimiter: off
flowtype/semi: off
flowtype/space-after-type-colon: off
flowtype/space-before-generic-bracket: off
flowtype/space-before-type-colon: off
flowtype/union-intersection-spacing: off
- files: '**/*.ts'
parser: '@typescript-eslint/parser'
parserOptions:
Expand All @@ -505,11 +450,11 @@ overrides:
'@typescript-eslint/ban-ts-comment': [error, { 'ts-expect-error': false }]
'@typescript-eslint/ban-tslint-comment': error
'@typescript-eslint/ban-types': error
'@typescript-eslint/class-literal-property-style': off # TODO enable after TS conversion
'@typescript-eslint/class-literal-property-style': error
'@typescript-eslint/consistent-indexed-object-style': off # TODO enable after TS conversion
'@typescript-eslint/consistent-type-assertions':
[error, { assertionStyle: as, objectLiteralTypeAssertions: never }]
'@typescript-eslint/consistent-type-definitions': off # TODO consider
'@typescript-eslint/consistent-type-definitions': error
'@typescript-eslint/consistent-type-imports': off # TODO enable after TS conversion
'@typescript-eslint/explicit-function-return-type': off # TODO consider
'@typescript-eslint/explicit-member-accessibility': off # TODO consider
Expand All @@ -527,7 +472,7 @@ overrides:
'@typescript-eslint/no-extraneous-class': off # TODO consider
'@typescript-eslint/no-floating-promises': error
'@typescript-eslint/no-for-in-array': error
'@typescript-eslint/no-implicit-any-catch': off # TODO: Enable after TS convertion
'@typescript-eslint/no-implicit-any-catch': error
'@typescript-eslint/no-implied-eval': error
'@typescript-eslint/no-inferrable-types':
[error, { ignoreParameters: true, ignoreProperties: true }]
Expand All @@ -542,7 +487,7 @@ overrides:
'@typescript-eslint/no-this-alias': error
'@typescript-eslint/no-type-alias': off # TODO consider
'@typescript-eslint/no-unnecessary-boolean-literal-compare': error
'@typescript-eslint/no-unnecessary-condition': error
'@typescript-eslint/no-unnecessary-condition': off # TODO temporarily disabled
'@typescript-eslint/no-unnecessary-qualifier': error
'@typescript-eslint/no-unnecessary-type-arguments': error
'@typescript-eslint/no-unnecessary-type-assertion': error
Expand All @@ -555,7 +500,7 @@ overrides:
'@typescript-eslint/non-nullable-type-assertion-style': error
'@typescript-eslint/prefer-as-const': off # TODO consider
'@typescript-eslint/prefer-enum-initializers': off # TODO consider
'@typescript-eslint/prefer-for-of': off # TODO switch to error after TS migration
'@typescript-eslint/prefer-for-of': error
'@typescript-eslint/prefer-function-type': error
'@typescript-eslint/prefer-includes': off # TODO switch to error after IE11 drop
'@typescript-eslint/prefer-literal-enum-member': error
Expand Down Expand Up @@ -630,7 +575,7 @@ overrides:
'@typescript-eslint/require-await': error
'@typescript-eslint/return-await': error

# Disable for JS, Flow and TS
# Disable for JS and TS
'@typescript-eslint/init-declarations': off
'@typescript-eslint/no-magic-numbers': off
'@typescript-eslint/no-use-before-define': off
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Lint ESLint
run: npm run lint

- name: Lint Flow
- name: Check TypeScript
run: npm run check

- name: Lint Prettier
Expand Down
2 changes: 1 addition & 1 deletion .mocharc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
throw-deprecation: true
check-leaks: true
require:
- '@babel/register'
- 'resources/ts-register.js'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ After cloning this repo, ensure dependencies are installed by running:
npm install
```

This library is written in ES6 and uses [Babel](https://babeljs.io/) for ES5 transpilation and [Flow](https://flow.org/) for type safety. Widely consumable JavaScript can be produced by running:
This library is written in ES6 and uses [Babel](https://babeljs.io/) for ES5 transpilation and [TypeScript](https://www.typescriptlang.org/) for type safety. Widely consumable JavaScript can be produced by running:

```sh
npm run build
Expand Down
1 change: 0 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"npmDist",

// Excluded from spelling check
"flow-typed",
"cspell.json",
"package.json",
"package-lock.json",
Expand Down
Loading