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

Add Pragma for createClass factory method #725

Merged
merged 1 commit into from
Aug 14, 2016
Merged

Add Pragma for createClass factory method #725

merged 1 commit into from
Aug 14, 2016

Conversation

zurawiki
Copy link
Contributor

@zurawiki zurawiki commented Jul 28, 2016

Allows the the plugin to lint components created in a non-standard way with
configuration such as

var MyComponent = SpecialReact.createSpecialClass({
  ...
});

with config looking like:

{
  "settings": {
    "react": {
      "createClass": "createSpecialClass",
      "pragma": "SpecialReact", 
    }
  }
}

@zurawiki
Copy link
Contributor Author

@yannickcr I would love to help you merge this in. I didn't see any notes on contributing to this project in the README or on the wiki.

Please let me know what next steps I need to take.

@yannickcr
Copy link
Member

Thanks for your contribution.

Sorry, I'm a bit busy working on the v6.0.0 right now, but I'll try to have a look on this right after 😃

if (context.settings.react && context.settings.react.createClass) {
pragma = context.settings.react.createClass;
}
return pragma.split('(')[0];
Copy link
Member

Choose a reason for hiding this comment

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

Why do you make a .split('(') here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I matched the .split('.') on line 24.
It's there because ( cannot be part of a function's name

Copy link
Member

Choose a reason for hiding this comment

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

If someone sets an invalid pragma value, shouldn't the plugin error out, instead of trying to fix it for them?

Allows the the plugin to lint components created in a non-standard way with
configuration such as

```js
var MyComponent = React.createSpecialClass({
  ...
});
```
@zurawiki
Copy link
Contributor Author

Ok, I added a regex and I set config to throw an error when an invalid config is given for either pragma field

@yannickcr yannickcr merged commit 7982627 into jsx-eslint:master Aug 14, 2016
@yannickcr
Copy link
Member

Merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants