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

Suggestion: no trailing semicolon #2527

Open
OliverJAsh opened this issue Dec 16, 2019 · 7 comments
Open

Suggestion: no trailing semicolon #2527

OliverJAsh opened this issue Dec 16, 2019 · 7 comments

Comments

@OliverJAsh
Copy link
Contributor

Copying suggestion from palantir/tslint-react#116:

We had a case in our code where a semicolon was accidentally used at the end of a line of a tsx statement. Since this is almost always unintended, it makes sense to have a lint rule to warn against it. The rule would warn against code like the following:

<div>
  <SomeComponent/>;
</div>

/cc @jkillian

@ljharb
Copy link
Member

ljharb commented Dec 16, 2019

This seems like a reallllllly niche rule for something that almost never happens :-/

@OliverJAsh
Copy link
Contributor Author

Happened to me loads of times. The linked issue also has some interest suggesting it's not just me.

@ljharb
Copy link
Member

ljharb commented Dec 16, 2019

This seems like it would be handled by the jsx-no-literals rule in a much more generic way.

@OliverJAsh
Copy link
Contributor Author

OliverJAsh commented Dec 16, 2019

That seems quite extreme for what we're trying to achieve here. I'm fine with literals, just not trailing semicolons, which usually get left behind during refactors

@dgoldstein0
Copy link

+1 for this being useful

@bobthecow
Copy link

👍 I've fixed instances of this bug four or five times in production. I'd love a linter too!

@cjvnjde
Copy link

cjvnjde commented Feb 14, 2024

Not the best solution, but it works for me.

    "no-restricted-syntax": [
      "error",
      {
        selector: "JSXElement > JSXText[value=/^;\n/]",
        message: 'Please use proper case for the text node "semi" after JSX elements.',
      },
    ]

It works for a semicolon at the end of the line after a jsx tag.

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

No branches or pull requests

5 participants