airbnb / javascript

JavaScript Style Guide
MIT License
145.55k stars 26.55k forks source link

Remove Math.pow from `no-restricted-properties` and use `prefer-exponentiation-operator` instead. #2421

Closed aSqrd-eSqrd closed 1 year ago

aSqrd-eSqrd commented 3 years ago

Since ESlint has the helpful prefer-exponentiation-operator rule it would be nice if Math.pow was removed from the no-restricted-properties definitions in rules/best-practices.js in favor of the prefer-exponentiation-operator rule.

This has the benefit to us stubborn folks who want to use the eslint-config-airbnb or eslint-config-airbnb-base packages but want to override the rule to allow the use of Math.pow. The no-restricted-properties ESlint rule can't be selectively modified, eslint/eslint#7957. It has to be completely duplicated and the desired change made in the duplicate. The Math.pow entry in no-restricted-properties doesn't really fit in with the "intent" of the other entries in the no-restricted-propertiesobjects and since theprefer-exponentiation-operator` rule exist it is a neat and tidy modification.

Thank you, aSqrd-eSqrd

ljharb commented 3 years ago

That was added in eslint v6.7, and indeed, we will enable it when eslint 5 is dropped: https://github.com/airbnb/javascript/blob/1eadb93e377da1e56c3f91f26610e5d0a00738a9/packages/eslint-config-airbnb-base/rules/style.js#L444

frazie commented 1 year ago

I'd like to help with this issue if it is still open for changes.

ljharb commented 1 year ago

This was done in f3d3a075c

SpraxDev commented 1 year ago

This was done in f3d3a07

It looks like the README.md has not been updated yet to reflect that change (https://github.com/airbnb/javascript#es2016-properties--exponentiation-operator)

ljharb commented 1 year ago

@SpraxDev you're right; want to send a PR updating that?

SpraxDev commented 1 year ago

I've created #2768 @ljharb ^^