Skip to content

chore: upgrade lint tools#2720

Merged
bjagg merged 8 commits into
uPortal-Project:masterfrom
ChristianMurphy:chore/upgrade-lint-tools
Nov 10, 2023
Merged

chore: upgrade lint tools#2720
bjagg merged 8 commits into
uPortal-Project:masterfrom
ChristianMurphy:chore/upgrade-lint-tools

Conversation

@ChristianMurphy

@ChristianMurphy ChristianMurphy commented Nov 10, 2023

Copy link
Copy Markdown
Member
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
Copy Markdown
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

var uportal = uportal || {};

(function($, fluid) {
(function ($, fluid) {

Copy link
Copy Markdown
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
Copy Markdown
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


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

Copy link
Copy Markdown
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.

},
listeners: {
onUpdatePermissions: function(element, newPermissions) {
if (!newPermissions.movable) {

Copy link
Copy Markdown
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

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
Copy Markdown
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

* be included in the uPortal.war package.
*/
@import url("../../../../webjars/bootstrap/less/bootstrap.less");
@import "../../../../webjars/bootstrap/less/bootstrap.less";

Copy link
Copy Markdown
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

}
}

.active {

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@ChristianMurphy ChristianMurphy force-pushed the chore/upgrade-lint-tools branch from c6b710f to c001b13 Compare November 10, 2023 18:52
@ChristianMurphy ChristianMurphy requested a review from a team November 10, 2023 22:50

@bjagg bjagg left a comment

Copy link
Copy Markdown
Member

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
@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.

2 participants