Skip to content

Commit

Permalink
chore: typescript setup (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
calintamas committed Oct 25, 2021
1 parent d7a4c14 commit 5c252fb
Show file tree
Hide file tree
Showing 20 changed files with 3,233 additions and 3,064 deletions.
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
root: true,
extends: ['backpacker-react-ts'],
rules: {
'import/no-extraneous-dependencies': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off'
}
};
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: npm
directory: '/'
schedule:
interval: monthly
time: '03:00'
open-pull-requests-limit: 10
reviewers:
- calintamas
44 changes: 44 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: tests

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Restore yarn cache
uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn --prefer-offline

- name: Setup React Native environment
run: |
yarn add react@17.0.1
yarn add react-native@0.64.2
- name: Run tests
run: yarn test --coverage

- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
lib
coverage
.DS_Store
.git
.idea
node_modules
node_modules
91 changes: 0 additions & 91 deletions README.md

This file was deleted.

3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: ['module:metro-react-native-babel-preset']
};
3 changes: 0 additions & 3 deletions index.js

This file was deleted.

2 changes: 2 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { Cache } from './src/Cache';
export * from './src/types';
6 changes: 6 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
preset: 'react-native',
testEnvironment: 'node',
collectCoverage: true,
collectCoverageFrom: ['src/**/*.{ts,tsx}']
};
51 changes: 38 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,56 @@
{
"name": "react-native-cachemere",
"version": "1.2.0",
"version": "2.0.0",
"description": "An async cache manager for React Native",
"main": "index.js",
"main": "./lib/index.js",
"types": "./lib/types/index.d.ts",
"files": [
"/lib"
],
"scripts": {
"test": "jest"
"prepare": "husky install",
"build": "rm -rf ./lib && tsc",
"prettier": "./node_modules/.bin/prettier --write",
"lint": "./node_modules/.bin/eslint --fix",
"lint-staged": "./node_modules/.bin/lint-staged",
"test": "./node_modules/.bin/jest"
},
"keywords": [
"cache",
"react-native"
],
"author": "Calin Tamas <calinntamas@gmail.com>",
"author": "Calin Tamas <calintamas2@gmail.com>",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/calintamas/react-native-cachemere.git"
},
"devDependencies": {
"@babel/core": "^7.6.4",
"@babel/preset-env": "^7.6.3",
"@babel/runtime": "^7.6.3",
"babel-jest": "^26.0.0",
"jest": "^26.0.1"
"@babel/core": "^7.15.8",
"@types/jest": "^27.0.1",
"eslint-config-backpacker-react-ts": "^0.1.0",
"husky": "^7.0.2",
"import-sort-style-module": "^6.0.0",
"jest": "^27.1.1",
"lint-staged": "^11.1.2",
"prettier": "^2.4.1",
"prettier-plugin-import-sort": "^0.0.7",
"typescript": "^4.4.3",
"metro-react-native-babel-preset": "^0.64.0"
},
"peerDependencies": {
"react": ">=16.9.0",
"react-native": ">=0.61.5",
"@react-native-async-storage/async-storage": ">=1.8.0"
},
"importSort": {
".js, .jsx, .ts, .tsx": {
"style": "module",
"parser": "typescript"
}
},
"jest": {
"testPathIgnorePatterns": [
"<rootDir>/node_modules"
]
"lint-staged": {
"*.{js,jsx,ts,tsx,md}": "yarn prettier",
"*.{js,jsx,ts,tsx}": "yarn lint"
}
}
9 changes: 9 additions & 0 deletions src/Cache.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { CacheOptions } from './types';

export class Cache {
ttl: CacheOptions['ttl'];

constructor({ ttl }: CacheOptions) {
this.ttl = ttl;
}
}
7 changes: 7 additions & 0 deletions src/__tests__/foo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* eslint-env jest */

describe('test mock', () => {
it('adds 2 numbers', () => {
expect(1 + 1).toBe(2);
});
});
28 changes: 0 additions & 28 deletions src/__tests__/utils.test.js

This file was deleted.

90 changes: 0 additions & 90 deletions src/cache.js

This file was deleted.

0 comments on commit 5c252fb

Please sign in to comment.