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

feat(lint): fix various eslint rules #2607

Merged
merged 60 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
80df463
strictly autofix no-var for non src/* files only
mvorisek Dec 7, 2022
7bd2e54
simplify cond
mvorisek Dec 11, 2022
117dc67
fix "configConst" and mutating imported config
mvorisek Dec 11, 2022
8afdfda
Revert "revert tasks/ changes"
mvorisek Dec 11, 2022
ca4ba59
Merge remote-tracking branch 'fomantic/develop' into airbnb_part2
mvorisek Dec 11, 2022
4889d17
Merge branch 'develop' into airbnb_part2
mvorisek Dec 12, 2022
23de6fa
fix config order
mvorisek Dec 12, 2022
d2e3f06
strictly autofix all rare errors
mvorisek Dec 7, 2022
836aef7
fix all rare errors manually
mvorisek Dec 7, 2022
62b670c
replace typeof [=!] to strict cmp with regex
mvorisek Dec 7, 2022
804f6cc
replace remaining manually
mvorisek Dec 7, 2022
43c0b27
strictly autofix unicorn/no-typeof-undefined
mvorisek Dec 7, 2022
db05c68
fix remaining 'undefined' manually
mvorisek Dec 7, 2022
c4c6954
fix eqeqeq for xxx.Math == Math using regex
mvorisek Dec 7, 2022
b9b04d3
strictly autofix unicorn/better-regex
mvorisek Dec 7, 2022
371f40e
strictly autofix unicorn/explicit-length-check
mvorisek Dec 7, 2022
efe9c2e
fix remaining manually
mvorisek Dec 7, 2022
3e65cfb
fix no-useless-concat manually
mvorisek Dec 7, 2022
67ef972
fix no-useless-escape manually
mvorisek Dec 12, 2022
a42f862
fix radix manually
mvorisek Dec 12, 2022
6020e7d
Merge branch 'develop' into airbnb_part4
mvorisek Dec 12, 2022
425985b
Merge branch 'airbnb_part4' into airbnb_part5
mvorisek Dec 12, 2022
3a39ea3
fix no-multi-assign manually
mvorisek Dec 7, 2022
727aa7c
fix no-else-return semimanually
mvorisek Dec 7, 2022
ff19171
fix unicorn/consistent-function-scoping manually
mvorisek Dec 7, 2022
7e84d7a
strictly autofix unicorn/prefer-regexp-test
mvorisek Dec 7, 2022
62b60b9
fix no-mixed-operators manually
mvorisek Dec 7, 2022
ed14a39
fix unicorn/prefer-logical-operator-over-ternary manually
mvorisek Dec 7, 2022
e3b1ebf
fix import/extensions manually
mvorisek Dec 7, 2022
48fbdee
fix import/no-dynamic-require manually
mvorisek Dec 7, 2022
2fe12f4
fix unicorn/prefer-ternary semimanually
mvorisek Dec 7, 2022
9fc3d09
Merge branch 'develop'
mvorisek Dec 12, 2022
0e096f8
Merge branch 'airbnb_part5' into airbnb_part6
mvorisek Dec 12, 2022
c607d50
fix possibly undeclared variable undefined check
mvorisek Dec 12, 2022
89397a2
Merge branch 'airbnb_part5' into airbnb_part6
mvorisek Dec 12, 2022
624d047
strictly autofix unicorn/prefer-date-now
mvorisek Dec 7, 2022
a693f80
Merge branch 'develop' into fui_2_9_airbnb_ws
mvorisek Dec 12, 2022
5fa654e
strictly autofix unicorn/escape-case
mvorisek Dec 7, 2022
2d7b56e
strictly autofix unicorn/no-hex-escape
mvorisek Dec 7, 2022
f3653b3
fix unicorn/empty-brace-spaces semimanually
mvorisek Dec 7, 2022
ebf6edb
fix no-empty manually
mvorisek Dec 7, 2022
b8e66aa
fix no-bitwise manually
mvorisek Dec 7, 2022
9721340
fix no-path-concat manually
mvorisek Dec 7, 2022
8608481
fix unicorn/prefer-default-parameters manually
mvorisek Dec 7, 2022
ae1e341
fix unicorn/no-useless-undefined manually
mvorisek Dec 7, 2022
7facc2e
fix no-new-func
mvorisek Dec 7, 2022
99d4803
fix no-unused-expressions manually
mvorisek Dec 7, 2022
a25bb62
fix no-labels manually
mvorisek Dec 7, 2022
c11e248
fix no-cond-assign manually
mvorisek Dec 7, 2022
c8d3bd4
fix unicorn/new-for-builtins
mvorisek Dec 7, 2022
d5da45e
fix unicorn/prefer-switch manually
mvorisek Dec 7, 2022
83b0444
fix no-loop-func
mvorisek Dec 7, 2022
4ce51cc
fix no-prototype-builtins manually
mvorisek Dec 7, 2022
2834c29
fix no-self-assign manually
mvorisek Dec 7, 2022
ad1341b
strictly autofix unicorn/no-instanceof-array
mvorisek Dec 7, 2022
cfae4bd
fix unicorn/no-process-exit manually
mvorisek Dec 7, 2022
9f7583c
fix unicorn/no-useless-switch-case manually
mvorisek Dec 7, 2022
1d62693
ignore unicorn/prefer-array-find
mvorisek Dec 7, 2022
475d0a7
strictly autofix unicorn/prefer-native-coercion-functions
mvorisek Dec 7, 2022
d1a529b
fix do not use useless undefined
mvorisek Dec 12, 2022
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
23 changes: 1 addition & 22 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ module.exports = {
'unicorn/no-null': 'off',
'unicorn/no-this-assignment': 'off',
'unicorn/numeric-separators-style': 'off',
'unicorn/prefer-array-find': 'off',
'unicorn/prefer-array-some': 'off', // https://github.com/sindresorhus/eslint-plugin-unicorn/issues/2007
'unicorn/prefer-module': 'off',
'unicorn/prevent-abbreviations': 'off',
Expand Down Expand Up @@ -118,32 +119,10 @@ module.exports = {
'unicorn/no-nested-ternary': 'off', // about 80 errors (except 14 nested ternary operators autofixable)

// TODO
'no-bitwise': 'off',
'no-cond-assign': 'off',
'no-empty': 'off',
'no-labels': 'off',
'no-loop-func': 'off',
'no-new-func': 'off',
'no-path-concat': 'off',
'no-prototype-builtins': 'off',
'no-return-assign': 'off',
'no-self-assign': 'off',
'no-shadow-restricted-names': 'off',
'no-unused-expressions': 'off',
'no-use-before-define': 'off',
'unicorn/empty-brace-spaces': 'off',
'unicorn/escape-case': 'off',
'unicorn/new-for-builtins': 'off',
'unicorn/no-hex-escape': 'off',
'unicorn/no-instanceof-array': 'off',
'unicorn/no-process-exit': 'off',
'unicorn/no-useless-switch-case': 'off',
'unicorn/no-useless-undefined': 'off',
'unicorn/prefer-array-find': 'off',
'unicorn/prefer-default-parameters': 'off',
'unicorn/prefer-native-coercion-functions': 'off',
'unicorn/prefer-negative-index': 'off',
'unicorn/prefer-switch': 'off',
},
reportUnusedDisableDirectives: true,
globals: {
Expand Down
2 changes: 1 addition & 1 deletion scripts/nightly-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const getNightlyVersion = async function () {
actions.setOutput('shouldPublish', false);

console.log('No new commits since last publish. Exiting.');
process.exit(0);
process.exit(0); // eslint-disable-line unicorn/no-process-exit

return;
}
Expand Down
9 changes: 4 additions & 5 deletions src/definitions/behaviors/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,6 @@
? floatValue
: (el.value === 'false' ? false : el.value)),
nameKeys = el.name.match(settings.regExp.key) || [],
k,
pushKey = el.name.replace(/\[]$/, '')
;
if (!(pushKey in pushes)) {
Expand All @@ -476,7 +475,9 @@
value = pushValues[pushKey];
}

while ((k = nameKeys.pop()) !== undefined) {
while (nameKeys.length > 0) {
var k = nameKeys.pop();

if (k == '' && !Array.isArray(value)) { // foo[]
value = build([], pushes[pushKey]++, value);
} else if (settings.regExp.fixed.test(k)) { // foo[n]
Expand Down Expand Up @@ -820,9 +821,7 @@
if (!isWindow(element)) {
if (module.is.input()) {
data.value = $module.val();
} else if (module.is.form()) {

} else {
} else if (!module.is.form()) {
data.text = $module.text();
}
}
Expand Down
69 changes: 48 additions & 21 deletions src/definitions/behaviors/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@
},

attachEvents: function (selector, action) {
action = action || 'submit';
if (!action) {
action = 'submit';
}

$(selector).on('click' + eventNamespace, function (event) {
module[action]();
event.preventDefault();
Expand Down Expand Up @@ -283,7 +286,7 @@

$el.data(settings.metadata.isDirty, isDirty);

formIsDirty |= isDirty;
formIsDirty = formIsDirty || isDirty;
});

if (formIsDirty) {
Expand Down Expand Up @@ -618,16 +621,20 @@
module.verbose('Finding field with identifier', identifier);
identifier = module.escape.string(identifier);
var t;
if ((t = $field.filter('#' + identifier)).length > 0) {
t = $field.filter('#' + identifier);
if (t.length > 0) {
return t;
}
if ((t = $field.filter('[name="' + identifier + '"]')).length > 0) {
t = $field.filter('[name="' + identifier + '"]');
if (t.length > 0) {
return t;
}
if ((t = $field.filter('[name="' + identifier + '[]"]')).length > 0) {
t = $field.filter('[name="' + identifier + '[]"]');
if (t.length > 0) {
return t;
}
if ((t = $field.filter('[data-' + metadata.validate + '="' + identifier + '"]')).length > 0) {
t = $field.filter('[data-' + metadata.validate + '="' + identifier + '"]');
if (t.length > 0) {
return t;
}
module.error(error.noField.replace('{identifier}', identifier));
Expand Down Expand Up @@ -1866,14 +1873,24 @@
matchingValue,
matchingElement
;
if ((matchingElement = $module.find('[data-validate="' + identifier + '"]')).length > 0) {
matchingValue = matchingElement.val();
} else if ((matchingElement = $module.find('#' + identifier)).length > 0) {
matchingElement = $module.find('[data-validate="' + identifier + '"]');
if (matchingElement.length > 0) {
matchingValue = matchingElement.val();
} else if ((matchingElement = $module.find('[name="' + identifier + '"]')).length > 0) {
matchingValue = matchingElement.val();
} else if ((matchingElement = $module.find('[name="' + identifier + '[]"]')).length > 0) {
matchingValue = matchingElement;
} else {
matchingElement = $module.find('#' + identifier);
if (matchingElement.length > 0) {
matchingValue = matchingElement.val();
} else {
matchingElement = $module.find('[name="' + identifier + '"]');
if (matchingElement.length > 0) {
matchingValue = matchingElement.val();
} else {
matchingElement = $module.find('[name="' + identifier + '[]"]');
if (matchingElement.length > 0) {
matchingValue = matchingElement;
}
}
}
}

return (matchingValue !== undefined)
Expand All @@ -1888,14 +1905,24 @@
matchingValue,
matchingElement
;
if ((matchingElement = $module.find('[data-validate="' + identifier + '"]')).length > 0) {
matchingValue = matchingElement.val();
} else if ((matchingElement = $module.find('#' + identifier)).length > 0) {
matchingValue = matchingElement.val();
} else if ((matchingElement = $module.find('[name="' + identifier + '"]')).length > 0) {
matchingElement = $module.find('[data-validate="' + identifier + '"]');
if (matchingElement.length > 0) {
matchingValue = matchingElement.val();
} else if ((matchingElement = $module.find('[name="' + identifier + '[]"]')).length > 0) {
matchingValue = matchingElement;
} else {
matchingElement = $module.find('#' + identifier);
if (matchingElement.length > 0) {
matchingValue = matchingElement.val();
} else {
matchingElement = $module.find('[name="' + identifier + '"]');
if (matchingElement.length > 0) {
matchingValue = matchingElement.val();
} else {
matchingElement = $module.find('[name="' + identifier + '[]"]');
if (matchingElement.length > 0) {
matchingValue = matchingElement;
}
}
}
}

return (matchingValue !== undefined)
Expand Down Expand Up @@ -2005,7 +2032,7 @@
;
while (length--) {
sum += producedValue[multiple][parseInt(cardNumber.charAt(length), 10)];
multiple ^= 1;
multiple ^= 1; // eslint-disable-line no-bitwise
}

return (sum % 10 === 0 && sum > 0);
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/behaviors/visibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
},

precache: function (images, callback) {
if (!(images instanceof Array)) {
if (!(Array.isArray(images))) {
images = [images];
}
var
Expand Down
97 changes: 53 additions & 44 deletions src/definitions/modules/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,38 +643,51 @@

if (module.popup('is visible')) {
var mode = module.get.mode();
if (keyCode === 37 || keyCode === 38 || keyCode === 39 || keyCode === 40) {
switch (keyCode) {
// arrow keys
var bigIncrement = mode === 'day' ? 7 : mode === 'hour' ? 4 : mode === 'minute' ? timeGap.column : 3;
var increment = keyCode === 37 ? -1 : keyCode === 38 ? -bigIncrement : keyCode == 39 ? 1 : bigIncrement;
increment *= mode === 'minute' ? settings.minTimeGap : 1;
var focusDate = module.get.focusDate() || module.get.date() || new Date();
var year = focusDate.getFullYear() + (mode === 'year' ? increment : 0);
var month = focusDate.getMonth() + (mode === 'month' ? increment : 0);
var day = focusDate.getDate() + (mode === 'day' ? increment : 0);
var hour = focusDate.getHours() + (mode === 'hour' ? increment : 0);
var minute = focusDate.getMinutes() + (mode === 'minute' ? increment : 0);
var newFocusDate = new Date(year, month, day, hour, minute);
if (settings.type === 'time') {
newFocusDate = module.helper.mergeDateTime(focusDate, newFocusDate);
}
if (module.helper.isDateInRange(newFocusDate, mode)) {
module.set.focusDate(newFocusDate);
case 37:
case 38:
case 39:
case 40: {
var bigIncrement = mode === 'day' ? 7 : mode === 'hour' ? 4 : mode === 'minute' ? timeGap.column : 3;
var increment = keyCode === 37 ? -1 : keyCode === 38 ? -bigIncrement : keyCode == 39 ? 1 : bigIncrement;
increment *= mode === 'minute' ? settings.minTimeGap : 1;
var focusDate = module.get.focusDate() || module.get.date() || new Date();
var year = focusDate.getFullYear() + (mode === 'year' ? increment : 0);
var month = focusDate.getMonth() + (mode === 'month' ? increment : 0);
var day = focusDate.getDate() + (mode === 'day' ? increment : 0);
var hour = focusDate.getHours() + (mode === 'hour' ? increment : 0);
var minute = focusDate.getMinutes() + (mode === 'minute' ? increment : 0);
var newFocusDate = new Date(year, month, day, hour, minute);
if (settings.type === 'time') {
newFocusDate = module.helper.mergeDateTime(focusDate, newFocusDate);
}
if (module.helper.isDateInRange(newFocusDate, mode)) {
module.set.focusDate(newFocusDate);
}

break;
}
} else if (keyCode === 13) {
// enter
var date = module.get.focusDate();
if (date && !settings.isDisabled(date, mode) && !module.helper.isDisabled(date, mode) && module.helper.isEnabled(date, mode)) {
if (settings.onSelect.call(element, date, module.get.mode()) !== false) {
module.selectDate(date);
// enter key
case 13: {
var date = module.get.focusDate();
if (date && !settings.isDisabled(date, mode) && !module.helper.isDisabled(date, mode) && module.helper.isEnabled(date, mode)) {
if (settings.onSelect.call(element, date, module.get.mode()) !== false) {
module.selectDate(date);
}
}
// disable form submission:
event.preventDefault();
event.stopPropagation();

break;
}
// disable form submission:
event.preventDefault();
event.stopPropagation();
} else if (keyCode === 27) {
module.popup('hide');
event.stopPropagation();
// escape key
case 27:
module.popup('hide');
event.stopPropagation();

break;
}
}

Expand Down Expand Up @@ -1320,7 +1333,10 @@
return date;
},
dateDiff: function (date1, date2, mode) {
mode = mode || 'day';
if (!mode) {
mode = 'day';
}

var isTimeOnly = settings.type === 'time';
var isYear = mode === 'year';
var isYearOrMonth = isYear || mode === 'month';
Expand Down Expand Up @@ -1643,8 +1659,7 @@
today: function (settings) {
return settings.type === 'date' ? settings.text.today : settings.text.now;
},
cell: function (cell, date, cellOptions) {
},
cell: function (cell, date, cellOptions) {},
},

parser: {
Expand Down Expand Up @@ -1684,7 +1699,7 @@
month = -1,
year = -1
;
var isAm = undefined;
var isAm;

var isTimeOnly = settings.type === 'time';
var isDateOnly = settings.type.indexOf('time') < 0;
Expand Down Expand Up @@ -1897,28 +1912,22 @@
},

// callback when date changes
onChange: function (date, text, mode) {
},
onChange: function (date, text, mode) {},

// callback before show animation, return false to prevent show
onShow: function () {
},
onShow: function () {},

// callback after show animation
onVisible: function () {
},
onVisible: function () {},

// callback before hide animation, return false to prevent hide
onHide: function () {
},
onHide: function () {},

// callback after hide animation
onHidden: function () {
},
onHidden: function () {},

// callback before item is selected, return false to prevent selection
onSelect: function (date, mode) {
},
onSelect: function (date, mode) {},

// is the given date disabled?
isDisabled: function (date, mode) {
Expand Down
17 changes: 10 additions & 7 deletions src/definitions/modules/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -967,17 +967,22 @@
if (queryLength === termLength) {
return (query === term);
}
search: for (var characterIndex = 0, nextCharacterIndex = 0; characterIndex < queryLength; characterIndex++) {
for (var characterIndex = 0, nextCharacterIndex = 0; characterIndex < queryLength; characterIndex++) {
var
continueSearch = false,
queryCharacter = query.charCodeAt(characterIndex)
;
while (nextCharacterIndex < termLength) {
if (term.charCodeAt(nextCharacterIndex++) === queryCharacter) {
continue search;
continueSearch = true;

break;
}
}

return false;
if (!continueSearch) {
return false;
}
}

return true;
Expand Down Expand Up @@ -2122,9 +2127,7 @@
return;
}
if (isMultiple) {
if ($.inArray(module.escape.htmlEntities(String(optionValue)), value.map(function (v) {
return String(v);
})) !== -1) {
if ($.inArray(module.escape.htmlEntities(String(optionValue)), value.map(String)) !== -1) {
$selectedItem = ($selectedItem)
? $selectedItem.add($choice)
: $choice;
Expand Down Expand Up @@ -3206,7 +3209,7 @@
}
},
diacritics: function (text) {
return settings.ignoreDiacritics ? text.normalize('NFD').replace(/[\u0300-\u036f]/g, '') : text;
lubber-de marked this conversation as resolved.
Show resolved Hide resolved
return settings.ignoreDiacritics ? text.normalize('NFD').replace(/[\u0300-\u036F]/g, '') : text;
},
},

Expand Down
Loading