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

Unify/modernize code with eslint - use let, drop Node 12 support #2584

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintrc.js
Expand Up @@ -91,7 +91,6 @@ module.exports = {
'guard-for-in': 'off', // refactor to "for of"
'no-restricted-globals': 'off',
'no-restricted-properties': 'off',
'no-var': 'off', // https://github.com/fomantic/Fomantic-UI/pull/2584
'one-var': 'off',
'prefer-const': 'off',
'prefer-exponentiation-operator': 'off',
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [12, 14, 16, 18, latest]
node-version: [14, 16, 18, latest]
steps:
- uses: actions/checkout@v3
- name: Setup Node.js ${{ matrix.node-version }}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -86,7 +86,7 @@
"stylelint-config-standard": "^29.0.0"
},
"engines": {
"node": ">=12",
"node": ">=14",
"npm": ">=6.14.8"
},
"title": "Fomantic UI",
Expand Down
50 changes: 25 additions & 25 deletions src/definitions/behaviors/api.js
Expand Up @@ -24,7 +24,7 @@
: globalThis;

$.fn.api = function (parameters) {
var
let
// use window context if none specified
$allModules = isFunction(this)
? $(window)
Expand All @@ -41,7 +41,7 @@
;

$allModules.each(function () {
var
let
settings = $.isPlainObject(parameters)
? $.extend(true, {}, $.fn.api.settings, parameters)
: $.extend({}, $.fn.api.settings),
Expand Down Expand Up @@ -109,7 +109,7 @@

bind: {
events: function () {
var
let
triggerEvent = module.get.event()
;
if (triggerEvent) {
Expand Down Expand Up @@ -140,7 +140,7 @@

read: {
cachedResponse: function (url) {
var
let
response
;
if (window.Storage === undefined) {
Expand Down Expand Up @@ -346,7 +346,7 @@

add: {
urlData: function (url, urlData) {
var
let
requiredVariables,
optionalVariables
;
Expand All @@ -357,7 +357,7 @@
if (requiredVariables) {
module.debug('Looking for required URL variables', requiredVariables);
$.each(requiredVariables, function (index, templatedString) {
var
let
// allow legacy {$var} style
variable = templatedString.indexOf('$') !== -1
? templatedString.slice(2, -1)
Expand Down Expand Up @@ -388,7 +388,7 @@
if (optionalVariables) {
module.debug('Looking for optional URL variables', requiredVariables);
$.each(optionalVariables, function (index, templatedString) {
var
let
// allow legacy {/$var} style
variable = templatedString.indexOf('$') !== -1
? templatedString.slice(3, -1)
Expand Down Expand Up @@ -419,7 +419,7 @@
return url;
},
formData: function (data) {
var
let
formData = {},
hasOtherData,
useFormDataApi = settings.serializeForm === 'formdata'
Expand All @@ -432,7 +432,7 @@
settings.processData = settings.processData !== undefined ? settings.processData : false;
settings.contentType = settings.contentType !== undefined ? settings.contentType : false;
} else {
var
let
formArray = $form.serializeArray(),
pushes = {},
pushValues = {},
Expand All @@ -452,7 +452,7 @@
if (!settings.regExp.validate.test(el.name)) {
return;
}
var
let
isCheckbox = $('[name="' + el.name + '"]', $form).attr('type') === 'checkbox',
floatValue = parseFloat(el.value),
value = (isCheckbox && el.value === 'on')
Expand All @@ -476,7 +476,7 @@
}

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

if (k === '' && !Array.isArray(value)) { // foo[]
value = build([], pushes[pushKey]++, value);
Expand Down Expand Up @@ -534,7 +534,7 @@
// nothing special
},
done: function (response, textStatus, xhr) {
var
let
context = this,
elapsedTime = Date.now() - requestStartTime,
timeLeft = settings.loadingDuration - elapsedTime,
Expand Down Expand Up @@ -563,7 +563,7 @@
}, timeLeft);
},
fail: function (xhr, status, httpMessage) {
var
let
context = this,
elapsedTime = Date.now() - requestStartTime,
timeLeft = settings.loadingDuration - elapsedTime
Expand Down Expand Up @@ -593,7 +593,7 @@
settings.onSuccess.call(context, response, $module, xhr);
},
complete: function (firstParameter, secondParameter) {
var
let
xhr,
response
;
Expand All @@ -609,7 +609,7 @@
settings.onComplete.call(context, response, $module, xhr);
},
fail: function (xhr, status, httpMessage) {
var
let
// pull response from xhr if available
response = module.get.responseFromXHR(xhr),
errorMessage = module.get.errorFromRequest(response, status, httpMessage)
Expand Down Expand Up @@ -658,7 +658,7 @@
},

mockedXHR: function () {
var
let
// xhr does not simulate these properties of xhr but must return them
textStatus = false,
status = false,
Expand Down Expand Up @@ -704,7 +704,7 @@
},

xhr: function () {
var
let
xhr
;
// ajax request promise
Expand Down Expand Up @@ -767,7 +767,7 @@
return module.xhr || false;
},
settings: function () {
var
let
runSettings
;
runSettings = settings.beforeSend.call($module, settings);
Expand Down Expand Up @@ -800,7 +800,7 @@
: $.extend(true, {}, settings);
},
urlEncodedValue: function (value) {
var
let
decodedValue = window.decodeURIComponent(value),
encodedValue = window.encodeURIComponent(value),
alreadyEncoded = decodedValue !== value
Expand All @@ -815,7 +815,7 @@
return encodedValue;
},
defaultData: function () {
var
let
data = {}
;
if (!isWindow(element)) {
Expand Down Expand Up @@ -877,7 +877,7 @@
},

abort: function () {
var
let
xhr = module.get.xhr()
;
if (xhr && xhr.state() !== 'resolved') {
Expand Down Expand Up @@ -943,7 +943,7 @@
},
performance: {
log: function (message) {
var
let
currentTime,
executionTime,
previousTime
Expand All @@ -964,7 +964,7 @@
module.performance.timer = setTimeout(module.performance.display, 500);
},
display: function () {
var
let
title = settings.name + ':',
totalTime = 0
;
Expand Down Expand Up @@ -992,7 +992,7 @@
},
},
invoke: function (query, passedArguments, context) {
var
let
object = instance,
maxDepth,
found,
Expand All @@ -1004,7 +1004,7 @@
query = query.split(/[ .]/);
maxDepth = query.length - 1;
$.each(query, function (depth, value) {
var camelCaseValue = depth !== maxDepth
let camelCaseValue = depth !== maxDepth
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
: query
;
Expand Down