1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-06 08:33:15 +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": { "rules": {
"max-len": [2, 80, 2, {"ignoreUrls": true}], "max-len": [2, 80, 2, {"ignoreUrls": true}],
"indent": [2, 4, {"SwitchCase": 1}], "indent": [2, 4, {"SwitchCase": 1}],
"semi": ["error", "always"],
"no-trailing-spaces": 2, "no-trailing-spaces": 2,
"no-multi-spaces": 2, "no-multi-spaces": 2,
"array-bracket-spacing": 2, "array-bracket-spacing": 2,

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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