1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-04-26 12:10:45 +02:00

Enforcing eslint rule

This commit is contained in:
Max Guglielmi 2017-05-25 13:51:44 +10:00
parent 07355d7442
commit 11e15f0482
18 changed files with 36 additions and 35 deletions

View file

@ -6,6 +6,7 @@
"rules": {
"max-len": [2, 80, 2, {"ignoreUrls": true}],
"indent": [2, 4, {"SwitchCase": 1}],
"semi": ["error", "always"],
"no-trailing-spaces": 2,
"no-multi-spaces": 2,
"array-bracket-spacing": 2,

View file

@ -65,7 +65,7 @@
"script-loader": "^0.7.0",
"string-replace-webpack-plugin": "^0.0.5",
"sugar-date": "2.0.4",
"webpack": "^2.5.1",
"webpack": "^2.6.0",
"webpack-dev-server": "^2.4.5"
},
"dependencies": {},

View file

@ -19,4 +19,4 @@ export const has = (arr, val, caseSensitive) => {
}
}
return false;
}
};

View file

@ -18,7 +18,7 @@ export const getText = (node) => {
return trim(node.innerText);
}
return trim(node.textContent);
}
};
/**
* Returns the first text node contained in the supplied node
@ -32,7 +32,7 @@ export const getFirstTextNode = (node) => {
return n.data;
}
}
}
};
/**
* Creates an html element with given collection of attributes
@ -56,7 +56,7 @@ export const createElm = (...args) => {
}
}
return el;
}
};
/**
* Removes passed node from DOM
@ -87,7 +87,7 @@ export const hasClass = (ele, cls) => {
return ele.classList.contains(cls);
}
return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
}
};
/**
* Adds the specified class to the passed element
@ -110,7 +110,7 @@ export const addClass = (ele, cls) => {
else if (!hasClass(ele, cls)) {
ele.className += ' ' + cls;
}
}
};
/**
* Removes the specified class to the passed element
@ -128,7 +128,7 @@ export const removeClass = (ele, cls) => {
}
let reg = new RegExp('(\\s|^)' + cls + '(\\s|$)', 'g');
ele.className = ele.className.replace(reg, '');
}
};
/**
* Creates and returns an option element
@ -144,7 +144,7 @@ export const createOpt = (text, value, isSel) => {
createElm('option', ['value', value]);
opt.appendChild(createText(text));
return opt;
}
};
/**
* Creates and returns a checklist item
@ -168,7 +168,7 @@ export const createCheckItem = (id, chkValue, labelText) => {
li.label = label;
li.check = check;
return li;
}
};
/**
* Returns the element matching the supplied Id

View file

@ -101,7 +101,7 @@ export class DateType extends Feature {
* @returns {String} Locale code (ie: 'en-us')
*/
getLocale(colIndex) {
return this.getOptions(colIndex).locale || this.locale
return this.getOptions(colIndex).locale || this.locale;
}
/**

View file

@ -26,4 +26,4 @@ export const parse = (value, decimal = '.') => {
// This will fail silently
return !isNaN(unformatted) ? unformatted : 0;
}
};

View file

@ -15,7 +15,7 @@ export const ignoreCase = (a, b) => {
let x = a.toLowerCase();
let y = b.toLowerCase();
return x < y ? -1 : (x > y ? 1 : 0);
}
};
/**
* Compare function for sorting passed numbers in ascending manner
@ -63,8 +63,8 @@ export const sortNumberStr = (compareFn, decimal = ',') => {
let num1 = parseNb(numStr1, decimal);
let num2 = parseNb(numStr2, decimal);
return compareFn(num1, num2);
}
}
};
};
/**
* Curried compare function for sorting passed formatted dates in desired
@ -78,5 +78,5 @@ export const sortDateStr = (compareFn, locale = 'en-us') => {
let date1 = SugarDate.create(dateStr1, locale);
let date2 = SugarDate.create(dateStr2, locale);
return compareFn(date1, date2);
}
}
};
};

View file

@ -14,7 +14,7 @@ export const trim = (text) => {
return text.trim();
}
return text.replace(/^\s*|\s*$/g, '');
}
};
/**
* Checks if passed string is empty
@ -32,7 +32,7 @@ export const rgxEsc = (text) => {
let chars = /[-\/\\^$*+?.()|[\]{}]/g;
let escMatch = '\\$&';
return String(text).replace(chars, escMatch);
}
};
/**
* Returns passed string as lowercase if caseSensitive flag set false. By
@ -45,7 +45,7 @@ export const matchCase = (text, caseSensitive = false) => {
return text.toLowerCase();
}
return text;
}
};
/**
* Checks if passed data contains the searched term
@ -73,4 +73,4 @@ export const contains = (term, data, exactMatch = false, caseSensitive = false,
regexp = new RegExp(rgxEsc(term), modifier);
}
return regexp.test(data);
}
};

View file

@ -8,7 +8,7 @@ import {isEmpty as isEmptyString} from './string';
import {
isArray, isEmpty, isFn, isNumber, isObj, isString, isUndef, EMPTY_FN
} from './types';
import {parse as parseNb} from './number'
import {parse as parseNb} from './number';
import {root} from './root';
import {Emitter} from './emitter';

View file

@ -138,7 +138,7 @@
// setup
var clearActiveColumns = markActiveColumns.clearActiveColumns;
var hit = 0;
markActiveColumns.clearActiveColumns = function() { hit++ };
markActiveColumns.clearActiveColumns = function() { hit++; };
markActiveColumns.initialized = false;
// act

View file

@ -110,7 +110,7 @@ test('Cannot init if initialised', function() {
// setup
var processAll = altRows.processAll;
var hit = 0;
altRows.processAll = function() { hit++ };
altRows.processAll = function() { hit++; };
altRows.initialized = true;
// act
@ -126,7 +126,7 @@ test('Cannot processAll if not enabled', function() {
// setup
var setRowBg = altRows.setRowBg;
var hit = 0;
altRows.setRowBg = function() { hit++ };
altRows.setRowBg = function() { hit++; };
altRows.enabled = false;
// act
@ -142,7 +142,7 @@ test('Cannot setRowBg if not enabled', function() {
// setup
var removeRowBg = altRows.removeRowBg;
var hit = 0;
altRows.removeRowBg = function() { hit++ };
altRows.removeRowBg = function() { hit++; };
altRows.enabled = false;
// act
@ -171,7 +171,7 @@ test('Cannot destroy if not initialised', function() {
// setup
var getRowsNb = altRows.tf.getRowsNb;
var hit = 0;
altRows.tf.getRowsNb = function() { hit++ };
altRows.tf.getRowsNb = function() { hit++; };
altRows.initialized = false;
// act

View file

@ -21,7 +21,7 @@
test('Sanity checks', function() {
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.cellParser.cols.length, 1,
'Columns implementing cell parser')
'Columns implementing cell parser');
deepEqual(typeof tf.cellParser.parse, 'function', 'Parse function');
deepEqual(
tf.getFilterElement(0).nodeName, 'SELECT', 'Expected filter type');
@ -60,7 +60,7 @@
tf.cellParser.cols = [];
tf.cellParser.parse = function() {
hit++;
}
};
// act
tf.getCellValue(cell);

View file

@ -41,7 +41,7 @@ test('Can refresh all drop-down filters', function() {
tf.clearFilters();
var build = checkList.build;
var hit = 0;
checkList.build = function() { hit++ };
checkList.build = function() { hit++; };
//act
checkList.refreshAll();

View file

@ -41,7 +41,7 @@ test('Can refresh all drop-down filters', function() {
tf.clearFilters();
var build = dropdown.build;
var hit = 0;
dropdown.build = function() { hit++ };
dropdown.build = function() { hit++; };
//act
dropdown.refreshAll();

View file

@ -46,7 +46,7 @@ test('Can parse a URL hash', function() {
// URL-encoded version of:
// #{"page":2,"page_length":4,"col_2":{"flt":">500"}}
var hashStr = '#%7B%22page%22%3A2%2C%22page_length%22%3A4'+
'%2C%22col_2%22%3A%7B%22flt%22%3A%22%3E500%22%7D%7D'
'%2C%22col_2%22%3A%7B%22flt%22%3A%22%3E500%22%7D%7D';
// act
var result = hash.parse(hashStr);

View file

@ -18,7 +18,7 @@ test('Does not init if initialised', function() {
var hit = 0;
loader.show = function() {
hit++;
}
};
// act
loader.init();

View file

@ -3,7 +3,7 @@
module('TableFilter with no rows');
test('throws when no rows', function() {
throws(
function() { new TableFilter('demo') },
function() { new TableFilter('demo'); },
Error,
'Throws Error when DOM table does not contain rows'
);

View file

@ -78,7 +78,7 @@
// setup
var importFile = tf1.import;
var hit = 0;
tf1.import = function() { hit++ };
tf1.import = function() { hit++; };
tf1.initialized = true;
// act