Skip to content

Commit

Permalink
chore: add no-prototype-builtins ESLint rule as it became part of rec…
Browse files Browse the repository at this point in the history
…ommended in ESLint9
  • Loading branch information
peter-sanderson committed Nov 7, 2024
1 parent 5e33e3a commit 4fbdb7b
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module.exports = {
'no-irregular-whitespace': 'error',
'no-constant-binary-expression': 'error',
'no-empty': 'error',
'no-prototype-builtins': 'error',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/prefer-ts-expect-error': 'error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const AccountsList = ({ onItemClick }: AccountListProps) => {
searchString || coinFilter
? list.filter(account => {
const { key, accountType, symbol, index } = account;
const accountLabel = accountLabels.hasOwnProperty(key)
const accountLabel = Object.prototype.hasOwnProperty.call(accountLabels, key)
? accountLabels[key]
: getDefaultAccountLabel({ accountType, symbol, index });

Expand Down
7 changes: 6 additions & 1 deletion suite-common/suite-utils/src/comparison.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ export const isChanged = (prev?: any, current?: any, filter?: { [k: string]: str
for (let i = 0; i < currentKeys.length; i++) {
const key = currentKeys[i];

if (filter && filter.hasOwnProperty(key) && prev[key] && current[key]) {
if (
filter &&
Object.prototype.hasOwnProperty.call(filter, key) &&
prev[key] &&
current[key]
) {
const prevFiltered = {};
const currentFiltered = {};
for (let i2 = 0; i2 < filter[key].length; i2++) {
Expand Down
5 changes: 3 additions & 2 deletions suite-common/wallet-config/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const getNetworkFeatures = (symbol: NetworkSymbol): NetworkFeature[] =>
export const getCoingeckoId = (symbol: NetworkSymbol) => networks[symbol].coingeckoId;

export const isNetworkSymbol = (symbol: NetworkSymbol | string): symbol is NetworkSymbol =>
networks.hasOwnProperty(symbol);
Object.prototype.hasOwnProperty.call(networks, symbol);

/**
* Get network object by symbol as a generic `Network` type.
Expand All @@ -67,7 +67,8 @@ export const isAccountOfNetwork = (
network: Network,
accountType: string,
): accountType is AccountType =>
network.accountTypes.hasOwnProperty(accountType) || accountType === 'normal';
Object.prototype.hasOwnProperty.call(network.accountTypes, accountType) ||
accountType === 'normal';

export const getNetworkByCoingeckoId = (coingeckoId: string) =>
networksCollection.find(n => n.coingeckoId === coingeckoId);
Expand Down
9 changes: 6 additions & 3 deletions suite-common/wallet-utils/src/fiatRatesUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,17 @@ const combineFiatRates = (fiatRates: RatesByTimestamps, accountRates: RatesByTim
for (const fiatRate in accountRates) {
const fiatRateKey = fiatRate as FiatRateKey;

if (accountRates.hasOwnProperty(fiatRateKey)) {
if (Object.prototype.hasOwnProperty.call(accountRates, fiatRateKey)) {
if (!fiatRates[fiatRateKey]) {
fiatRates[fiatRateKey] = accountRates[fiatRateKey];
} else {
for (const timestampRate in accountRates[fiatRateKey]) {
const timestamp = timestampRate as unknown as Timestamp;
if (
accountRates[fiatRateKey].hasOwnProperty(timestamp) &&
Object.prototype.hasOwnProperty.call(
accountRates[fiatRateKey],
timestamp,
) &&
!fiatRates[fiatRateKey][timestamp]
) {
fiatRates[fiatRateKey][timestamp] = accountRates[fiatRateKey][timestamp];
Expand All @@ -70,7 +73,7 @@ export const buildHistoricRatesFromStorage = (storageHistoricRates: RatesByTimes

storageHistoricRates.forEach(fiatRates => {
for (const fiatRate in fiatRates) {
if (fiatRates.hasOwnProperty(fiatRate)) {
if (Object.prototype.hasOwnProperty.call(fiatRates, fiatRate)) {
const fiatRateKey = fiatRate as FiatRateKey;

if (!historicFiatRates[fiatRateKey]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const useConnectParseParams = (url: ParsedURL): UseConnectParseParamsType
typeof queryParams?.params !== 'string' ||
typeof queryParams?.method !== 'string' ||
typeof queryParams?.callback !== 'string' ||
!TrezorConnect.hasOwnProperty(queryParams?.method)
!Object.prototype.hasOwnProperty.call(TrezorConnect, queryParams?.method)
) {
return { parseParamsError: TypedError('Method_InvalidParameter') };
}
Expand Down

0 comments on commit 4fbdb7b

Please sign in to comment.