Skip to content

Commit 453b7dd

Browse files
authored
feat(typescript): Source code rewrite using typescript (react-native-webview#425)
Rewrote the whole repository into typescript. This will provide way better and up to date documentation. This should also add some safety for people contributing 😄 . Flow types were not working until now which is why this PR doesn't have them but feel free to PR. This also fixes react-native-webview#384 react-native-webview#435 react-native-webview#206 react-native-webview#171 react-native-webview#168.
1 parent e697dff commit 453b7dd

24 files changed

+2799
-2187
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535

3636
- run:
3737
name: Run Tests
38-
command: yarn ci:test
38+
command: yarn ci
3939

4040
publish:
4141
<<: *defaults

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lib/

.eslintrc.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
module.exports = {
2+
// Airbnb is the base, prettier is here so that eslint doesn't conflict with prettier
3+
extends: ['airbnb', 'prettier', 'prettier/react'],
4+
parser: '@typescript-eslint/parser',
5+
plugins: ['react', 'react-native', 'import', '@typescript-eslint'],
6+
rules: {
7+
'no-console': 'off',
8+
// Lines will be broken before binary operators
9+
'operator-linebreak': ['error', 'before'],
10+
// Allow imports from dev and peer dependencies
11+
'import/no-extraneous-dependencies': [
12+
'error',
13+
{ devDependencies: true, peerDependencies: true },
14+
],
15+
'react/jsx-filename-extension': ['error', { extensions: ['.tsx'] }],
16+
// This rule doesn't play nice with Prettier
17+
'react/jsx-one-expression-per-line': 'off',
18+
// This rule doesn't play nice with Prettier
19+
'react/jsx-wrap-multilines': 'off',
20+
// Remove this rule because we only destructure props, but never state
21+
'react/destructuring-assignment': 'off',
22+
'react/prop-types': 'off',
23+
'@typescript-eslint/adjacent-overload-signatures': 'error',
24+
'@typescript-eslint/array-type': ['error', 'array'],
25+
'@typescript-eslint/generic-type-naming': ['error', '^[a-zA-Z]+$'],
26+
'@typescript-eslint/no-angle-bracket-type-assertion': 'error',
27+
'@typescript-eslint/no-array-constructor': 'error',
28+
'@typescript-eslint/no-empty-interface': 'error',
29+
'@typescript-eslint/no-explicit-any': 'error',
30+
'@typescript-eslint/no-extraneous-class': 'error',
31+
'@typescript-eslint/no-inferrable-types': 'error',
32+
'@typescript-eslint/no-misused-new': 'error',
33+
'@typescript-eslint/no-namespace': 'error',
34+
'@typescript-eslint/no-non-null-assertion': 'error',
35+
'@typescript-eslint/no-object-literal-type-assertion': 'error',
36+
'@typescript-eslint/no-parameter-properties': 'error',
37+
'@typescript-eslint/no-this-alias': 'error',
38+
'@typescript-eslint/no-triple-slash-reference': 'error',
39+
'@typescript-eslint/no-type-alias': [
40+
'error',
41+
{
42+
allowAliases: 'always',
43+
allowCallbacks: 'always',
44+
allowMappedTypes: 'always',
45+
},
46+
],
47+
'@typescript-eslint/no-unused-vars': [
48+
'error',
49+
{ ignoreRestSiblings: true },
50+
],
51+
'@typescript-eslint/prefer-interface': 'error',
52+
'@typescript-eslint/prefer-namespace-keyword': 'error',
53+
'@typescript-eslint/type-annotation-spacing': 'error',
54+
},
55+
settings: {
56+
'import/resolver': {
57+
node: {
58+
extensions: [
59+
'.js',
60+
'.android.js',
61+
'.ios.js',
62+
'.jsx',
63+
'.android.jsx',
64+
'.ios.jsx',
65+
'.tsx',
66+
'.ts',
67+
'.android.tsx',
68+
'.android.ts',
69+
'.ios.tsx',
70+
'.ios.ts',
71+
],
72+
},
73+
},
74+
},
75+
};

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,6 @@ bundles/
5151

5252
android/gradle
5353
android/gradlew
54-
android/gradlew.bat
54+
android/gradlew.bat
55+
56+
lib/

.prettierrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// https://prettier.io/docs/en/options.html
2+
3+
module.exports = {
4+
// Enables semicolons at the end of statements
5+
semi: true,
6+
// Formats strings with single quotes ('') instead of quotes ("")
7+
singleQuote: true,
8+
// Adds a trailing comma at the end of all lists (including function arguments)
9+
trailingComma: 'all',
10+
};

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"typescript.tsdk": "node_modules/typescript/lib",
3+
"eslint.validate": [
4+
"javascript",
5+
"javascriptreact",
6+
"typescript",
7+
"typescriptreact"
8+
]
9+
}

0 commit comments

Comments
 (0)