Skip to content

Commit d3776a7

Browse files
authored
feat: Update typescript code for library (#1)
1 parent f7170a6 commit d3776a7

56 files changed

Lines changed: 8839 additions & 6749 deletions

Some content is hidden

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

.eslintrc.js

Lines changed: 56 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,60 @@
11
module.exports = {
2-
env: {
3-
es6: true,
4-
node: true,
5-
jest: true,
6-
},
7-
extends: [
8-
'plugin:@typescript-eslint/recommended',
9-
'prettier',
10-
'plugin:prettier/recommended',
11-
'prettier/react',
12-
'prettier/@typescript-eslint',
13-
],
14-
15-
parser: '@typescript-eslint/parser',
16-
parserOptions: {
17-
createDefaultProgram: true,
18-
ecmaFeatures: {
19-
jsx: true,
20-
impliedStrict: true,
21-
},
22-
ecmaVersion: 2018,
23-
sourceType: 'module',
24-
project: './tsconfig.json',
25-
},
26-
// plugins: ['react', 'react-native'],
27-
28-
plugins: ['react', 'react-hooks', 'react-native', 'prettier'],
29-
2+
root: true,
3+
extends: '@react-native-community',
4+
plugins: ['react-hooks'],
305
rules: {
31-
indent: ['error', 2, { SwitchCase: 1 }],
32-
quotes: ['error', 'single', { avoidEscape: true }],
33-
'@typescript-eslint/no-var-requires': 0,
34-
'react-native/no-unused-styles': 2,
35-
'react-native/split-platform-components': 2,
36-
'react-native/no-inline-styles': 2,
37-
'react-native/no-color-literals': 2,
38-
'react-native/no-single-element-style-arrays': 2,
39-
'global-require': 0,
40-
'linebreak-style': [2, 'unix'],
41-
'prefer-const': 0,
42-
'no-console': [
43-
'warn',
6+
semi: ['error', 'never'],
7+
quotes: ['error', 'single'],
8+
radix: 0,
9+
'max-len': [
10+
'error',
4411
{
45-
allow: ['warn', 'error', 'log', 'info', 'disableYellowBox'],
46-
},
12+
code: 120,
13+
tabWidth: 2,
14+
comments: 100,
15+
ignoreUrls: true,
16+
ignoreRegExpLiterals: true,
17+
ignorePattern: '^import\\W.*'
18+
}
4719
],
48-
'no-param-reassign': 0,
49-
'@typescript-eslint/explicit-module-boundary-types': 'off',
50-
'no-restricted-globals': 0,
51-
'no-unused-vars': 0,
52-
'no-use-before-define': 0,
53-
'no-underscore-dangle': 0,
54-
'no-useless-constructor': 0,
55-
'no-unused-expressions': 0,
56-
'no-plusplus': 0,
57-
'no-nested-ternary': 0,
58-
'lines-between-class-members': [
59-
1,
60-
'always',
61-
{
62-
exceptAfterSingleLine: true,
63-
},
64-
],
65-
'prefer-destructuring': [
66-
2,
67-
{
68-
array: false,
69-
object: true,
70-
},
71-
],
72-
'max-classes-per-file': 0,
73-
'import/prefer-default-export': 0,
74-
'react/prefer-stateless-function': 0,
75-
'react/destructuring-assignment': 0,
76-
'react/prop-types': 0,
77-
'react/react-in-jsx-scope': 0,
78-
'react/jsx-props-no-spreading': 0,
79-
'react/jsx-filename-extension': [
80-
2,
81-
{
82-
extensions: ['.jsx', '.tsx'],
83-
},
84-
],
85-
'jsx-a11y/accessible-emoji': 0,
86-
'react/static-property-placement': 0,
87-
'@typescript-eslint/explicit-member-accessibility': [2, { accessibility: 'no-public' }],
88-
'@typescript-eslint/no-empty-interface': 1,
89-
'@typescript-eslint/explicit-function-return-type': [
90-
0,
91-
{
92-
allowExpressions: true,
93-
allowTypedFunctionExpressions: true,
94-
},
95-
],
96-
'@typescript-eslint/no-explicit-any': 0,
97-
'@typescript-eslint/no-use-before-define': [
98-
2,
99-
{
100-
functions: true,
101-
classes: true,
102-
variables: false,
103-
},
104-
],
105-
'@typescript-eslint/no-unused-vars': [1, { args: 'none' }],
106-
'@typescript-eslint/no-non-null-assertion': 0,
107-
'@typescript-eslint/camelcase': 0,
108-
'@typescript-eslint/ban-ts-ignore': 0,
109-
'@typescript-eslint/no-empty-function': 'off',
110-
},
111-
settings: {
112-
react: {
113-
version: 'detect',
114-
},
115-
},
116-
};
20+
curly: 'error',
21+
'arrow-parens': ['error', 'always'],
22+
'arrow-spacing': 'error',
23+
'comma-dangle': ['error', 'never'],
24+
'react/self-closing-comp': ['error'],
25+
'no-mixed-spaces-and-tabs': 0,
26+
'no-shadow': 0,
27+
'no-unused-vars': ['error', { vars: 'local', args: 'after-used' }],
28+
'no-duplicate-imports': 'error',
29+
'no-var': 'error',
30+
'no-const-assign': 'error',
31+
'no-dupe-args': 'error',
32+
'no-dupe-keys': 'error',
33+
'no-duplicate-case': 'error',
34+
'no-empty': 'error',
35+
'no-sparse-arrays': 'error',
36+
'no-multi-spaces': 'error',
37+
'no-useless-escape': 'error',
38+
'no-extra-boolean-cast': 'error',
39+
'no-alert': 'error',
40+
'block-scoped-var': 'error',
41+
'dot-notation': 0,
42+
'array-bracket-spacing': ['error', 'never'],
43+
'prefer-arrow-callback': 'error',
44+
'template-curly-spacing': 'error',
45+
'default-case': 'error',
46+
'block-spacing': 'error',
47+
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
48+
'comma-style': 'error',
49+
'computed-property-spacing': 'error',
50+
'eol-last': 'error',
51+
'func-call-spacing': ['error', 'never'],
52+
'func-style': ['off', 'expression', { allowArrowFunctions: true }],
53+
'key-spacing': ['error', { beforeColon: false }],
54+
'keyword-spacing': ['error', { before: true }],
55+
'jsx-quotes': ['error', 'prefer-single'],
56+
'react-hooks/rules-of-hooks': 'error',
57+
'react-hooks/exhaustive-deps': 'warn',
58+
'react-native/no-inline-styles': 'error'
59+
}
60+
}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,5 @@ buck-out/
5757

