Closed mkszepp closed 1 week ago
i'm seeying a false positive too at line 34 using 12.1.1
const svg = await toString(data, options);
import { assert } from '@ember/debug';
import Service from '@ember/service';
import { toDataURL, toString } from 'qrcode';
import type { QRCodeToDataURLOptionsJpegWebp, QRCodeToDataURLOptionsOther, QRCodeToStringOptions } from 'qrcode';
export default class RendererService extends Service {
async renderDataUrl(data: string, options: QRCodeToStringOptions | QRCodeToDataURLOptionsJpegWebp | QRCodeToDataURLOptionsOther = {}): Promise<string> {
if (!data.length) {
return '';
}
if (!options?.type) {
options.type = 'image/png';
}
if (!options?.errorCorrectionLevel) {
options.errorCorrectionLevel = 'L';
}
if (!options?.margin) {
options.margin = 0;
}
assert(`Attribute 'type' must be one of 'image/png', 'svg', 'image/jpeg'`, ['image/png', 'svg', 'image/jpeg'].includes(options.type));
assert(`Attribute 'data' must be string...`, 'string' === typeof data);
assert(`Attribute 'errorCorrectionLevel' must be string`, 'string' === typeof options.errorCorrectionLevel);
assert(`Attribute 'errorCorrectionLevel' must be one of 'L', 'M', 'Q' or 'H'`, ['L', 'M', 'Q', 'H'].includes(options.errorCorrectionLevel));
// assert(`Attribute 'quality' must be a number`, options?.rendererOpts?.quality !== undefined ? typeof options?.rendererOpts?.quality === 'number' : true);
switch (options.type) {
case 'svg': {
const svg = await toString(data, options);
const blob = new Blob([svg], { type: 'image/svg+xml' });
return URL.createObjectURL(blob);
}
case 'image/png':
case 'image/jpeg':
return await toDataURL(data, options);
default:
throw new Error('Unsupported QR Type');
}
}
}
declare module '@ember/service' {
interface Registry {
'qr-renderer': RendererService;
}
}
Looks like when a function is named like a Object.prototype property (https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Object_prototypes) there is a false positive error...
hasOwnProperty()
isPrototypeOf()
propertyIsEnumerable()
toLocaleString()
toString()
valueOf()
constructor()
@mkszepp did you find a work around?
@basz atm i have disabled... i have not really experience with eslint rules, but i have commitet a possible fix...
After cleanup of all
ember/runloops
, i have removed the ruleember/no-runloop
. Now i'm getting a false positive error.Example:
While the lint rules brings wrong errors, there is necessary to disable the rule, because there is not allowed to set
hasOwnproperty
inallowedList
.Version: