Skip to content

Commit

Permalink
fix(lint): adhere to strict triple equality check (#477)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding-SE committed May 29, 2020
1 parent 9be8fbf commit c49f950
Show file tree
Hide file tree
Showing 22 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/app/examples/custom-angularComponentEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class CustomAngularComponentEditor implements Editor {
}

isValueChanged() {
return (!(this.componentRef.instance.selectedId === '' && this.defaultId == null)) && (this.componentRef.instance.selectedId !== this.defaultId);
return (!(this.componentRef.instance.selectedId === '' && (this.defaultId === null || this.defaultId === undefined))) && (this.componentRef.instance.selectedId !== this.defaultId);
}

validate(): EditorValidatorOutput {
Expand Down
3 changes: 2 additions & 1 deletion src/app/examples/grid-editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const myCustomTitleValidator: EditorValidator = (value: any, args: EditorArgs) =
// don't use "editor" property since that one is what SlickGrid uses internally by it's editor factory
const columnEditor = args && args.column && args.column.internalColumnEditor;

if (value == null || value === undefined || !value.length) {
if (value === null || value === undefined || !value.length) {
return { valid: false, msg: 'This is a required field' };
} else if (!/^Task\s\d+$/.test(value)) {
return { valid: false, msg: 'Your title is invalid, it must start with "Task" followed by a number' };
Expand Down Expand Up @@ -644,6 +644,7 @@ export class GridEditorComponent implements OnInit {

undo() {
const command = this._commandQueue.pop();
const item = this.angularGrid.dataView.getItem(command.row);
if (command && Slick.GlobalEditorLock.cancelCurrentEdit()) {
command.undo();
this.gridObj.gotoCell(command.row, command.cell, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class AvgAggregator implements Aggregator {
accumulate(item: any) {
const val = (item && item.hasOwnProperty(this._field)) ? item[this._field] : null;
this._count++;
if (val != null && val !== '' && !isNaN(val)) {
if (val !== null && val !== undefined && val !== '' && !isNaN(val)) {
this._nonNullCount++;
this._sum += parseFloat(val);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export class MaxAggregator implements Aggregator {

accumulate(item: any) {
const val = (item && item.hasOwnProperty(this._field)) ? item[this._field] : null;
if (val != null && val !== '' && !isNaN(val)) {
if (this._max == null || val > this._max) {
if (val !== null && val !== undefined && val !== '' && !isNaN(val)) {
if (this._max === null || this._max === undefined || val > this._max) {
this._max = parseFloat(val);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export class MinAggregator implements Aggregator {

accumulate(item: any) {
const val = (item && item.hasOwnProperty(this._field)) ? item[this._field] : null;
if (val != null && val !== '' && !isNaN(val)) {
if (this._min == null || val < this._min) {
if (val !== null && val !== undefined && val !== '' && !isNaN(val)) {
if (this._min === null || this._min === undefined || val < this._min) {
this._min = parseFloat(val);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class SumAggregator implements Aggregator {

accumulate(item: any) {
const val = (item && item.hasOwnProperty(this._field)) ? item[this._field] : null;
if (val != null && val !== '' && !isNaN(val)) {
if (val !== null && val !== undefined && val !== '' && !isNaN(val)) {
this._sum += parseFloat(val);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const avgTotalsDollarFormatter: GroupTotalsFormatter = (totals: any, colu
const thousandSeparator = getValueFromParamsOrFormatterOptions('thousandSeparator', columnDef, grid, '');
const displayNegativeNumberWithParentheses = getValueFromParamsOrFormatterOptions('displayNegativeNumberWithParentheses', columnDef, grid, false);

if (val != null && !isNaN(+val)) {
if (val !== null && val !== undefined && !isNaN(+val)) {
const formattedNumber = formatNumber(val, minDecimal, maxDecimal, displayNegativeNumberWithParentheses, '$', '', decimalSeparator, thousandSeparator);
return `${prefix}${formattedNumber}${suffix}`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const avgTotalsFormatter: GroupTotalsFormatter = (totals: any, columnDef:
const thousandSeparator = getValueFromParamsOrFormatterOptions('thousandSeparator', columnDef, grid, '');
const displayNegativeNumberWithParentheses = getValueFromParamsOrFormatterOptions('displayNegativeNumberWithParentheses', columnDef, grid, false);

if (val != null && !isNaN(+val)) {
if (val !== null && val !== undefined && !isNaN(+val)) {
if (val < 0) {
val = Math.abs(val);
if (!displayNegativeNumberWithParentheses) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const avgTotalsPercentageFormatter: GroupTotalsFormatter = (totals: any,
const thousandSeparator = getValueFromParamsOrFormatterOptions('thousandSeparator', columnDef, grid, '');
const displayNegativeNumberWithParentheses = getValueFromParamsOrFormatterOptions('displayNegativeNumberWithParentheses', columnDef, grid, false);

if (val != null && !isNaN(+val)) {
if (val !== null && val !== undefined && !isNaN(+val)) {
if (val < 0) {
val = Math.abs(val);
if (!displayNegativeNumberWithParentheses) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const maxTotalsFormatter: GroupTotalsFormatter = (totals: any, columnDef:
const thousandSeparator = getValueFromParamsOrFormatterOptions('thousandSeparator', columnDef, grid, '');
const displayNegativeNumberWithParentheses = getValueFromParamsOrFormatterOptions('displayNegativeNumberWithParentheses', columnDef, grid, false);

if (val != null && !isNaN(+val)) {
if (val !== null && val !== undefined && !isNaN(+val)) {
const formattedNumber = formatNumber(val, minDecimal, maxDecimal, displayNegativeNumberWithParentheses, '', '', decimalSeparator, thousandSeparator);
return `${prefix}${formattedNumber}${suffix}`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const minTotalsFormatter: GroupTotalsFormatter = (totals: any, columnDef:
const thousandSeparator = getValueFromParamsOrFormatterOptions('thousandSeparator', columnDef, grid, '');
const displayNegativeNumberWithParentheses = getValueFromParamsOrFormatterOptions('displayNegativeNumberWithParentheses', columnDef, grid, false);

if (val != null && !isNaN(+val)) {
if (val !== null && val !== undefined && !isNaN(+val)) {
const formattedNumber = formatNumber(val, minDecimal, maxDecimal, displayNegativeNumberWithParentheses, '', '', decimalSeparator, thousandSeparator);
return `${prefix}${formattedNumber}${suffix}`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const sumTotalsBoldFormatter: GroupTotalsFormatter = (totals: any, column
const thousandSeparator = getValueFromParamsOrFormatterOptions('thousandSeparator', columnDef, grid, '');
const displayNegativeNumberWithParentheses = getValueFromParamsOrFormatterOptions('displayNegativeNumberWithParentheses', columnDef, grid, false);

if (val != null && !isNaN(+val)) {
if (val !== null && val !== undefined && !isNaN(+val)) {
const formattedNumber = formatNumber(val, minDecimal, maxDecimal, displayNegativeNumberWithParentheses, '', '', decimalSeparator, thousandSeparator);
return `<b>${prefix}${formattedNumber}${suffix}</b>`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const sumTotalsColoredFormatter: GroupTotalsFormatter = (totals: any, col
const thousandSeparator = getValueFromParamsOrFormatterOptions('thousandSeparator', columnDef, grid, '');
const displayNegativeNumberWithParentheses = getValueFromParamsOrFormatterOptions('displayNegativeNumberWithParentheses', columnDef, grid, false);

if (val != null && !isNaN(+val)) {
if (val !== null && val !== undefined && !isNaN(+val)) {
const colorStyle = (val >= 0) ? 'green' : 'red';
const formattedNumber = formatNumber(val, minDecimal, maxDecimal, displayNegativeNumberWithParentheses, '', '', decimalSeparator, thousandSeparator);
return `<span style="color:${colorStyle}">${prefix}${formattedNumber}${suffix}</span>`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const sumTotalsDollarBoldFormatter: GroupTotalsFormatter = (totals: any,
const thousandSeparator = getValueFromParamsOrFormatterOptions('thousandSeparator', columnDef, grid, '');
const displayNegativeNumberWithParentheses = getValueFromParamsOrFormatterOptions('displayNegativeNumberWithParentheses', columnDef, grid, false);

if (val != null && !isNaN(+val)) {
if (val !== null && val !== undefined && !isNaN(+val)) {
const formattedNumber = formatNumber(val, minDecimal, maxDecimal, displayNegativeNumberWithParentheses, '$', '', decimalSeparator, thousandSeparator);
return `<b>${prefix}${formattedNumber}${suffix}</b>`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const sumTotalsDollarColoredBoldFormatter: GroupTotalsFormatter = (totals
const thousandSeparator = getValueFromParamsOrFormatterOptions('thousandSeparator', columnDef, grid, '');
const displayNegativeNumberWithParentheses = getValueFromParamsOrFormatterOptions('displayNegativeNumberWithParentheses', columnDef, grid, false);

if (val != null && !isNaN(+val)) {
if (val !== null && val !== undefined && !isNaN(+val)) {
const colorStyle = (val >= 0) ? 'green' : 'red';
const formattedNumber = formatNumber(val, minDecimal, maxDecimal, displayNegativeNumberWithParentheses, '$', '', decimalSeparator, thousandSeparator);
return `<span style="color:${colorStyle}; font-weight: bold;">${prefix}${formattedNumber}${suffix}</span>`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const sumTotalsDollarColoredFormatter: GroupTotalsFormatter = (totals: an
const thousandSeparator = getValueFromParamsOrFormatterOptions('thousandSeparator', columnDef, grid, '');
const displayNegativeNumberWithParentheses = getValueFromParamsOrFormatterOptions('displayNegativeNumberWithParentheses', columnDef, grid, false);

if (val != null && !isNaN(+val)) {
if (val !== null && val !== undefined && !isNaN(+val)) {
const colorStyle = (val >= 0) ? 'green' : 'red';
const formattedNumber = formatNumber(val, minDecimal, maxDecimal, displayNegativeNumberWithParentheses, '$', '', decimalSeparator, thousandSeparator);
return `<span style="color:${colorStyle}">${prefix}${formattedNumber}${suffix}</span>`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const sumTotalsDollarFormatter: GroupTotalsFormatter = (totals: any, colu
const thousandSeparator = getValueFromParamsOrFormatterOptions('thousandSeparator', columnDef, grid, '');
const displayNegativeNumberWithParentheses = getValueFromParamsOrFormatterOptions('displayNegativeNumberWithParentheses', columnDef, grid, false);

if (val != null && !isNaN(+val)) {
if (val !== null && val !== undefined && !isNaN(+val)) {
const formattedNumber = formatNumber(val, minDecimal, maxDecimal, displayNegativeNumberWithParentheses, '$', '', decimalSeparator, thousandSeparator);
return `${prefix}${formattedNumber}${suffix}`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const sumTotalsFormatter: GroupTotalsFormatter = (totals: any, columnDef:
const thousandSeparator = getValueFromParamsOrFormatterOptions('thousandSeparator', columnDef, grid, '');
const displayNegativeNumberWithParentheses = getValueFromParamsOrFormatterOptions('displayNegativeNumberWithParentheses', columnDef, grid, false);

if (val != null && !isNaN(+val)) {
if (val !== null && val !== undefined && !isNaN(+val)) {
const formattedNumber = formatNumber(val, minDecimal, maxDecimal, displayNegativeNumberWithParentheses, '', '', decimalSeparator, thousandSeparator);
return `${prefix}${formattedNumber}${suffix}`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const myUppercaseFormatter: Formatter = (row, cell, value, columnDef, dataContex
const myUppercaseGroupTotalFormatter: GroupTotalsFormatter = (totals: any, columnDef: Column) => {
const field = columnDef.field || '';
const val = totals.sum && totals.sum[field];
if (val != null && !isNaN(+val)) {
if (val !== null && val !== undefined && !isNaN(+val)) {
return `Custom: ${val}`;
}
return '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,9 @@ export class ExcelExportService {
// loop through all the grid rows of data
for (let rowNumber = 0; rowNumber < lineCount; rowNumber++) {
const itemObj = this._dataView.getItem(rowNumber);
if (itemObj != null) {
if (itemObj) {
// Normal row (not grouped by anything) would have an ID which was predefined in the Grid Columns definition
if (itemObj[this.datasetIdName] != null) {
if (itemObj[this.datasetIdName] !== null && itemObj[this.datasetIdName] !== undefined) {
// get regular row item data
originalDaraArray.push(this.readRegularRowData(columns, rowNumber, itemObj));
} else if (this._hasGroupedItems && itemObj.__groupTotals === undefined) {
Expand Down
4 changes: 2 additions & 2 deletions src/app/modules/angular-slickgrid/services/export.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ export class ExportService {
// loop through all the grid rows of data
for (let rowNumber = 0; rowNumber < lineCount; rowNumber++) {
const itemObj = this._dataView.getItem(rowNumber);
if (itemObj != null) {
if (itemObj) {
// Normal row (not grouped by anything) would have an ID which was predefined in the Grid Columns definition
if (itemObj[this.datasetIdName] != null) {
if (itemObj[this.datasetIdName] !== null && itemObj[this.datasetIdName] !== undefined) {
// get regular row item data
outputDataStrings.push(this.readRegularRowData(columns, rowNumber, itemObj));
} else if (this._hasGroupedItems && itemObj.__groupTotals === undefined) {
Expand Down
2 changes: 1 addition & 1 deletion src/assets/lib/multiple-select/multiple-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@
}).off('keyup').on('keyup', function (e) {
// enter or space
// Avoid selecting/deselecting if no choices made
if (that.options.filterAcceptOnEnter && (e.which === 13 || e.which == 32) && that.$searchInput.val()) {
if (that.options.filterAcceptOnEnter && (e.which === 13 || e.which === 32) && that.$searchInput.val()) {
that.$selectAll.click();
that.close();
that.focus();
Expand Down

0 comments on commit c49f950

Please sign in to comment.