5858
# CocoaPods
5959
/ios/Pods/
60+
61+
.vscode

.prettierrc.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
module.exports = {
2-
jsxBracketSameLine: true,
2+
semi: false,
3+
tabWidth: 2,
34
singleQuote: true,
4-
trailingComma: 'all',
5-
printWidth: 100,
6-
};
5+
bracketSpacing: true,
6+
arrowParens: 'always',
7+
jsxBracketSameLine: false,
8+
insertPragma: false,
9+
jsxSingleQuote: true,
10+
printWidth: 120,
11+
proseWrap: 'preserve',
12+
quoteProps: 'as-needed',
13+
requirePragma: false,
14+
trailingComma: 'none',
15+
useTabs: false
16+
}

App.tsx

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,104 +8,99 @@
88
* @format
99
*/
1010

11-
import React from 'react';
12-
import {
13-
SafeAreaView,
14-
ScrollView,
15-
StatusBar,
16-
StyleSheet,
17-
Text,
18-
useColorScheme,
19-
View,
20-
} from 'react-native';
11+
import React from 'react'
12+
import { SafeAreaView, ScrollView, StatusBar, StyleSheet, Text, useColorScheme, View } from 'react-native'
2113

2214
import {
2315
Colors,
2416
DebugInstructions,
2517
Header,
2618
LearnMoreLinks,
27-
ReloadInstructions,
28-
} from 'react-native/Libraries/NewAppScreen';
19+
ReloadInstructions
20+
} from 'react-native/Libraries/NewAppScreen'
2921

