Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Suggestion for no-magic-numbers #4412

Closed
fwh1990 opened this issue Dec 26, 2018 · 5 comments
Closed

Suggestion for no-magic-numbers #4412

fwh1990 opened this issue Dec 26, 2018 · 5 comments

Comments

@fwh1990
Copy link

fwh1990 commented Dec 26, 2018

Rule Suggestion

Is your rule for a general problem or is it specific to your development style?

A general problem.

What does your suggested rule do?

no-magic-numbers should not report error when using in tsx attribute.

List several examples where your rule could be used

class App extends React.PureComponent {
    render() {
        return <SomePage width={200} height={150} />;
    }
}

Because we both understand what the numbers mean.

Additional context

No.

@johnwiseheart
Copy link
Contributor

For me at least, I still want no-magic-numbers to catch this case. Yes you know what the number represents, but by forcing you to define the number outside of the JSX, it could enable you to better define how you came up with the number, allow easy exporting, etc.

That said, I could see this as a new rule option - to disable the rule within JSX. However, I would disagree with setting it as default.

@fwh1990
Copy link
Author

fwh1990 commented Dec 27, 2018

Good idea. So, you may add the new rule to repository tslint-react?

@JoshuaKGoldberg
Copy link
Contributor

@fwh1990 this repository could take in a pull request to add the option to the no-magic-numbers rule that's off by default 😊

@fwh1990
Copy link
Author

fwh1990 commented Jan 8, 2019

I appended option ts.SyntaxKind.JsxAttribute and ts.SyntaxKind.JsxAttributes to Rule.ALLOWED_NODES,but nothing changed. Would you please add this enhancement yourself?

@adidahiya
Copy link
Contributor

fixed by #4460

@adidahiya adidahiya added this to the 5.14.0 milestone Mar 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants