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

Violates "no new" lint rule #167

Open
julix-unity opened this issue Jan 7, 2023 · 4 comments
Open

Violates "no new" lint rule #167

julix-unity opened this issue Jan 7, 2023 · 4 comments

Comments

@julix-unity
Copy link

Describe the bug

The regular use of this starts with new Compressor without storing the result (since the main effect is in side effect).

From ESLint docs https://eslint.org/docs/latest/rules/no-new

In this case, the created object is thrown away because its reference isn’t stored anywhere, and in many cases, this means that the constructor should be replaced with a function that doesn’t require new to be used.

What lead to using new rather than just importing some kind of function like compress() or equivalent?

@fengyuanchen
Copy link
Owner

Maybe you can try to use the native Reflect.construct() method, e.g.:

import Compressor from 'compressorjs';

// const compressor =  new Compressor(file, options);
const compressor = Reflect.construct(Compressor, [file, options]);

@uzianhar
Copy link

hay @fengyuanchen, how can I push compressor result to data ?
I'm using vuex and some parameter as payload to upload, and I cann't using vuex inside compressor

image

@fengyuanchen
Copy link
Owner

@uzianhar I'm sorry. I have no idea about your situation.

@Murtdha
Copy link

Murtdha commented May 8, 2023

hay @fengyuanchen, how can I push compressor result to data ? I'm using vuex and some parameter as payload to upload, and I cann't using vuex inside compressor

image

did you solve your issue, i have the same problem

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

No branches or pull requests

4 participants