Skip to content

Commit 979921e

Browse files
author
Valeriy Borodayev
committed
chore: update packages, fix lint errors
1 parent f2bdd14 commit 979921e

File tree

8 files changed

+1116
-918
lines changed

8 files changed

+1116
-918
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ cache:
77
notifications:
88
email: true
99
node_js:
10+
- "10"
1011
- "12"
11-
- "11"
12+
- "13"
13+
- "14"
1214
before_install:
1315
- yarn global add greenkeeper-lockfile@1
1416
before_script:

package.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,37 +27,37 @@
2727
"homepage": "https://github.com/FrankAst/mongoose-history-diff",
2828
"license": "MIT",
2929
"dependencies": {
30-
"@babel/runtime": "^7.8.4"
30+
"@babel/runtime": "^7.9.6"
3131
},
3232
"peerDependencies": {
33-
"mongoose": "^5.8.11"
33+
"mongoose": "^5.9.11"
3434
},
3535
"devDependencies": {
3636
"@babel/cli": "^7.8.4",
37-
"@babel/core": "^7.8.4",
37+
"@babel/core": "^7.9.6",
3838
"@babel/plugin-proposal-class-properties": "^7.8.3",
39-
"@babel/plugin-proposal-object-rest-spread": "^7.8.3",
40-
"@babel/plugin-proposal-optional-chaining": "^7.8.3",
41-
"@babel/plugin-transform-flow-strip-types": "^7.8.3",
42-
"@babel/plugin-transform-runtime": "^7.8.3",
43-
"@babel/preset-env": "^7.8.4",
44-
"@babel/preset-flow": "^7.8.3",
39+
"@babel/plugin-proposal-object-rest-spread": "^7.9.6",
40+
"@babel/plugin-proposal-optional-chaining": "^7.9.0",
41+
"@babel/plugin-transform-flow-strip-types": "^7.9.0",
42+
"@babel/plugin-transform-runtime": "^7.9.6",
43+
"@babel/preset-env": "^7.9.6",
44+
"@babel/preset-flow": "^7.9.0",
4545
"babel-core": "^7.0.0-bridge.0",
46-
"babel-eslint": "^10.0.3",
47-
"babel-jest": "^25.1.0",
46+
"babel-eslint": "^10.1.0",
47+
"babel-jest": "^25.5.1",
4848
"babel-preset-minify": "^0.5.1",
4949
"cz-conventional-changelog": "^3.1.0",
5050
"eslint": "^6.8.0",
51-
"eslint-config-airbnb-base": "^14.0.0",
52-
"eslint-config-prettier": "^6.10.0",
53-
"eslint-plugin-flowtype": "^4.6.0",
54-
"eslint-plugin-import": "^2.20.1",
55-
"eslint-plugin-prettier": "^3.1.2",
56-
"flow-bin": "^0.117.0",
57-
"jest": "25.1.0",
58-
"mongodb-memory-server": "^6.2.4",
59-
"prettier": "^1.19.1",
60-
"semantic-release": "^17.0.2"
51+
"eslint-config-airbnb-base": "^14.1.0",
52+
"eslint-config-prettier": "^6.11.0",
53+
"eslint-plugin-flowtype": "^4.7.0",
54+
"eslint-plugin-import": "^2.20.2",
55+
"eslint-plugin-prettier": "^3.1.3",
56+
"flow-bin": "^0.123.0",
57+
"jest": "25.5.4",
58+
"mongodb-memory-server": "^6.5.2",
59+
"prettier": "^2.0.5",
60+
"semantic-release": "^17.0.7"
6161
},
6262
"publishConfig": {
6363
"access": "public"

src/DiffModel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { Schema, type MongooseConnection } from 'mongoose';
44
import { ItemDoc, ChangeDoc, DiffDoc, type DiffModelT } from './definitions';
55

6-
export default function(
6+
export default function (
77
mongooseConnection: MongooseConnection,
88
collectionName: string
99
): DiffModelT {

src/definitions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class DiffDoc /* :: extends Mongoose$Document */ {
6868
const diffDocs = (await this.findAfterVersion(doc._id, v): any);
6969

7070
if (diffDocs.length === 0) return null;
71-
diffDocs.forEach(diffDoc => changes.push(...diffDoc.c));
71+
diffDocs.forEach((diffDoc) => changes.push(...diffDoc.c));
7272
return revertChanges(doc, changes);
7373
}
7474

src/diff.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export const deepDiff = (
130130
const lhsKeys = Object.keys(lhs);
131131
const rhsKeys = Object.keys(rhs);
132132

133-
lhsKeys.forEach(lhsKey => {
133+
lhsKeys.forEach((lhsKey) => {
134134
other = rhsKeys.indexOf(lhsKey);
135135
if (other >= 0) {
136136
deepDiff(lhs[lhsKey], rhs[lhsKey], changes, {
@@ -152,7 +152,7 @@ export const deepDiff = (
152152
}
153153
});
154154

155-
rhsKeys.forEach(rhsKey => {
155+
rhsKeys.forEach((rhsKey) => {
156156
if (rhsKey) {
157157
deepDiff(null, rhs[rhsKey], changes, {
158158
prefilter,
@@ -179,7 +179,7 @@ export const deepDiff = (
179179
export const revertChanges = (target: any, changes: Array<RawChangeT>): any => {
180180
const copyTarget = deepClone(target);
181181

182-
changes.forEach(change => {
182+
changes.forEach((change) => {
183183
let it = copyTarget;
184184
let i;
185185

src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ export default function plugin(schema: MongooseSchema<any>, options?: OptionsT)
1717
MHD.excludedFields = getExcludedFields(schema);
1818

1919
// $FlowFixMe
20-
schema.static('diffModel', function(): DiffModelT {
20+
schema.static('diffModel', function (): DiffModelT {
2121
const collectionName = options?.diffCollectionName || `${this.collection.name}_diff`;
2222
return DiffModel(this.collection.conn, collectionName);
2323
});
2424

25-
schema.post('init', function() {
25+
schema.post('init', function () {
2626
this._original = this.toObject();
2727
});
2828

29-
schema.pre('save', async function() {
29+
schema.pre('save', async function () {
3030
if (!this.isNew && this._original) {
3131
await this.increment();
3232
const lhs = this._original;

src/utils.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const excludeFields = (
1515
): boolean => {
1616
if (path.length === 0 && key === '_id') return true;
1717
let isFilter = false;
18-
excludedFields.forEach(field => {
18+
excludedFields.forEach((field) => {
1919
if (path.length === field.lvl && key === field.key) isFilter = true;
2020
});
2121
return isFilter;
@@ -32,7 +32,7 @@ export const getExcludedFields = (schema: MongooseSchema<any>): Array<ExcludeFie
3232
const key = splittedPath[lvl];
3333
excludedFields.push({ key, lvl });
3434
} else if (value.instance === 'Array') {
35-
value.options.type.forEach(obj => {
35+
value.options.type.forEach((obj) => {
3636
const aKey = Object.keys(obj)[0];
3737
const aPath = [path, aKey].join('.');
3838
const aOptions = obj[aKey];
@@ -93,7 +93,7 @@ export const getOrderIndependentHash = (obj: any): number => {
9393
let accum = 0;
9494
const type = realTypeOf(obj);
9595
if (type === 'array') {
96-
obj.forEach(item => {
96+
obj.forEach((item) => {
9797
// Addition is commutative so this is order indep
9898
accum += getOrderIndependentHash(item);
9999
});
@@ -102,7 +102,7 @@ export const getOrderIndependentHash = (obj: any): number => {
102102
}
103103

104104
if (type === 'object') {
105-
Object.keys(obj).forEach(key => {
105+
Object.keys(obj).forEach((key) => {
106106
const keyValueString = `[ type: object, key: ${key}, value hash: ${getOrderIndependentHash(
107107
obj[key]
108108
)}]`;

0 commit comments

Comments
 (0)