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

Add support for ES6 bare imports #468

Merged
merged 1 commit into from
Jun 26, 2015
Merged

Add support for ES6 bare imports #468

merged 1 commit into from
Jun 26, 2015

Conversation

adidahiya
Copy link
Contributor

Fixes #451

This affects the following rules:

  • no-unused-variable
  • no-use-before-declare
  • whitespace (it was already handled here, but I added a regression test)

Review on Reviewable

@adidahiya adidahiya added the P1 label Jun 25, 2015
// Named imports & namespace imports handled by other walker methods.
// importClause will be null for bare imports.
if (importClause != null && importClause.name != null) {
const variableIdentifier = importClause.name;
Copy link
Contributor

Choose a reason for hiding this comment

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

it's inappropriate to use const for these variables. we have no way of enforcing these -- someone can still do variableIdentifier.setRandomValue(123) and TypeScript wouldn't know. we should be reserving const for literal values only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't matter though. I'm strongly in favor of using the strictest specifier whenever possible for variables. It signals to the developer that the variable binding should never change, and devs are expected to know JS/TS semantics enough to know that the values inside that object might change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, that's unrelated to this change. Bring it up in a separate issue/PR.

@ashwinr
Copy link
Contributor

ashwinr commented Jun 26, 2015

Review status: 0 of 5 files reviewed at latest revision, 2 unresolved discussions, all commit checks successful.


src/rules/noUnusedVariableRule.ts, line 59 [r1] (raw file):
change this back to what it was and same thing down below. single-line comments start with a lower-case as a style convention. i'm going to change all other single-line comments to start lowercase


src/rules/noUseBeforeDeclareRule.ts, line 50 [r1] (raw file):
disagree. let's take it up in a separate issue.


Comments from the review on Reviewable.io

@@ -56,8 +56,9 @@ class NoUnusedVariablesWalker extends Lint.RuleWalker {
if (!Lint.hasModifier(node.modifiers, ts.SyntaxKind.ExportKeyword)) {
const importClause = node.importClause;

// named imports & namespace imports handled by other walker methods
if (importClause.name != null) {
// Named imports & namespace imports handled by other walker methods.
Copy link
Contributor

Choose a reason for hiding this comment

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

fixed all code comments in #470. revert this comment to its original format. same thing in noUseBeforeDeclareRule.

Fixes #451

This affects the following rules:

- `no-unused-variable`
- `no-use-before-declare`
- `whitespace` (it was already handled here, but I added a regression test)
@adidahiya adidahiya force-pushed the bugfix-bare-imports branch from 21ad3d5 to 5398f44 Compare June 26, 2015 15:28
@adidahiya
Copy link
Contributor Author

addressed feedback and --amended

@ashwinr
Copy link
Contributor

ashwinr commented Jun 26, 2015

👍 waiting for builds to finish

@ashwinr
Copy link
Contributor

ashwinr commented Jun 26, 2015

why do builds take so long

@adidahiya
Copy link
Contributor Author

TravisCI has been pretty slow lately. 🐌

ashwinr added a commit that referenced this pull request Jun 26, 2015
@ashwinr ashwinr merged commit 514510f into master Jun 26, 2015
@ashwinr ashwinr deleted the bugfix-bare-imports branch June 26, 2015 17:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants