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

[FIX] eslint warnings #1133

merged 5 commits into from
Jan 20, 2024

Conversation

legalsylvain
Copy link
Contributor

Rational : for the time being, when we want to contribute to the OCA 16.0 branch and if we run pre-commit run -a, a lot of warning are poluting the log. So it's not easy to see if there is a real problem.

This PR fix all warnings. (a commit per type)

  • 'no-shadow'
  • 'no-param-reassign'
  • 'eqeqeq'
  • 'sort-imports'
  • 'radix'

Thanks for your review !

CC : @OCA/pos-maintainers

@OCA-git-bot
Copy link
Contributor

Hi @geomer198, @robyf70, @CetmixGitDrone, @GabbasovDinar,
some modules you are maintaining are being modified, check this out!

Copy link
Member

@chienandalu chienandalu left a comment

Choose a reason for hiding this comment

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

Great!

(isn't it eslint anyway?)

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

@legalsylvain legalsylvain changed the title [FIX] esling warnings [FIX] eslint warnings Jan 18, 2024
@legalsylvain legalsylvain force-pushed the 16.0-FIX-warning-no-shadow branch from 65ff05d to 1f6aa17 Compare January 19, 2024 09:07
@legalsylvain
Copy link
Contributor Author

(isn't it eslint anyway?)

Indeed ! typo fixed in commits texts.

@legalsylvain
Copy link
Contributor Author

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 16.0-ocabot-merge-pr-1133-by-legalsylvain-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit cbc8fb0 into OCA:16.0 Jan 20, 2024
7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at a47eedf. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants