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

dynamic import cannot have trailing comma #4494

Closed
surma opened this issue Feb 1, 2019 · 6 comments
Closed

dynamic import cannot have trailing comma #4494

surma opened this issue Feb 1, 2019 · 6 comments
Labels
Formatting rule Relates to a rule which enforces code formatting and likely overlaps with prettier P3 🌹 R.I.P. 🌹 Status: Accepting PRs Type: Enhancement

Comments

@surma
Copy link

surma commented Feb 1, 2019

Bug Report

  • TSLint version: 5.12.1
  • TypeScript version: 3.3.1
  • Running TSLint via: CLI

TypeScript code being linted

const x = import(
  "./module",
);

with tslint.json configuration:

{
    "defaultSeverity": "error",
    "extends": [
        "tslint:recommended"
    ],
    "rules": {
        "trailing-comma": true
    },
}

Actual behavior

No error.

Expected behavior

Trailing commas are invalid in import() statements as they are not a function call but a syntactic construct. TypeScript v3.3+ does not compile with a trailing comma in an import statement. See this PR. This should be an error in tslint, too.

@adidahiya
Copy link
Contributor

If it fails to compile in TS 3.3, then adding the same exact check in TSLint feels redundant. Why report it twice? I'm going to mark this as declined for now but open to community feedback.

@adidahiya adidahiya added Type: Rule Suggestion Resolution: Declined Formatting rule Relates to a rule which enforces code formatting and likely overlaps with prettier labels Feb 2, 2019
@surma
Copy link
Author

surma commented Feb 2, 2019

Fair enough. What about tslint --fix?

@adidahiya
Copy link
Contributor

adidahiya commented Feb 2, 2019

Yeah autofixing is a fair argument but IMO the benefits don't outweigh the maintenance costs in this one, especially given that it's a formatting rule, a category which we are de-prioritizing in TSLint as a whole (#3592)

@adidahiya
Copy link
Contributor

adidahiya commented Feb 2, 2019

actually, I looked at the trailing-comma rule implementation again and this shouldn't be too hard to add. open to PRs with unit tests

@JoshuaKGoldberg
Copy link
Contributor

💀 It's time! 💀

TSLint is being deprecated and no longer accepting pull requests for major new changes or features. See #4534. 😱

If you'd like to see this change implemented, you have two choices:

  • Recommended: Check if this is available in ESLint + typescript-eslint
  • Not Recommended: Fork TSLint locally 🤷‍♂️

👋 It was a pleasure open sourcing with you!

If you believe this message was posted here in error, please comment so we can re-open the issue!

@JoshuaKGoldberg
Copy link
Contributor

🤖 Beep boop! 👉 TSLint is deprecated 👈 (#4534) and you should switch to typescript-eslint! 🤖

🔒 This issue is being locked to prevent further unnecessary discussions. Thank you! 👋

@palantir palantir locked and limited conversation to collaborators Mar 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Formatting rule Relates to a rule which enforces code formatting and likely overlaps with prettier P3 🌹 R.I.P. 🌹 Status: Accepting PRs Type: Enhancement
Projects
None yet
Development

No branches or pull requests

3 participants