3022
const Section: React.FC<{
31-
title: string;
23+
title: string
3224
}> = ({ children, title }) => {
33-
const isDarkMode = useColorScheme() === 'dark';
25+
const isDarkMode = useColorScheme() === 'dark'
3426
return (
3527
<View style={styles.sectionContainer}>
3628
<Text
3729
style={[
3830
styles.sectionTitle,
3931
{
40-
color: isDarkMode ? Colors.white : Colors.black,
41-
},
42-
]}>
32+
color: isDarkMode ? Colors.white : Colors.black
33+
}
34+
]}
35+
>
4336
{title}
4437
</Text>
4538
<Text
4639
style={[
4740
styles.sectionDescription,
4841
{
49-
color: isDarkMode ? Colors.light : Colors.dark,
50-
},
51-
]}>
42+
color: isDarkMode ? Colors.light : Colors.dark
43+
}
44+
]}
45+
>
5246
{children}
5347
</Text>
5448
</View>
55-
);
56-
};
49+
)
50+
}
5751

5852
const App = () => {
59-
const isDarkMode = useColorScheme() === 'dark';
53+
const isDarkMode = useColorScheme() === 'dark'
6054

6155
const backgroundStyle = {
62-
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
63-
};
56+
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter
57+
}
6458

6559
return (
6660
<SafeAreaView style={backgroundStyle}>
6761
<StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
68-
<ScrollView contentInsetAdjustmentBehavior="automatic" style={backgroundStyle}>
62+
<ScrollView contentInsetAdjustmentBehavior='automatic' style={backgroundStyle}>
6963
<Header />
7064
<View
7165
style={{
72-
backgroundColor: isDarkMode ? Colors.black : Colors.white,
73-
}}>
74-
<Section title="Step One">
75-
Edit <Text style={styles.highlight}>App.tsx</Text> to change this screen and then come
76-
back to see your edits.
66+
backgroundColor: isDarkMode ? Colors.black : Colors.white
67+
}}
68+
>
69+
<Section title='Step One'>
70+
Edit <Text style={styles.highlight}>App.tsx</Text> to change this screen and then come back to see your
71+
edits.
7772
</Section>
78-
<Section title="See Your Changes">
73+
<Section title='See Your Changes'>
7974
<ReloadInstructions />
8075
</Section>
81-
<Section title="Debug">
76+
<Section title='Debug'>
8277
<DebugInstructions />
8378
</Section>
84-
<Section title="Learn More">Read the docs to discover what to do next:</Section>
79+
<Section title='Learn More'>Read the docs to discover what to do next:</Section>
8580
<LearnMoreLinks />
8681
</View>
8782
</ScrollView>
8883
</SafeAreaView>
89-
);
90-
};
84+
)
85+
}
9186

9287
const styles = StyleSheet.create({
9388
sectionContainer: {
9489
marginTop: 32,
95-
paddingHorizontal: 24,
90+
paddingHorizontal: 24
9691
},
9792
sectionTitle: {
9893
fontSize: 24,
99-
fontWeight: '600',
94+
fontWeight: '600'
10095
},
10196
sectionDescription: {
10297
marginTop: 8,
10398
fontSize: 18,
104-
fontWeight: '400',
99+
fontWeight: '400'
105100
},
106101
highlight: {
107-
fontWeight: '700',
108-
},
109-
});
102+
fontWeight: '700'
103+
}
104+
})
110105

111-
export default App;
106+
export default App

0 commit comments

Comments
 (0)