Skip to content

fix(prettier): Properly handle lint-staged files #6970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
semi: true
trailingComma: "es5"
singleQuote: true
arrowParens: "avoid"
arrowParens: "avoid"
printWidth: 100
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"posttest": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=4.0.4} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} MONGODB_STORAGE_ENGINE=${MONGODB_STORAGE_ENGINE:=mmapv1} mongodb-runner stop",
"coverage": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=4.0.4} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} MONGODB_STORAGE_ENGINE=${MONGODB_STORAGE_ENGINE:=mmapv1} TESTING=1 nyc jasmine",
"start": "node ./bin/parse-server",
"prettier": "prettier --write {src,spec}/**/*.js",
"prettier": "prettier --write {src,spec}/{**/*,*}.js",
"prepare": "npm run build",
"postinstall": "node -p 'require(\"./postinstall.js\")()'"
},
Expand Down Expand Up @@ -133,7 +133,7 @@
}
},
"lint-staged": {
"{src,spec}/**/*.js": [
"{src,spec}/{**/*,*}.js": [
"prettier --write",
"eslint --fix --cache",
"git add"
Expand Down
109 changes: 26 additions & 83 deletions spec/AccountLockoutPolicy.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const Config = require('../lib/Config');

const loginWithWrongCredentialsShouldFail = function(username, password) {
const loginWithWrongCredentialsShouldFail = function (username, password) {
return new Promise((resolve, reject) => {
Parse.User.logIn(username, password)
.then(() => reject('login should have failed'))
Expand All @@ -16,7 +16,7 @@ const loginWithWrongCredentialsShouldFail = function(username, password) {
});
};

const isAccountLockoutError = function(username, password, duration, waitTime) {
const isAccountLockoutError = function (username, password, duration, waitTime) {
return new Promise((resolve, reject) => {
setTimeout(() => {
Parse.User.logIn(username, password)
Expand Down Expand Up @@ -50,28 +50,17 @@ describe('Account Lockout Policy: ', () => {
return user.signUp(null);
})
.then(() => {
return loginWithWrongCredentialsShouldFail(
'username1',
'incorrect password 1'
);
return loginWithWrongCredentialsShouldFail('username1', 'incorrect password 1');
})
.then(() => {
return loginWithWrongCredentialsShouldFail(
'username1',
'incorrect password 2'
);
return loginWithWrongCredentialsShouldFail('username1', 'incorrect password 2');
})
.then(() => {
return loginWithWrongCredentialsShouldFail(
'username1',
'incorrect password 3'
);
return loginWithWrongCredentialsShouldFail('username1', 'incorrect password 3');
})
.then(() => done())
.catch(err => {
fail(
'allow unlimited failed login attempts failed: ' + JSON.stringify(err)
);
fail('allow unlimited failed login attempts failed: ' + JSON.stringify(err));
done();
});
});
Expand All @@ -93,15 +82,11 @@ describe('Account Lockout Policy: ', () => {
.catch(err => {
if (
err &&
err ===
'Account lockout duration should be greater than 0 and less than 100000'
err === 'Account lockout duration should be greater than 0 and less than 100000'
) {
done();
} else {
fail(
'set duration to an invalid number test failed: ' +
JSON.stringify(err)
);
fail('set duration to an invalid number test failed: ' + JSON.stringify(err));
done();
}
});
Expand All @@ -124,15 +109,11 @@ describe('Account Lockout Policy: ', () => {
.catch(err => {
if (
err &&
err ===
'Account lockout threshold should be an integer greater than 0 and less than 1000'
err === 'Account lockout threshold should be an integer greater than 0 and less than 1000'
) {
done();
} else {
fail(
'set threshold to an invalid number test failed: ' +
JSON.stringify(err)
);
fail('set threshold to an invalid number test failed: ' + JSON.stringify(err));
done();
}
});
Expand All @@ -155,14 +136,11 @@ describe('Account Lockout Policy: ', () => {
.catch(err => {
if (
err &&
err ===
'Account lockout threshold should be an integer greater than 0 and less than 1000'
err === 'Account lockout threshold should be an integer greater than 0 and less than 1000'
) {
done();
} else {
fail(
'threshold value < 1 is invalid test failed: ' + JSON.stringify(err)
);
fail('threshold value < 1 is invalid test failed: ' + JSON.stringify(err));
done();
}
});
Expand All @@ -185,15 +163,11 @@ describe('Account Lockout Policy: ', () => {
.catch(err => {
if (
err &&
err ===
'Account lockout threshold should be an integer greater than 0 and less than 1000'
err === 'Account lockout threshold should be an integer greater than 0 and less than 1000'
) {
done();
} else {
fail(
'threshold value > 999 is invalid test failed: ' +
JSON.stringify(err)
);
fail('threshold value > 999 is invalid test failed: ' + JSON.stringify(err));
done();
}
});
Expand All @@ -216,14 +190,11 @@ describe('Account Lockout Policy: ', () => {
.catch(err => {
if (
err &&
err ===
'Account lockout duration should be greater than 0 and less than 100000'
err === 'Account lockout duration should be greater than 0 and less than 100000'
) {
done();
} else {
fail(
'duration value < 1 is invalid test failed: ' + JSON.stringify(err)
);
fail('duration value < 1 is invalid test failed: ' + JSON.stringify(err));
done();
}
});
Expand All @@ -246,15 +217,11 @@ describe('Account Lockout Policy: ', () => {
.catch(err => {
if (
err &&
err ===
'Account lockout duration should be greater than 0 and less than 100000'
err === 'Account lockout duration should be greater than 0 and less than 100000'
) {
done();
} else {
fail(
'duration value > 99999 is invalid test failed: ' +
JSON.stringify(err)
);
fail('duration value > 99999 is invalid test failed: ' + JSON.stringify(err));
done();
}
});
Expand All @@ -276,16 +243,10 @@ describe('Account Lockout Policy: ', () => {
return user.signUp();
})
.then(() => {
return loginWithWrongCredentialsShouldFail(
'username2',
'wrong password'
);
return loginWithWrongCredentialsShouldFail('username2', 'wrong password');
})
.then(() => {
return loginWithWrongCredentialsShouldFail(
'username2',
'wrong password'
);
return loginWithWrongCredentialsShouldFail('username2', 'wrong password');
})
.then(() => {
return isAccountLockoutError('username2', 'wrong password', 1, 1);
Expand All @@ -294,10 +255,7 @@ describe('Account Lockout Policy: ', () => {
done();
})
.catch(err => {
fail(
'lock account after failed login attempts test failed: ' +
JSON.stringify(err)
);
fail('lock account after failed login attempts test failed: ' + JSON.stringify(err));
done();
});
});
Expand All @@ -318,16 +276,10 @@ describe('Account Lockout Policy: ', () => {
return user.signUp();
})
.then(() => {
return loginWithWrongCredentialsShouldFail(
'username3',
'wrong password'
);
return loginWithWrongCredentialsShouldFail('username3', 'wrong password');
})
.then(() => {
return loginWithWrongCredentialsShouldFail(
'username3',
'wrong password'
);
return loginWithWrongCredentialsShouldFail('username3', 'wrong password');
})
.then(() => {
return isAccountLockoutError('username3', 'wrong password', 0.05, 1);
Expand All @@ -340,10 +292,7 @@ describe('Account Lockout Policy: ', () => {
done();
})
.catch(err => {
fail(
'account should be locked for duration mins test failed: ' +
JSON.stringify(err)
);
fail('account should be locked for duration mins test failed: ' + JSON.stringify(err));
done();
});
});
Expand All @@ -364,16 +313,10 @@ describe('Account Lockout Policy: ', () => {
return user.signUp();
})
.then(() => {
return loginWithWrongCredentialsShouldFail(
'username4',
'wrong password'
);
return loginWithWrongCredentialsShouldFail('username4', 'wrong password');
})
.then(() => {
return loginWithWrongCredentialsShouldFail(
'username4',
'wrong password'
);
return loginWithWrongCredentialsShouldFail('username4', 'wrong password');
})
.then(() => {
// allow locked user to login after 3 seconds with a valid userid and password
Expand Down
28 changes: 13 additions & 15 deletions spec/AdaptableController.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
const AdaptableController = require('../lib/Controllers/AdaptableController')
.AdaptableController;
const AdaptableController = require('../lib/Controllers/AdaptableController').AdaptableController;
const FilesAdapter = require('../lib/Adapters/Files/FilesAdapter').default;
const FilesController = require('../lib/Controllers/FilesController')
.FilesController;
const FilesController = require('../lib/Controllers/FilesController').FilesController;

const MockController = function(options) {
const MockController = function (options) {
AdaptableController.call(this, options);
};
MockController.prototype = Object.create(AdaptableController.prototype);
Expand Down Expand Up @@ -60,11 +58,11 @@ describe('AdaptableController', () => {

it('should accept an object adapter', done => {
const adapter = {
createFile: function() {},
deleteFile: function() {},
getFileData: function() {},
getFileLocation: function() {},
validateFilename: function() {},
createFile: function () {},
deleteFile: function () {},
getFileData: function () {},
getFileLocation: function () {},
validateFilename: function () {},
};
expect(() => {
new FilesController(adapter);
Expand All @@ -74,11 +72,11 @@ describe('AdaptableController', () => {

it('should accept an prototype based object adapter', done => {
function AGoodAdapter() {}
AGoodAdapter.prototype.createFile = function() {};
AGoodAdapter.prototype.deleteFile = function() {};
AGoodAdapter.prototype.getFileData = function() {};
AGoodAdapter.prototype.getFileLocation = function() {};
AGoodAdapter.prototype.validateFilename = function() {};
AGoodAdapter.prototype.createFile = function () {};
AGoodAdapter.prototype.deleteFile = function () {};
AGoodAdapter.prototype.getFileData = function () {};
AGoodAdapter.prototype.getFileLocation = function () {};
AGoodAdapter.prototype.validateFilename = function () {};

const adapter = new AGoodAdapter();
expect(() => {
Expand Down
8 changes: 3 additions & 5 deletions spec/AdapterLoader.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ describe('AdapterLoader', () => {
});

it('should instantiate an adapter from string that is module', done => {
const adapterPath = require('path').resolve(
'./lib/Adapters/Files/FilesAdapter'
);
const adapterPath = require('path').resolve('./lib/Adapters/Files/FilesAdapter');
const adapter = loadAdapter({
adapter: adapterPath,
});
Expand Down Expand Up @@ -88,14 +86,14 @@ describe('AdapterLoader', () => {
});

it('should fail loading an improperly configured adapter', done => {
const Adapter = function(options) {
const Adapter = function (options) {
if (!options.foo) {
throw 'foo is required for that adapter';
}
};
const adapterOptions = {
param: 'key',
doSomething: function() {},
doSomething: function () {},
};

expect(() => {
Expand Down
11 changes: 3 additions & 8 deletions spec/AggregateRouter.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const AggregateRouter = require('../lib/Routers/AggregateRouter')
.AggregateRouter;
const AggregateRouter = require('../lib/Routers/AggregateRouter').AggregateRouter;

describe('AggregateRouter', () => {
it('get pipeline from Array', () => {
Expand Down Expand Up @@ -56,9 +55,7 @@ describe('AggregateRouter', () => {
try {
AggregateRouter.getPipeline(body);
} catch (e) {
expect(e.message).toBe(
'Pipeline stages should only have one key found group, match'
);
expect(e.message).toBe('Pipeline stages should only have one key found group, match');
}
});

Expand All @@ -74,9 +71,7 @@ describe('AggregateRouter', () => {
try {
AggregateRouter.getPipeline(body);
} catch (e) {
expect(e.message).toBe(
'Pipeline stages should only have one key found group, match'
);
expect(e.message).toBe('Pipeline stages should only have one key found group, match');
}
});
});
4 changes: 2 additions & 2 deletions spec/Analytics.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const analyticsAdapter = {
appOpened: function() {},
trackEvent: function() {},
appOpened: function () {},
trackEvent: function () {},
};

describe('AnalyticsController', () => {
Expand Down
Loading