Skip to content
This repository was archived by the owner on Sep 8, 2021. It is now read-only.

Commit 661fdb1

Browse files
committed
add packages and configure prettier, eslint and jest
1 parent fada4df commit 661fdb1

10 files changed

+301
-268
lines changed

.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
module.exports = {
22
root: true,
33
extends: '@react-native-community',
4+
env: {
5+
jest: true,
6+
},
47
parser: '@typescript-eslint/parser',
58
plugins: ['@typescript-eslint'],
69
};

.prettierrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
2-
bracketSpacing: false,
32
jsxBracketSameLine: true,
3+
semi: true,
44
singleQuote: true,
5-
trailingComma: 'all',
5+
trailingComma: 'es5',
66
};

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* @format
33
*/
44

5-
import {AppRegistry} from 'react-native';
6-
import App from './App';
7-
import {name as appName} from './app.json';
5+
import { AppRegistry } from 'react-native';
6+
import App from './src/App';
7+
import { name as appName } from './app.json';
88

99
AppRegistry.registerComponent(appName, () => App);

jest.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const jestPreset = require('@testing-library/react-native/jest-preset');
2+
3+
module.exports = {
4+
preset: '@testing-library/react-native',
5+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
6+
setupFiles: [
7+
...jestPreset.setupFiles,
8+
'./node_modules/react-native-gesture-handler/jestSetup.js',
9+
],
10+
setupFilesAfterEnv: ['./src/testSetup'],
11+
testMatch: ['**/__tests__/?(*.)+(test).{js,jsx,ts,tsx}'],
12+
transformIgnorePatterns: [
13+
'node_modules/(?!(jest-)?react-native|react-clone-referenced-element|react-navigation|react-navigation-stack|react-navigation-drawer|@react-navigation/core|@react-navigation/native|react-native-gesture-handler|@react-native-community/masked-view)',
14+
],
15+
};

package.json

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,36 @@
1010
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
1111
},
1212
"dependencies": {
13+
"@react-native-community/masked-view": "^0.1.7",
1314
"react": "16.9.0",
14-
"react-native": "0.61.5"
15+
"react-native": "0.61.5",
16+
"react-native-gesture-handler": "^1.6.0",
17+
"react-native-reanimated": "^1.7.0",
18+
"react-native-safe-area-context": "^0.7.3",
19+
"react-native-screens": "^2.2.0",
20+
"react-navigation": "^4.1.0",
21+
"react-navigation-drawer": "^2.4.2",
22+
"react-navigation-stack": "^2.2.2",
23+
"react-navigation-tabs": "^2.8.2"
1524
},
1625
"devDependencies": {
1726
"@babel/core": "^7.6.2",
1827
"@babel/runtime": "^7.6.2",
1928
"@react-native-community/eslint-config": "^0.0.5",
29+
"@testing-library/react-native": "^5.0.3",
2030
"@types/jest": "^24.0.24",
2131
"@types/react-native": "^0.60.25",
32+
"@types/react-navigation": "^3.4.0",
2233
"@types/react-test-renderer": "16.9.1",
2334
"@typescript-eslint/eslint-plugin": "^2.12.0",
2435
"@typescript-eslint/parser": "^2.12.0",
2536
"babel-jest": "^24.9.0",
2637
"eslint": "^6.5.1",
38+
"eslint-plugin-prettier": "^3.1.2",
2739
"jest": "^24.9.0",
2840
"metro-react-native-babel-preset": "^0.56.0",
41+
"prettier": "^1.19.1",
2942
"react-test-renderer": "16.9.0",
3043
"typescript": "^3.7.3"
31-
},
32-
"jest": {
33-
"preset": "react-native",
34-
"moduleFileExtensions": [
35-
"ts",
36-
"tsx",
37-
"js",
38-
"jsx",
39-
"json",
40-
"node"
41-
]
4244
}
4345
}

App.tsx renamed to src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
ReloadInstructions,
2727
} from 'react-native/Libraries/NewAppScreen';
2828

29-
declare var global: {HermesInternal: null | {}};
29+
declare var global: { HermesInternal: null | {} };
3030

3131
const App = () => {
3232
return (
File renamed without changes.

src/testSetup.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
jest.mock('react-native/Libraries/Animated/src/NativeAnimatedHelper');

tsconfig.json

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
1-
21
{
32
"compilerOptions": {
43
/* Basic Options */
5-
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
6-
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
7-
"lib": ["es6"], /* Specify library files to be included in the compilation. */
8-
"allowJs": true, /* Allow javascript files to be compiled. */
4+
"target": "esnext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
5+
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
6+
"lib": [
7+
"es6"
8+
] /* Specify library files to be included in the compilation. */,
9+
"allowJs": true /* Allow javascript files to be compiled. */,
910
// "checkJs": true, /* Report errors in .js files. */
10-
"jsx": "react-native", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
11+
"jsx": "react-native" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */,
1112
// "declaration": true, /* Generates corresponding '.d.ts' file. */
1213
// "sourceMap": true, /* Generates corresponding '.map' file. */
1314
// "outFile": "./", /* Concatenate and emit output to single file. */
1415
// "outDir": "./", /* Redirect output structure to the directory. */
1516
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
1617
// "removeComments": true, /* Do not emit comments to output. */
17-
"noEmit": true, /* Do not emit outputs. */
18-
"incremental": true, /* Enable incremental compilation */
18+
"noEmit": true /* Do not emit outputs. */,
19+
"incremental": true /* Enable incremental compilation */,
1920
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
2021
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
21-
"isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
22+
"isolatedModules": true /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */,
2223

2324
/* Strict Type-Checking Options */
24-
"strict": true, /* Enable all strict type-checking options. */
25+
"strict": true /* Enable all strict type-checking options. */,
2526
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
2627
// "strictNullChecks": true, /* Enable strict null checks. */
2728
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
@@ -30,20 +31,20 @@
3031
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
3132

3233
/* Additional Checks */
33-
// "noUnusedLocals": true, /* Report errors on unused locals. */
34-
// "noUnusedParameters": true, /* Report errors on unused parameters. */
34+
"noUnusedLocals": true /* Report errors on unused locals. */,
35+
"noUnusedParameters": true /* Report errors on unused parameters. */,
3536
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
3637
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
3738

3839
/* Module Resolution Options */
39-
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
40-
"baseUrl": "./", /* Base directory to resolve non-absolute module names. */
40+
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
41+
"baseUrl": "./" /* Base directory to resolve non-absolute module names. */,
4142
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
4243
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
4344
// "typeRoots": [], /* List of folders to include type definitions from. */
4445
// "types": [], /* Type declaration files to be included in compilation. */
45-
"allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
46-
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
46+
"allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */,
47+
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
4748
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
4849

4950
/* Source Map Options */
@@ -55,8 +56,9 @@
5556
/* Experimental Options */
5657
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
5758
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
59+
"skipLibCheck": true,
60+
"experimentalDecorators": true,
61+
"emitDecoratorMetadata": true
5862
},
59-
"exclude": [
60-
"node_modules", "babel.config.js", "metro.config.js", "jest.config.js"
61-
]
63+
"exclude": ["node_modules", "*.config.js"]
6264
}

0 commit comments

Comments
 (0)