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

Implement polymer lint --watch #928

Merged
merged 6 commits into from
Nov 21, 2017
Merged

Implement polymer lint --watch #928

merged 6 commits into from
Nov 21, 2017

Conversation

rictic
Copy link
Contributor

@rictic rictic commented Nov 16, 2017

  • CHANGELOG.md has been updated

@rictic rictic force-pushed the lint-watch branch 2 times, most recently from 4416e32 to 0cc27dc Compare November 17, 2017 03:34
@rictic rictic changed the base branch from master to update-deps November 17, 2017 03:34
@rictic rictic force-pushed the lint-watch branch 3 times, most recently from 6d5475c to 2b60857 Compare November 17, 2017 18:45
@rictic rictic changed the base branch from update-deps to master November 17, 2017 20:43
Introduces some logic to ensure that we react to the changes from
lint fixes quickly, but without doing duplicated back-to-back runs,
which would be very noisy for users (as well as being difficult
to test).
src/lint/lint.ts Outdated
reportIfNoFix?: boolean;
}

async function runOnce(
Copy link
Contributor

Choose a reason for hiding this comment

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

+docs! also I'd prefer run instead of runOnce, I think run being singular is implied, especially if there's a second method that is explicitly "multiple/loop/watch/etc"

src/lint/lint.ts Outdated
for await(const changeBatch of watcher) {
await analyzer.filesChanged([...changeBatch]);

await runOnce(
Copy link
Contributor

Choose a reason for hiding this comment

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

oh, wait, do you pass a watcher to runOnce()? Can you document this?

src/lint/lint.ts Outdated
});
}

private noticeChange(path: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

+docs!

src/lint/lint.ts Outdated
this.outOfBandNotices.add(path);
}

async * [Symbol.asyncIterator](): AsyncIterator<Set<string>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

+docs!

@rictic
Copy link
Contributor Author

rictic commented Nov 18, 2017

All comments addressed!

@rictic rictic requested review from FredKSchott and removed request for justinfagnani November 20, 2017 16:32
@rictic
Copy link
Contributor Author

rictic commented Nov 20, 2017

[Justin's out this week, so passing this review over to Fred]

Copy link
Contributor

@FredKSchott FredKSchott left a comment

Choose a reason for hiding this comment

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

great stuff!

@@ -67,7 +67,7 @@ gulp.task(
}))
.pipe(tslint.report()));

gulp.task('depcheck', () => {
gulp.task('depcheck', ['build'], () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

why build first? it should be analyzing our typescript directly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this change it crashes saying that chokidar is unused.

Adding some console.log statements around makes me think that it's unable to handle lint/lint.ts, giving a warning in the babylon parser, a little bit after an await statement. It seems like it's not handling typescript perfectly. Fortunately by ensuring that build happens first, it will also run over our generated JS, which it does handle correctly.

* Run a single pass of the linter, and then report the results or fix warnings
* as requested by `options`.
*
* In a normal run this is called once and then it's done. When running with
Copy link
Contributor

Choose a reason for hiding this comment

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

super clear 👍

new Set([...analysis.getFeatures({kind: 'document'})].map((d) => d.url));
const watcher = new FilesystemChangeStream(
chokidar.watch([...paths], {persistent: true}));
for await (const changeBatch of watcher) {
Copy link
Contributor

Choose a reason for hiding this comment

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

man, for await is wild.

So the intention is that this iterator never completes, until the user kills the process, correct? That would be worth a comment, just to make sure future readers don't follow through past this.

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 know right!? It's the best.

I added a comment mentioning that this is a forever loop.

@@ -183,6 +184,77 @@ Fixed 4 warnings.
</dom-module>
`);
});

suite('--watch', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

clever test 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

@rictic rictic merged commit 5af52d9 into master Nov 21, 2017
@rictic rictic deleted the lint-watch branch November 21, 2017 01:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants