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] eslint warnings #1133

Merged
merged 5 commits into from
Jan 20, 2024
Merged
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
4 changes: 2 additions & 2 deletions pos_access_right/static/src/js/ActionpadWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ odoo.define("pos_access_right.ActionpadWidget", function (require) {
const Registries = require("point_of_sale.Registries");
const ActionpadWidget = require("point_of_sale.ActionpadWidget");

const PosActionpadWidget = (ActionpadWidget) =>
class extends ActionpadWidget {
const PosActionpadWidget = (OriginalActionpadWidget) =>
class extends OriginalActionpadWidget {
get hasPaymentControlRights() {
return this.env.pos.user.hasGroupPayment;
}
Expand Down
4 changes: 2 additions & 2 deletions pos_access_right/static/src/js/NumpadWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ odoo.define("pos_access_right.NumpadWidget", function (require) {
const Registries = require("point_of_sale.Registries");
const NumpadWidget = require("point_of_sale.NumpadWidget");

const PosNumpadWidget = (NumpadWidget) =>
class extends NumpadWidget {
const PosNumpadWidget = (OriginalNumpadWidget) =>
class extends OriginalNumpadWidget {
get hasManualDiscount() {
const res = super.hasManualDiscount;
if (res) {
Expand Down
4 changes: 2 additions & 2 deletions pos_access_right/static/src/js/TicketScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ odoo.define("pos_access_right.TicketScreen", function (require) {
const Registries = require("point_of_sale.Registries");
const TicketScreen = require("point_of_sale.TicketScreen");

const PosTicketScreen = (TicketScreen) =>
class extends TicketScreen {
const PosTicketScreen = (OriginalTicketScreen) =>
class extends OriginalTicketScreen {
get hasNewOrdersControlRights() {
return this.env.pos.user.hasGroupMultiOrder;
}
Expand Down
4 changes: 2 additions & 2 deletions pos_escpos_status/static/src/js/ProxyStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ odoo.define("pos_escpos_status.ProxyStatus", function (require) {
var Registries = require("point_of_sale.Registries");
var ProxyStatus = require("point_of_sale.ProxyStatus");

const EscposProxyStatus = (ProxyStatus) =>
class EscposProxyStatus extends ProxyStatus {
const EscposProxyStatus = (OriginalProxyStatus) =>
class extends OriginalProxyStatus {
_setStatus(newStatus) {
if (newStatus.drivers.escpos) {
newStatus.drivers.printer = newStatus.drivers.escpos;
Expand Down
4 changes: 2 additions & 2 deletions pos_financial_risk/static/src/js/PaymentScreen.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import PaymentScreen from "point_of_sale.PaymentScreen";
import Registries from "point_of_sale.Registries";

export const PaymentScreenRisk = (PaymentScreen) =>
class PaymentScreenRisk extends PaymentScreen {
export const PaymentScreenRisk = (OriginalPaymentScreen) =>
class extends OriginalPaymentScreen {
setup() {
super.setup();
this.paymentMethodsFromConfigBase = this.payment_methods_from_config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ odoo.define("pos_global_discount_in_line.GlobalLineDiscount", function (require)
const DiscountButton = require("pos_discount.DiscountButton");
const Registries = require("point_of_sale.Registries");

const GlobalLineDiscount = (DiscountButton) =>
class extends DiscountButton {
const GlobalLineDiscount = (OriginalDiscountButton) =>
class extends OriginalDiscountButton {
async onClick() {
// Replaced to remove rounding
var self = this;
Expand Down
4 changes: 2 additions & 2 deletions pos_lot_barcode/static/src/js/Popups/EditListPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ odoo.define("pos_lot_barcode.EditListPopup", function (require) {
const Registries = require("point_of_sale.Registries");
const {useBarcodeReader} = require("point_of_sale.custom_hooks");

const PosLotBarcodeEditListPopup = (EditListPopup) =>
class extends EditListPopup {
const PosLotBarcodeEditListPopup = (OriginalEditListPopup) =>
class extends OriginalEditListPopup {
setup() {
super.setup();
useBarcodeReader({
Expand Down
4 changes: 2 additions & 2 deletions pos_lot_barcode/static/src/js/Screens/ProductScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ odoo.define("pos_lot_barcode.ProductScreen", function (require) {
const {isConnectionError} = require("point_of_sale.utils");
const {_lt} = require("@web/core/l10n/translation");

const PosLotBarcodeProductScreen = (ProductScreen) =>
class extends ProductScreen {
const PosLotBarcodeProductScreen = (OriginalProductScreen) =>
class extends OriginalProductScreen {
setup() {
super.setup();
this.scan_lots_active = true;
Expand Down
4 changes: 2 additions & 2 deletions pos_lot_selection/static/src/js/EditListPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ odoo.define("pos_lot_selection.EditListPopup", function (require) {
const EditListPopup = require("point_of_sale.EditListPopup");
const Registries = require("point_of_sale.Registries");

const LotSelectEditListPopup = (EditListPopup) =>
class extends EditListPopup {
const LotSelectEditListPopup = (OriginalEditListPopup) =>
class extends OriginalEditListPopup {
setup() {
super.setup();
if (this.props.title === this.env._t("Lot/Serial Number(s) Required")) {
Expand Down
4 changes: 2 additions & 2 deletions pos_lot_selection/static/src/js/OrderWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ odoo.define("pos_lot_selection.CustomOrderWidget", function (require) {
const Registries = require("point_of_sale.Registries");
const OrderWidget = require("point_of_sale.OrderWidget");

const CustomOrderWidget = (OrderWidget) =>
class extends OrderWidget {
const CustomOrderWidget = (OriginalOrderWidget) =>
class extends OriginalOrderWidget {
/**
* @override
*/
Expand Down
4 changes: 2 additions & 2 deletions pos_lot_selection/static/src/js/ProductScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ odoo.define("pos_lot_selection.ProductScreen", function (require) {
const ProductScreen = require("point_of_sale.ProductScreen");
const Registries = require("point_of_sale.Registries");

const PosLotSaleProductScreen = (ProductScreen) =>
class extends ProductScreen {
const PosLotSaleProductScreen = (OriginalProductScreen) =>
class extends OriginalProductScreen {
/**
* @override
*/
Expand Down
4 changes: 2 additions & 2 deletions pos_lot_selection/static/src/js/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ odoo.define("pos_lot_selection.models", function (require) {
const {PosGlobalState} = require("point_of_sale.models");
const Registries = require("point_of_sale.Registries");

const LotSelectPosGlobalState = (PosGlobalState) =>
class extends PosGlobalState {
const LotSelectPosGlobalState = (OriginalPosGlobalState) =>
class extends OriginalPosGlobalState {
async getProductLots(product) {
try {
return await this.env.services.rpc(
Expand Down
8 changes: 4 additions & 4 deletions pos_margin/static/src/js/models.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import field_utils from "web.field_utils";
// Overload models.Order
// /////////////////////////////

const OrderMargin = (Order) =>
class extends Order {
const OrderMargin = (OriginalOrder) =>
class extends OriginalOrder {
get_margin() {
return this.get_orderlines().reduce(
(margin, line) => margin + line.get_margin(),
Expand All @@ -35,8 +35,8 @@ Registries.Model.extend(Order, OrderMargin);
// /////////////////////////////
// Overload models.OrderLine
// /////////////////////////////
const OrderLineMargin = (Orderline) =>
class extends Orderline {
const OrderLineMargin = (OriginalOrderline) =>
class extends OriginalOrderline {
get_purchase_price() {
// Overload the function to use another field that the default standard_price
return this.product.standard_price;
Expand Down
4 changes: 2 additions & 2 deletions pos_order_remove_line/static/src/js/orderline.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import Orderline from "point_of_sale.Orderline";
import Registries from "point_of_sale.Registries";

const PosOrderline = (Orderline) =>
class extends Orderline {
const PosOrderline = (OriginalOrderline) =>
class extends OriginalOrderline {
async removeLine(ev) {
ev.stopPropagation();
ev.preventDefault();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/** @odoo-module **/

import {Orderline} from "point_of_sale.models";
import PosComponent from "point_of_sale.PosComponent";
import Registries from "point_of_sale.Registries";
import {Orderline} from "point_of_sale.models";

class ReorderButton extends PosComponent {
get isEmptyOrder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ChooseDeliveryCarrierPopup extends AbstractAwaitablePopup {
}
onChange(carrierId) {
const selected = this.props.chooses.find(
(item) => parseInt(carrierId) === item.carrier_id[0]
(item) => parseInt(carrierId, 10) === item.carrier_id[0]
);
this.state.choose = selected;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import Registries from "point_of_sale.Registries";

const {useState} = owl;

const PosDeliveryCarrierCreateOrderPopup = (CreateOrderPopup) =>
class extends CreateOrderPopup {
const PosDeliveryCarrierCreateOrderPopup = (OriginalCreateOrderPopup) =>
class extends OriginalCreateOrderPopup {
// @override
setup() {
super.setup();
Expand Down
4 changes: 2 additions & 2 deletions pos_order_to_sale_order_delivery/static/src/js/models.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import {Order} from "point_of_sale.models";
import Registries from "point_of_sale.Registries";

const PosOrderToSaleOrderDeliveryOrder = (Order) =>
class PosOrderToSaleOrderDeliveryOrder extends Order {
const PosOrderToSaleOrderDeliveryOrder = (OriginalOrder) =>
class extends OriginalOrder {
constructor() {
super(...arguments);
this.delivery_carrier = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import CreateOrderPopup from "point_of_sale.CreateOrderPopup";
import Registries from "point_of_sale.Registries";

const PosSaleOrderReportCreateOrderPopup = (CreateOrderPopup) =>
class extends CreateOrderPopup {
const PosSaleOrderReportCreateOrderPopup = (OriginalCreateOrderPopup) =>
class extends OriginalCreateOrderPopup {
async _downloadSaleOrderReport(saleOrderId) {
try {
const report = this.env.pos.config.iface_sale_order_report_id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import CreateOrderPopup from "point_of_sale.CreateOrderPopup";
import Registries from "point_of_sale.Registries";

export const CreateOrderPopupRisk = (CreateOrderPopup) =>
class CreateOrderPopupRisk extends CreateOrderPopup {
export const CreateOrderPopupRisk = (OriginalCreateOrderPopup) =>
class extends OriginalCreateOrderPopup {
/**
* Calculate risk amount by order
* @returns {Promise<*>} order total
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import {Order} from "point_of_sale.models";
import Registries from "point_of_sale.Registries";

const PosSaleFinancialRiskOrder = (Order) =>
class PosSaleFinancialRiskOrder extends Order {
const PosSaleFinancialRiskOrder = (OriginalOrder) =>
class extends OriginalOrder {
constructor() {
super(...arguments);
this.bypass_risk = false;
Expand Down
6 changes: 3 additions & 3 deletions pos_partner_firstname/static/src/js/PartnerDetailsEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ odoo.define("pos_partner_firstname.PartnerDetailsEdit", function (require) {
const PartnerDetailsEdit = require("point_of_sale.PartnerDetailsEdit");
const Registries = require("point_of_sale.Registries");

const PosPartnerDetailsEdit = (PartnerDetailsEdit) =>
class extends PartnerDetailsEdit {
const PosPartnerDetailsEdit = (OriginalPartnerDetailsEdit) =>
class extends OriginalPartnerDetailsEdit {
setup() {
super.setup();
this.changes = useState({
Expand Down Expand Up @@ -40,7 +40,7 @@ odoo.define("pos_partner_firstname.PartnerDetailsEdit", function (require) {
const processedChanges = {};
for (const [key, value] of Object.entries(this.changes)) {
if (this.intFields.includes(key)) {
processedChanges[key] = parseInt(value) || false;
processedChanges[key] = parseInt(value, 10) || false;
} else {
processedChanges[key] = value;
}
Expand Down
4 changes: 2 additions & 2 deletions pos_partner_firstname/static/src/js/PartnerScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ odoo.define("pos_partner_firstname.PartnerListScreen", function (require) {
const PartnerListScreen = require("point_of_sale.PartnerListScreen");
const Registries = require("point_of_sale.Registries");

const PosPartnerListScreen = (PartnerListScreen) =>
class extends PartnerListScreen {
const PosPartnerListScreen = (OriginalPartnerListScreen) =>
class extends OriginalPartnerListScreen {
back() {
super.back();
if (this.props.partner) {
Expand Down
12 changes: 7 additions & 5 deletions pos_payment_terminal/static/src/js/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ odoo.define("pos_payment_terminal.models", function (require) {
var OCAPaymentTerminal = require("pos_payment_terminal.payment");
models.register_payment_method("oca_payment_terminal", OCAPaymentTerminal);

const PosPaymentTerminalPosGlobalState = (PosGlobalState) =>
class PosPaymentTerminalPosGlobalState extends PosGlobalState {
const PosPaymentTerminalPosGlobalState = (OriginalPosGlobalState) =>
class extends OriginalPosGlobalState {
// @override
async after_load_server_data() {
for (var payment_method_id in this.payment_methods) {
var payment_method = this.payment_methods[payment_method_id];
if (payment_method.use_payment_terminal == "oca_payment_terminal") {
if (
payment_method.use_payment_terminal === "oca_payment_terminal"
) {
this.config.use_proxy = true;
}
}
Expand All @@ -34,8 +36,8 @@ odoo.define("pos_payment_terminal.models", function (require) {
};
Registries.Model.extend(PosGlobalState, PosPaymentTerminalPosGlobalState);

const PosPaymentTerminalPayment = (Payment) =>
class PosPaymentTerminalPayment extends Payment {
const PosPaymentTerminalPayment = (OriginalPayment) =>
class extends OriginalPayment {
constructor() {
super(...arguments);
// Id of the terminal transaction, used to find the payment
Expand Down
3 changes: 0 additions & 3 deletions pos_product_multi_barcode/static/src/js/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ odoo.define("pos_product_multi_barcode.db", function (require) {
var res = this._super(products);
var self = this;

if (!products instanceof Array) {
products = [products];
}
Copy link
Member

Choose a reason for hiding this comment

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

sorry not a Javascript expert here, but are you sure this can be simply removed like that?

Copy link
Contributor Author

@legalsylvain legalsylvain Jan 18, 2024

Choose a reason for hiding this comment

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

super is called before, and the original function does the job. So it is not possible to not have an array at this step or did I missed something ?

https://github.com/odoo/odoo/blob/16.0/addons/point_of_sale/static/src/js/db.js#L192C1-L194C1

Copy link
Member

Choose a reason for hiding this comment

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

Mmm, I'd say it isn't mutable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ow Thanks ! I didn't know. So what is the good way here ? Add an eslint exceptiont ?

Copy link
Member

Choose a reason for hiding this comment

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

Well, I'm wrong and is indeed mutable as is part of the arguments object: https://eslint.org/docs/latest/rules/no-param-reassign

Copy link
Member

Choose a reason for hiding this comment

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

I'd say so

Copy link
Member

Choose a reason for hiding this comment

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

So it is OK like that. Right ?

yes sorry I didn't see the job was done already in super.

Copy link
Contributor

Choose a reason for hiding this comment

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

Strict mode code doesn’t sync indices of the arguments object with each parameter binding. Therefore, this rule is not necessary to protect against arguments object mutation in ESM modules or other strict mode functions.

I wouldn't remove it. According to that it's only mutable if running old code that hasn't been flagged with "use strict";

As we're slowly migrating to ESM, we can't rely on the argument being mutable (which is a bad thing, solved in "modern js")

Copy link
Member

Choose a reason for hiding this comment

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

Thanks @ivantodorovich I didn't get that nuance :) Wouldn't the lint rule be a bit misguiding being that virtually all the code is run in strict mode?

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed, since we already have the strict rule, it seems we could remove the no-param-reassign one

products.forEach(function (product) {
var barcodes = JSON.parse(product.barcodes_json);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ odoo.define("pos_product_quick_info.ProductItem", function (require) {
const ProductItem = require("point_of_sale.ProductItem");
const Registries = require("point_of_sale.Registries");

const QuickInfoProductItem = (ProductItem) =>
class QuickInfoProductItem extends ProductItem {
const QuickInfoProductItem = (OriginalProductItem) =>
class extends OriginalProductItem {
async onProductInfoClick(event) {
event.stopPropagation();
return await super.onProductInfoClick(...arguments);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/** @odoo-module **/

import SaleOrderManagementScreen from "pos_sale.SaleOrderManagementScreen";
import Registries from "point_of_sale.Registries";
import SaleOrderManagementScreen from "pos_sale.SaleOrderManagementScreen";

const PrintSaleOrderManagementScreen = (SaleOrderManagementScreen) =>
class PrintSaleOrderManagementScreen extends SaleOrderManagementScreen {
const PrintSaleOrderManagementScreen = (OriginalSaleOrderManagementScreen) =>
class extends OriginalSaleOrderManagementScreen {
async _onClickSaleOrder(event) {
// Add a "Print" option to the selection list
this.additionalSelectionList = [
Expand All @@ -18,8 +18,9 @@ const PrintSaleOrderManagementScreen = (SaleOrderManagementScreen) =>
}
async _printSaleOrder(confirmed, payload) {
// Reset confirmed, payload, and additionalSelectionList
confirmed = false;
payload = false;
// eslint-disable-next-line no-param-reassign
confirmed = payload = false;

this.additionalSelectionList = false;
if (
this.env.pos.config.print_sales_order_ids &&
Expand Down Expand Up @@ -78,7 +79,7 @@ const PrintSaleOrderManagementScreen = (SaleOrderManagementScreen) =>
return {confirmed, payload};
}
showPopup(name, props) {
if (name == "SelectionPopup" && this.additionalSelectionList) {
if (name === "SelectionPopup" && this.additionalSelectionList) {
props.list = [...props.list, ...this.additionalSelectionList];
}
return super.showPopup(name, props).then(({confirmed, payload}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import {PosGlobalState} from "point_of_sale.models";
import Registries from "point_of_sale.Registries";

const ReportPosGlobalState = (PosGlobalState) =>
class ReportPosGlobalState extends PosGlobalState {
const ReportPosGlobalState = (OriginalPosGlobalState) =>
class extends OriginalPosGlobalState {
async _processData(loadedData) {
await super._processData(...arguments);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import Registries from "point_of_sale.Registries";
import {format} from "web.field_utils";
import utils from "web.utils";

const StockProductItem = (ProductItem) =>
class StockProductItem extends ProductItem {
const StockProductItem = (OriginalProductItem) =>
class extends OriginalProductItem {
format_quantity(quantity) {
const unit = this.env.pos.units_by_id[this.props.product.uom_id[0]];
var formattedQuantity = `${quantity}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import ProductsWidget from "point_of_sale.ProductsWidget";
import Registries from "point_of_sale.Registries";

const StockProductsWidget = (ProductsWidget) =>
class StockProductsWidget extends ProductsWidget {
const StockProductsWidget = (OriginalProductsWidget) =>
class extends OriginalProductsWidget {
setup() {
super.setup();
this.env.services.bus_service.addChannel(this._getChannelName());
Expand Down
Loading