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

enable all eslint rules and fix problems #297

Closed
wants to merge 3 commits into from

Conversation

mifi
Copy link
Collaborator

@mifi mifi commented Oct 29, 2021

See discussion in #291

  • had to disable no-use-before-define many places where onSuccess uses the upload object, maybe in the future onsuccess could provide upload as an argument to onSuccess
  • also a lot of functions moved (as eslint doesn't allow function hoisting)
  • disabled eslint for demos/cordova and demos/browser
  • disabled import/no-extraneous-dependencies for test code (which uses dev dependencies)

See discussion in tus#291
- had to disable no-use-before-define many places where onSuccess uses the upload object, maybe in the future onsuccess could provide upload as an argument to onSuccess
- also a lot of functions moved (as eslint doesn't allow function hoisting)
- disabled eslint for demos/cordova and demos/browser
@mifi mifi requested a review from Acconut November 2, 2021 05:31
@mifi
Copy link
Collaborator Author

mifi commented Feb 22, 2022

any chance of getting this merged @Acconut before we get too many conflicts? Or are there any rules you don't agree with that you would like to disable?

Copy link
Member

@Acconut Acconut left a comment

Choose a reason for hiding this comment

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

Thank you for reminding me of this PR! I only have a few questions about it

@@ -1,5 +1,6 @@
/* eslint no-console: 0 */

// eslint-disable-next-line import/no-extraneous-dependencies
Copy link
Member

Choose a reason for hiding this comment

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

Do you know why import/no-extraneous-dependencies has to be disabled here? browserstack-runner is defined as a dependency in package.json

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, it's because it's only a devDependency. I think that rule's purpose is to help catch errors where we accidentally try to use a module that we forgot to add to dependencies, only to realise it after publish, or a user realises that it's missing. In this case browserstack-jasmine.js is indeed just a local dev script so it's not part of the produced code, so it's ok to use devDependencies. I think this could be solved either by disabling each use of dev deps like we do here, or by setting up different eslint config for different paths, where we disalbe this rule for dev code.

@@ -6,6 +6,7 @@
* according to the result.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
Copy link
Member

Choose a reason for hiding this comment

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

Again, is it necessary to disable import/no-extraneous-dependencies here?

} else {
try {
data = !data.trim().length ? {} : JSON.parse(data)
const data2 = !data.trim().length ? {} : JSON.parse(data)
Copy link
Member

Choose a reason for hiding this comment

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

I assume there is a rule disallowing the reassignment of arguments. Could we loosen up this rule? I actually think the previous code where reassignment is allowed is more reasonable. Or is there a specific reason against it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You can see the rationale behind the rule here: https://eslint.org/docs/rules/no-param-reassign
Although I agree that it's not a big problem, so we can disable that rule if you like.

lib/upload.js Outdated
// Count the number of arguments to see if a callback is being provided as the last
// argument in the old style required by tus-js-client 1.x, then throw an error if it is.
// `arguments` is a JavaScript built-in variable that contains all of the function's arguments.
if (arguments.length > 1 && typeof arguments[arguments.length - 1] === 'function') {
if (arguments.length > 1 && typeof args[arguments.length - 1] === 'function') {
Copy link
Member

Choose a reason for hiding this comment

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

Could you explain this change? Are we not allowed to access arguments, but we can use arguments.length?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TBH I can't explain that 😅 It seems like the rule doesn't enforce all uses of arguments, I don't know why. I'll remove the other uses too. Or if you think this rule should be disabled we can do that too.

even though eslint didn't catch them for some reason
@Acconut
Copy link
Member

Acconut commented Jun 7, 2022

Implement in #390 which fixed the merge conflicts. Thanks for your work, @mifi!

@Acconut Acconut closed this Jun 7, 2022
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