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

Fix some lint warnings #1186

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"no-unsanitized"
],
"rules": {
"no-negated-condition": "warn",
"no-negated-condition": "error",
"no-unsanitized/method": [
"error",
{
Expand All @@ -76,13 +76,13 @@
}
}
],
"no-unused-vars": "warn",
"prefer-destructuring": "warn",
"unicorn/no-for-loop": "warn",
"unicorn/prefer-includes": "warn",
"unicorn/prefer-string-slice": "warn",
"no-unused-vars": "error",
"prefer-destructuring": "error",
"unicorn/no-for-loop": "error",
"unicorn/prefer-includes": "error",
"unicorn/prefer-string-slice": "error",
"unicorn/filename-case": "warn",
"unicorn/prefer-query-selector": "warn"
"unicorn/prefer-query-selector": "error"
}
},
"repository": {
Expand Down
25 changes: 12 additions & 13 deletions src/main/zapHomeFiles/hud/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Vue.component('modal', {
close() {
this.$emit('close');
},
afterLeave(element) {
afterLeave(_element) {
if (!app.keepShowing) {
app.backStack = [];
hideDisplayFrame();
Expand Down Expand Up @@ -402,13 +402,13 @@ Vue.component('http-message-modal', {
let header = '';
let body = '';

if (!this.response.isReadonly) {
header = this.response.header;
body = this.response.body;
} else {
if (this.response.isReadonly) {
method = this.request.method;
header = this.request.header;
body = this.request.body;
} else {
header = this.response.header;
body = this.response.body;
}

return {method, header, body};
Expand Down Expand Up @@ -529,7 +529,7 @@ Vue.component('history-message-modal', {
}, [channel.port2]);
},
ascanRequest() {
const request = this.request;
const {request} = this;
this.$emit('close');
navigator.serviceWorker.controller.postMessage(
{
Expand Down Expand Up @@ -582,7 +582,7 @@ Vue.component('ws-message-modal', {
},
computed: {
currentMessage() {
const payload = this.payload;
const {payload} = this;
return {payload};
}
}
Expand Down Expand Up @@ -736,10 +736,9 @@ Vue.component('site-tree-node', {
channel.port1.addEventListener('message', event => {
// Remove the ..loading.. child
Vue.set(treeNode.model, 'children', []);
for (let i = 0; i < event.data.childNodes.length; i++) {
const child = event.data.childNodes[i];
event.data.childNodes.forEach(child => {
treeNode.addChild(child.name, child.method, child.isLeaf, child.hrefId);
}
});
});

navigator.serviceWorker.controller.postMessage({
Expand All @@ -755,7 +754,7 @@ Vue.component('site-tree-node', {
if ((name.match(/\//g) || []).length > 2) {
// If there are more than 2 slashes just show last url element
// The first 2 slashes will be http(s)://...
name = name.substring(name.lastIndexOf('/') + 1);
name = name.slice(name.lastIndexOf('/') + 1);
}

if (isLeaf) {
Expand Down Expand Up @@ -921,8 +920,8 @@ document.addEventListener('DOMContentLoaded', () => {
});

navigator.serviceWorker.addEventListener('message', event => {
const action = event.data.action;
const config = event.data.config;
const {data: {action}} = event;
const {data: {config}} = event;
const port = event.ports[0];
let show;

Expand Down
26 changes: 14 additions & 12 deletions src/main/zapHomeFiles/hud/drawer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// App is the main Vue object controlling everything

let app;
const eventBus = new Vue();
let frameId = '';
Expand Down Expand Up @@ -55,7 +56,7 @@ Vue.component('history', {
return re.test(message.url);
}

return message.url.indexOf(self.filter) >= 0;
return message.url.includes(self.filter);
});
}
},
Expand All @@ -72,12 +73,12 @@ Vue.component('history', {
},
watch: {
regexEnabled() {
this.isRegExError = !this.regexEnabled ? false : this.isRegExError;
this.isRegExError = this.regexEnabled ? this.isRegExError : false;
},
filteredMessages() {
this.$nextTick(function () {
const visibleMessages = document.querySelectorAll('#history-messages .message-tr');
this.hiddenMessageCount = (!this.messages) ? 0 : this.messages.length - visibleMessages.length;
this.hiddenMessageCount = this.messages ? this.messages.length - visibleMessages.length : 0;
this.historyItemsFiltered();
});
}
Expand All @@ -104,7 +105,7 @@ Vue.component('history', {
if (this.messages.length > 0) {
const lastMessage = this.messages[this.messages.length - 1];
const lastid = 'message-tr-' + lastMessage.id;
const lastIdElement = document.getElementById(lastid);
const lastIdElement = document.querySelector('#' + lastid);

if (lastIdElement) {
lastIdElement.scrollIntoView({block: 'end', behavior: 'smooth'});
Expand Down Expand Up @@ -169,7 +170,7 @@ Vue.component('websockets', {
return re.test(message.messageSummary);
}

return message.messageSummary.indexOf(self.filter) >= 0;
return message.messageSummary.includes(self.filter);
});
}
},
Expand All @@ -186,12 +187,12 @@ Vue.component('websockets', {
},
watch: {
regexEnabled() {
this.isRegExError = !this.regexEnabled ? false : this.isRegExError;
this.isRegExError = this.regexEnabled ? this.isRegExError : false;
},
filteredMessages() {
this.$nextTick(function () {
const visibleMessages = document.querySelectorAll('#websockets-messages .message-tr');
this.hiddenMessageCount = (!this.messages) ? 0 : this.messages.length - visibleMessages.length;
this.hiddenMessageCount = this.messages ? this.messages.length - visibleMessages.length : 0;
this.websocketsItemsFiltered();
});
}
Expand Down Expand Up @@ -315,10 +316,10 @@ Vue.component('tabs', {
})
.catch(utils.errorHandler);

eventBus.$on('showTabs', data => {
eventBus.$on('showTabs', _data => {
this.tabsVisible = true;
});
eventBus.$on('hideTabs', data => {
eventBus.$on('hideTabs', _data => {
this.tabsVisible = false;
if (this.isOpen) {
this.closeDrawer();
Expand Down Expand Up @@ -431,7 +432,7 @@ Vue.component('drawer-button-showhide', {
showHud() {
this.isHudVisible = true;
localforage.setItem('settings.isHudVisible', true)
.then(function (value) {
.then(function (_value) {
this.icon = utils.getZapImagePath('radar.png');
parent.postMessage({tabId, frameId, action: 'showHudPanels'}, context.url);
eventBus.$emit('showTabs', {});
Expand All @@ -441,7 +442,7 @@ Vue.component('drawer-button-showhide', {
hideHud() {
this.isHudVisible = false;
localforage.setItem('settings.isHudVisible', false)
.then(function (value) {
.then(function (_value) {
this.icon = utils.getZapImagePath('radar-grey.png');
parent.postMessage({tabId, frameId, action: 'hideHudPanels'}, context.url);
eventBus.$emit('hideTabs', {});
Expand Down Expand Up @@ -477,6 +478,7 @@ document.addEventListener('DOMContentLoaded', () => {
tabId = parameters.get('tabId');

/* Vue app */
// eslint-disable-next-line no-unused-vars
app = new Vue({
i18n: I18n.i18n,
el: '#app',
Expand All @@ -485,7 +487,7 @@ document.addEventListener('DOMContentLoaded', () => {
});

navigator.serviceWorker.addEventListener('message', event => {
const action = event.data.action;
const {data: {action}} = event;
const port = event.ports[0];

switch (action) {
Expand Down
2 changes: 0 additions & 2 deletions src/main/zapHomeFiles/hud/management.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const ZAP_SHARED_SECRET = '<<ZAP_SHARED_SECRET>>';

let app;
let tabId = '';
let frameId = '';
const urlParameter = utils.getParameter(document.location.href, 'url');
const context = {
url: urlParameter,
Expand Down Expand Up @@ -56,7 +55,6 @@ function showTutorial() {
document.addEventListener('DOMContentLoaded', () => {
const parameters = new URL(document.location).searchParams;

frameId = parameters.get('frameId');
tabId = parameters.get('tabId');

app = new Vue({
Expand Down
1 change: 1 addition & 0 deletions src/main/zapHomeFiles/hud/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ document.addEventListener('DOMContentLoaded', () => {
window.name = panelKey;

// Initialize vue app
// eslint-disable-next-line no-unused-vars
app = new Vue({
i18n: I18n.i18n,
el: '#app',
Expand Down
3 changes: 2 additions & 1 deletion src/main/zapHomeFiles/hud/serviceworker.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function initWebSockets() {
self.dispatchEvent(ev);
} else if ('id' in jevent && 'response' in jevent) {
const pFunctions = webSocketCallbacks[jevent.id];
const response = jevent.response;
const {response} = jevent;
if ('code' in response && 'message' in response) {
// These always indicate a failure
const error = new Error(I18n.t('error_with_message', [response.message]));
Expand Down Expand Up @@ -234,6 +234,7 @@ self.addEventListener('error', utils.errorHandler);
self.addEventListener('hud.log', logHandler);
self.addEventListener('hud.backup', backupHandler);

// eslint-disable-next-line no-unused-vars
function registerForZapEvents(publisher) {
apiCall('event', 'register', publisher);
}
Expand Down
Loading