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

Added new jsx-ban-elements rule to ban jsx elements #137

Merged
merged 2 commits into from
Jan 11, 2018

Conversation

dryganets
Copy link
Contributor

No description provided.

@dryganets
Copy link
Contributor Author

dryganets commented Jan 10, 2018

@adidahiya,
am I missing something here?
The checks seem to be hanging.

@adidahiya
Copy link
Contributor

@dryganets did you enable CircleCI on your fork? https://circleci.com/projects

@dryganets
Copy link
Contributor Author

Thank you.
Didn't realize I need to enable it for my fork.

package.json Outdated
@@ -1,6 +1,6 @@
{
"name": "tslint-react",
"version": "3.3.3",
"version": "3.3.4",
Copy link
Contributor

Choose a reason for hiding this comment

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

please don't bump the version in this commit. that will be done during the release process.

public static metadata: Lint.IRuleMetadata = {
ruleName: "jsx-ban-elements",
description: Lint.Utils.dedent`
Bans specific jsx elements from being used.`,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "JSX", not "jsx"

}

function parseOption([pattern, message]: [string, string | undefined]): IOption {
return {message, pattern: new RegExp(`^${pattern}$`)};
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we surround the configured pattern with ^$? Why not leave that up to the user?

const typeName = node.tagName.getText();
for (const ban of ctx.options) {
if (ban.pattern.test(typeName)) {
ctx.addFailureAtNode(node, Rule.FAILURE_STRING_FACTORY(typeName, ban.message));
Copy link
Contributor

Choose a reason for hiding this comment

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

can we highlight the failure on just the tag name rather than the whole tag expression? that way, if there are other lint errors in the tag expression, they're less likely to overlap, which makes it easier to read in your editor.

@@ -0,0 +1,7 @@
{
"rules": {
"jsx-ban-elements": [true,
Copy link
Contributor

Choose a reason for hiding this comment

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

use the newer options syntax please.

"jsx-ban-elements": {
    "options": [
        ["span", "Use div instead."]
    ]
}

@dryganets
Copy link
Contributor Author

Fixed all you asked.

@adidahiya
Copy link
Contributor

thanks!

@adidahiya adidahiya merged commit 9cb1347 into palantir:master Jan 11, 2018
@adidahiya adidahiya mentioned this pull request Jan 11, 2018
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.

2 participants