Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate prefer-exponentiation-operator rule #484

Conversation

fisker
Copy link
Collaborator

@fisker fisker commented Dec 24, 2019

Deprecate unicorn/prefer-exponentiation-operator rule, replace it with ESLint official rule prefer-exponentiation-operator

I ran prefer-exponentiation-operator over our test cases, little difference:

  1. spaces
Math.pow(1, 2);

1 ** 2; // unicorn/prefer-exponentiation-operator
1**2; // prefer-exponentiation-operator
  1. exponent parenthesised
Math.pow(1, +2);

1 ** +2; // unicorn/prefer-exponentiation-operator
1**(+2); // prefer-exponentiation-operator

fixes #483

@fisker fisker force-pushed the deprecated-prefer-exponentiation-operator branch from 14ae67d to 83208a8 Compare December 24, 2019 02:20
@fisker
Copy link
Collaborator Author

fisker commented Dec 24, 2019

//cc @gurpreetatwal @sindresorhus

Copy link

@gurpreetatwal gurpreetatwal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comment on testing, but otherwise looks good to me!

t.is(Object.keys(usageRules).length - ignoredRules.length, ruleFiles.length, 'There are more rules in readme.md ## Usage than rule files.');
t.is(Object.keys(rules).length, ruleFiles.length, 'There are more rules in readme.md ## Rules than rule files.');
t.is(Object.keys(usageRules).length - ignoredRules.length, availableRules.length, 'There are more rules in readme.md ## Usage than rule files.');
t.is(Object.keys(rules).length, availableRules.length, 'There are more rules in readme.md ## Rules than rule files.');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be worth it to add a check that ensures deprecated rules are described in the readme?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's really nessary.

readme.md Outdated

|Deprecated rule|Replaced by|Rule Details|
|:--|:--|:--|
|[unicorn/prefer-exponentiation-operator](docs/rules/prefer-exponentiation-operator.md)|[prefer-exponentiation-operator](https://eslint.org/docs/rules/prefer-exponentiation-operator)|Prefer the exponentiation operator over `Math.pow()`|
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should use a table for this. Markdown tables are annoying to edit and comes with little benefit here. Not every deprecated rule will have a replacement either. Better to just use a plain list.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@fisker fisker force-pushed the deprecated-prefer-exponentiation-operator branch from f158a41 to 9b288d8 Compare December 30, 2019 02:20
@fisker fisker force-pushed the deprecated-prefer-exponentiation-operator branch from 9b288d8 to 1d6aad2 Compare December 30, 2019 02:27
@sindresorhus sindresorhus merged commit c4ffb1a into sindresorhus:master Dec 30, 2019
@fisker fisker deleted the deprecated-prefer-exponentiation-operator branch December 30, 2019 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs: direct users towards core prefer-exponentiation-operator rule
3 participants