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

chore: upgrade lint tools #2720

Merged

Conversation

ChristianMurphy
Copy link
Member

@ChristianMurphy ChristianMurphy commented Nov 10, 2023

Checklist
Description of change
  • updates Node.js to latest long term support release
  • removes eslint-config-google which is deprecated by Google
  • add eslint recommended, sonarqube, and unicorn lint rules to improve potential error detection
  • manage both the root and uportal-webapp package file within a single npm workspace to better detect version conflicts and have a single lockfile
  • upgrade stylelint to latest major version, use new less recommended ruleset

📓 ⚠️ if/when this is merged, please squash merge to avoid unnecessary churn in files.

⚠️ a fair number of rules around JS best practice need to be disabled because Resource Server is applying YUI compressor, and YUI compressor does not recognize JavaScript syntax from the past 8 year (Anything ECMA2015 or newer).

Comment on lines -94 to -102
var data = {};

var persistPermissions = function (that, form) {
// construct an appropriate data object from the form
data.elementID = $(form)
.find('[name=nodeId]')
.val();
data.action = 'updatePermissions';
data.deletable = $(form.deletable).is(':checked');
data.movable = $(form.movable).is(':checked');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SonarQube caught this could be flattened

@@ -18,15 +18,15 @@
*/
var uportal = uportal || {};

(function($, fluid) {
(function ($, fluid) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prettier now adds a space between function and params

Comment on lines -99 to -100
if ($.browser.msie) {
if ($.browser.version === '7.0') {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these conditions were flattened

@@ -39,7 +39,7 @@ var up = up || {};
);

var tree = {children: []};
$(results).each(function(idx, result) {
$(results).each(function (index, result) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unicorn aims to have abbreviations like idx, msg, e, spelled out in clear English words.

@@ -312,19 +314,19 @@ var up = up || {};
onUpdatePermissions: null,
},
listeners: {
onUpdatePermissions: function(element, newPermissions) {
if (!newPermissions.movable) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conditions were reversed automatically to avoid negation


// add the portlet to the cached list
if (!that.state.portlets['portlet.' + portlet.id]) {
that.state.portlets.push(portlet);
that.state.portlets['portlet.' + portlet.id] =
that.state.portlets[that.state.portlets.length - 1];
that.state.portlets.at(-1);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

automatically changed to simpler way to access final element

@@ -30,32 +30,32 @@
* NOTE: Do not change the location of Bootstrap sources lightly; they must
* be included in the uPortal.war package.
*/
@import url("../../../../webjars/bootstrap/less/bootstrap.less");
@import "../../../../webjars/bootstrap/less/bootstrap.less";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

less does not require the url function for imports

@@ -606,18 +623,6 @@
}
}

.active {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.active was declared in two places this was manually moved to combine them

Comment on lines +106 to +130
/**
* Simple function to escape specific HTML characters so they aren't
* a problem. &, quote, and single quote are handled by jQuery so
* only need to deal with < and >
* @param {string} str - unescaped input
* @return {string} escaped output
*/
function htmlEscape(string_) {
return String(string_).replaceAll('<', '&lt;').replaceAll('>', '&gt;');
}

/**
* Helper method for making it a little easier to format the output in the menu
* @param {object} item A JavaScript Object containing the item values
* @return {string} Returns a formatted string that will be injected into the menu
*/
var formatOutput = function (item) {
return (
'<a><span class="autocomplete-header">' +
htmlEscape(item.title) +
'</span><br>' +
htmlEscape(item.desc) +
'</a>'
);
};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are pure functions, and were extracted up a level to avoid unnecessary reallocation.

updateCountdown = function() {
var now = new Date().getTime();
updateCountdown = function () {
var now = Date.now();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

automatically updated, same timestamp, but avoids instantiating a new class to generate it.

Copy link
Member

@bjagg bjagg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏅

@bjagg bjagg merged commit 2b03f4a into uPortal-Project:master Nov 10, 2023
18 checks passed
@ChristianMurphy ChristianMurphy deleted the chore/upgrade-lint-tools branch November 10, 2023 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants