Skip to content

Commit

Permalink
Merge pull request #46 from Imtiyaz-CHOUJAI/feature/refactoring
Browse files Browse the repository at this point in the history
Feature/refactoring
  • Loading branch information
amranidev authored Jan 20, 2020
2 parents 9402360 + c62cd02 commit 387af6b
Show file tree
Hide file tree
Showing 15 changed files with 383 additions and 330 deletions.
7 changes: 6 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"presets": ["env"]
"presets": ["@babel/preset-env"],
"env": {
"test": {
"plugins": ["@babel/plugin-transform-runtime"]
}
}
}
10 changes: 0 additions & 10 deletions .eslintrc

This file was deleted.

23 changes: 23 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
env: {
browser: true,
es6: true
},
extends: ['plugin:vue/essential', 'airbnb-base', 'prettier'],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module'
},
plugins: ['vue', 'prettier'],
rules: {
'prettier/prettier': ['error'],
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
'no-param-reassign': ['warn'],
'guard-for-in': 0,
'no-restricted-syntax': 0
}
};
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"printWidth": 100,
"singleQuote": true
}
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
nguage: node_js
node_js:
- 6.10.0
script: npm run test
services:
- xvfb
before_install:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
before_script:
- npm install
script: npm run test
2 changes: 1 addition & 1 deletion dist/vue-firestore.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 50 additions & 43 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,52 @@
{
"name": "vue-firestore",
"version": "0.3.22",
"description": "Vue plugin for firestore",
"main": "./dist/vue-firestore.js",
"scripts": {
"test": "jest --forceExit --detectOpenHandles",
"lint": "eslint --fix src",
"build": "webpack"
},
"keywords": [
"vue",
"firebase",
"cloud",
"cloud firestore",
"realtime"
],
"author": "Amrani Houssain",
"license": "MIT",
"peerDependencies": {
"firebase": "^5.x.x"
},
"devDependencies": {
"babel-core": "^6.24.1",
"babel-loader": "^6.4.1",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-2": "^6.18.0",
"codecov": "^1.0.1",
"eslint": ">=4.18.2",
"eslint-config-standard": "^6.2.1",
"eslint-plugin-html": "^2.0.0",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^2.0.1",
"firebase": "^5.0.0",
"jest": "^23.6.0",
"vue": "^1.0.28",
"webpack": "^2.6.1"
},
"jest": {
"collectCoverage": true,
"collectCoverageFrom": [
"<rootDir>/src/*.js"
]
}
"name": "vue-firestore",
"version": "0.3.22",
"description": "Vue plugin for firestore",
"main": "./dist/vue-firestore.js",
"scripts": {
"test": "jest --forceExit --detectOpenHandles",
"lint": "eslint --fix src",
"build": "webpack"
},
"keywords": [
"vue",
"firebase",
"cloud",
"cloud firestore",
"realtime"
],
"author": "Amrani Houssain",
"license": "MIT",
"peerDependencies": {
"firebase": "^7.6.1"
},
"dependencies": {
"@babel/core": "^7.7.7",
"@babel/preset-env": "^7.7.7",
"babel-loader": "^8.0.6",
"cross-env": "^6.0.3",
"firebase": "^7.6.1",
"vue": "^2.6.11"
},
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/runtime": "^7.7.7",
"codecov": "^3.6.1",
"eslint": "^5.16.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-config-prettier": "^6.9.0",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-vue": "^6.1.2",
"jest": "^24.9.0",
"prettier": "^1.19.1",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10"
},
"jest": {
"collectCoverage": true,
"collectCoverageFrom": [
"<rootDir>/src/*.js"
]
}
}
5 changes: 5 additions & 0 deletions src/defaultOptions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Plugin options
export default {
keyName: '.key',
enumerable: true
};
4 changes: 2 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import VueFireStore from './vue-firestore'
import VueFireStore from './vue-firestore';

export default VueFireStore
export default VueFireStore;
26 changes: 14 additions & 12 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* @param {*} val
* @return {boolean}
*/
export function isObject (val) {
return Object.prototype.toString.call(val) === '[object Object]'
}
const isObject = val => {
return Object.prototype.toString.call(val) === '[object Object]';
};

/**
* Normalize Firebase snapshot into a bindable data record.
Expand All @@ -15,23 +15,25 @@ export function isObject (val) {
* @param {object} options
* @return {object}
*/
export function normalize (snapshot, options) {
var value = snapshot.doc ? snapshot.doc.data() : snapshot.data()
var out = isObject(value) ? value : { '.value': value }
const normalize = (snapshot, options) => {
const value = snapshot.doc ? snapshot.doc.data() : snapshot.data();
const out = isObject(value) ? value : { '.value': value };
Object.defineProperty(out, options.keyName, {
value: snapshot.doc ? snapshot.doc.id : snapshot.id,
enumerable: options.enumerable
})
return out
}
});
return out;
};

/**
* Ensure firebasestore option on a vue instance.
*
* @param {Vue} vm
*/
export function ensureRefs (vm) {
const ensureRefs = vm => {
if (!vm.$firestore) {
vm.$firestore = Object.create(null)
vm.$firestore = Object.create(null);
}
}
};

export { isObject, normalize, ensureRefs };
Loading

0 comments on commit 387af6b

Please sign in to comment.