简体   繁体   中英

Substitute bitwise operation in ESLint

I'm trying to apply this code: How to get XYZ coordinates of tile by click on Leaflet map - which contains bitwise operator "<<". In the environment that I'm running it on (NodeJS, ExpressJS, AngularJS), codes are checked by ESLint upon compiling it but I need the solution given on the link. I get this error on compilation .

Unexpected use of '<<' no-bitwise

According to this link: http://eslint.org/docs/rules/no-bitwise - ESLint disallows bitwise operators. Is there any way to bypass this rule or if not, provide an alternate calculation that produces similar results to bitwise operation '<<'?

I hope my question is clear, thanks.

You need to add the comment //eslint-disable-line no-bitwise on the line you'd like for es-lint to ignore

eg

var x = 5 << 5; //eslint-disable-line no-bitwise

对于 2 的幂,您可以使用Math.pow

const scale = Math.pow( 2, zoom );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM