compressorjs
compressorjs copied to clipboard
Violates "no new" lint rule
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?
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]);
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

@uzianhar I'm sorry. I have no idea about your situation.
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
![]()
did you solve your issue, i have the same problem