silverwind

Results 1283 comments of silverwind

Do you even need the `Object.entries`? You haven't told what `tokenBody` is. ```js > new URLSearchParams(Object.entries({a: 1})) URLSearchParams { 'a' => '1' } > new URLSearchParams({a: 1}) URLSearchParams { 'a'...

I guess this rule could apply to more than just `URLSearchParams`, basically anything that accepts a iterable in its constructor. [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/Set) is such an example, [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData/FormData) is not. I'd call...

Right, so `URLSearchParams` is special in that it accepts objects, but the basic idea is the same in all cases, avoid a loop when a constructor can do the looping...

FWIW there is also [`regexp/prefer-regexp-test`](https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-regexp-test.html) but it doesn't detect those either.

Does it have to be a "switch"? There are a number of plugins that support both configs at the same time and I think it would ease the migration.

> We can switch to [`find-up`](https://github.com/sindresorhus/find-up) and `JSON.parse(fs.readFileSync(pkgPath, 'utf8'))`. Don't even need `find-up`, this simple function will do: ```js function findUpSync(filename, dir) { const path = join(dir, filename); try {...

> Forgot `Array#indexOf()`, seems we can't support it. Could maybe be supported if `Array#at()` is preferred over `Array#indexOf()` so any remaining `indexOf` property access must be against strings.

I do agree on flagging atob and btoa but maybe it should not make any module recommendations as those are subjective. I used https://www.npmjs.com/package/base-64 in the past.

Yeah I wouln't use it today anymore. Maybe it should link to that MDN until a new standard method arises.

I think https://eslint.org/docs/latest/rules/no-restricted-globals could cover at least part of this: ```json "no-restricted-globals": [ "error", { "name": "atob", "message": "Use uint8array-extras instead" }, { "name": "btoa", "message": "Use uint8array-extras instead" }...