Skip to content
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

chore: introduce prettier and run it #1660

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"bracketSpacing": false,
"printWidth": 80,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"useTabs": false,
"arrowParens": "always"
}
2 changes: 1 addition & 1 deletion lib/chai.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function use(fn) {
}

return exports;
};
}

// Utility Functions
export {util};
Expand Down
58 changes: 37 additions & 21 deletions lib/chai/assertion.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import * as util from './utils/index.js';
* @returns {unknown}
* @private
*/
export function Assertion (obj, msg, ssfi, lockSsfi) {
export function Assertion(obj, msg, ssfi, lockSsfi) {
util.flag(this, 'ssfi', ssfi || Assertion);
util.flag(this, 'lockSsfi', lockSsfi);
util.flag(this, 'object', obj);
Expand All @@ -60,23 +60,31 @@ export function Assertion (obj, msg, ssfi, lockSsfi) {
}

Object.defineProperty(Assertion, 'includeStack', {
get: function() {
console.warn('Assertion.includeStack is deprecated, use chai.config.includeStack instead.');
get: function () {
console.warn(
'Assertion.includeStack is deprecated, use chai.config.includeStack instead.'
);
return config.includeStack;
},
set: function(value) {
console.warn('Assertion.includeStack is deprecated, use chai.config.includeStack instead.');
set: function (value) {
console.warn(
'Assertion.includeStack is deprecated, use chai.config.includeStack instead.'
);
config.includeStack = value;
}
});

Object.defineProperty(Assertion, 'showDiff', {
get: function() {
console.warn('Assertion.showDiff is deprecated, use chai.config.showDiff instead.');
get: function () {
console.warn(
'Assertion.showDiff is deprecated, use chai.config.showDiff instead.'
);
return config.showDiff;
},
set: function(value) {
console.warn('Assertion.showDiff is deprecated, use chai.config.showDiff instead.');
set: function (value) {
console.warn(
'Assertion.showDiff is deprecated, use chai.config.showDiff instead.'
);
config.showDiff = value;
}
});
Expand Down Expand Up @@ -120,7 +128,14 @@ Assertion.overwriteChainableMethod = function (name, fn, chainingBehavior) {
* @private
*/

Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual, showDiff) {
Assertion.prototype.assert = function (
expr,
msg,
negateMsg,
expected,
_actual,
showDiff
) {
var ok = util.test(this, arguments);
if (false !== showDiff) showDiff = true;
if (undefined === expected && undefined === _actual) showDiff = false;
Expand All @@ -130,9 +145,9 @@ Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual,
msg = util.getMessage(this, arguments);
var actual = util.getActual(this, arguments);
var assertionErrorObjectProperties = {
actual: actual
, expected: expected
, showDiff: showDiff
actual: actual,
expected: expected,
showDiff: showDiff
};

var operator = util.getOperator(this, arguments);
Expand All @@ -143,7 +158,8 @@ Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual,
throw new AssertionError(
msg,
assertionErrorObjectProperties,
(config.includeStack) ? this.assert : util.flag(this, 'ssfi'));
config.includeStack ? this.assert : util.flag(this, 'ssfi')
);
}
};

Expand All @@ -154,11 +170,11 @@ Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual,
*
* @private
*/
Object.defineProperty(Assertion.prototype, '_obj',
{ get: function () {
return util.flag(this, 'object');
}
, set: function (val) {
util.flag(this, 'object', val);
}
Object.defineProperty(Assertion.prototype, '_obj', {
get: function () {
return util.flag(this, 'object');
},
set: function (val) {
util.flag(this, 'object', val);
}
});
2 changes: 0 additions & 2 deletions lib/chai/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export const config = {

/**
* ### config.includeStack
*
Expand Down Expand Up @@ -110,5 +109,4 @@ export const config = {
* @public
*/
deepEqual: null

};
Loading
Loading