8000 fix (datafile-manager): Fix boolean types, remove StaticDatafileManag… · github/optimizely-javascript-sdk@5a2d4f9 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 5a2d4f9

Browse files
authored
fix (datafile-manager): Fix boolean types, remove StaticDatafileManager, update READMe, add eslint + prettier (optimizely#436)
Summary: Small cleanups in datafile-manager package: - Replace Boolean with boolean - global Boolean object type shouldn't be used, only the primitive type - Remove unused StaticDatafileManager (core SDK package does not consume this) - Add ESLint and Prettier. Configuration modeled after what we recently introduced in React SDK. Will follow up with a separate PR applying fixes to all files. - Update README based on recent developments, and fix a mistake Test plan: Existing unit tests
1 parent babe5d7 commit 5a2d4f9

14 files changed

+841
-106
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module.exports = {
2+
parserOptions: {
3+
ecmaVersion: 2015,
4+
sourceType: 'module',
5+
},
6+
env: {
7+
browser: true,
8+
es6: true,
9+
jest: true,
10+
mocha: true,
11+
node: true,
12+
},
13+
extends: [
14+
'eslint:recommended',
15+
'plugin:@typescript-eslint/recommended',
16+
'prettier/@typescript-eslint',
17+
18+
// Prettier should always go last so it can trump any rules above
19+
'plugin:prettier/recommended',
20+
'prettier/react',
21+
],
22+
rules: {
23+
'@typescript-eslint/ban-ts-ignore': 'off',
24+
'@typescript-eslint/camelcase': 'off',
25+
'@typescript-eslint/no-empty-function': 'off',
26+
},
27+
};

packages/datafile-manager/.prettierrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"printWidth": 120,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": true,
7+
"trailingComma": "es5",
8+
"bracketSpacing": true,
9+
"jsxBracketSameLine": false
10+
}

packages/datafile-manager/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77
## [Unreleased]
88
Changes that have landed but are not yet released.
99

10+
### Breaking Changes
11+
- Removed `StaticDatafileManager` from all top level exports
12+
1013
## [0.4.0] - June 12, 2019
1114

1215
### Changed

packages/datafile-manager/README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
# Javascript SDK Datafile Manager
22

3-
This package provides a datafile manager implementations for Node.js and the browser.
3+
This package provides datafile manager implementations for Node.js, browsers, and React Native.
44

55
## Installation
66

77
```sh
8-
npm install @optimizely/js-sdk-datafile-manager
8+
npm i @optimizely/js-sdk-datafile-manager
9+
```
10+
11+
For React Native, installation of peer dependency `@react-native-community/async-storage` is also required:
12+
```sh
13+
npm i @react-native-community/async-storage
914
```
1015

1116
## Usage
1217

1318
```js
14-
const { DatafileManager } = require('@optimizely/js-sdk-datafile-manager')
19+
const { HttpPollingDatafileManager } = require('@optimizely/js-sdk-datafile-manager')
1520

16-
const manager = new DatafileManager({
21+
const manager = new HttpPollingDatafileManager({
1722
sdkKey: '9LCprAQyd1bs1BBXZ3nVji',
1823
autoUpdate: true,
1924
updateInterval: 5000,
@@ -29,3 +34,13 @@ manager.on('update', ({ datafile }) => {
2934
console.log(datafile)
3035
})
3136
```
37+
38+
## Development
39+
For development, installation of peer dependency `@react-native-community/async-storage` is also required:
40+
```sh
41+
npm i --no-save @react-native-community/async-storage
42+
```
43+
44+
- The `lint` package.json script runs ESLint and Prettier. This applies formatting and lint fixes to all `.ts` files in the `src/` directory.
45+
- The `test` package.json script runs our Jest-based test suite.
46+
- The `tsc` package.json script runs the TypeScript compiler to build the final scripts for publishing (into the `lib/` directory).

packages/datafile-manager/__test__/httpPollingDatafileManager.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const testCache : PersistentKeyValueCache = {
8181
return Promise.resolve()
8282
},
8383

84-
contains(key: string): Promise<Boolean> {
84+
contains(key: string): Promise<boolean> {
8585
return Promise.resolve(false)
8686
},
8787

packages/datafile-manager/__test__/staticDatafileManager.spec.ts

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0