Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
listen to .jshintignore file changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kieferrm committed May 2, 2016
1 parent 9dd888d commit 49b9258
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
28 changes: 24 additions & 4 deletions jshint-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class FileMatcher {
if (ignoreFile) {
shouldBeExcluded = this.match(processIgnoreFile(ignoreFile), fsPath, this.folderOf(ignoreFile));
} else {
shouldBeExcluded = this.match(this.defaultExcludePatterns, fsPath, root);
shouldBeExcluded = this.match(this.defaultExcludePatterns, fsPath, root);
}

this.excludeCache[fsPath] = shouldBeExcluded;
Expand Down Expand Up @@ -343,16 +343,36 @@ class Linter {
this.validateAll();
});
this.connection.onDidChangeWatchedFiles(params => {
this.options.clear();
this.fileMatcher.clear();
this.validateAll();
var needsValidating = false;
if (params.changes) {
params.changes.forEach(change => {
switch (this.lastSegment(change.uri)) {
case JSHINTRC:
this.options.clear();
needsValidating = true;
break;
case JSHINTIGNORE:
this.fileMatcher.clear();
needsValidating = true;
break;
}
});
}
if (needsValidating) {
this.validateAll();
}
})
}

public listen(): void {
this.connection.listen();
}

private lastSegment(fsPath: string): string {
let index = fsPath.lastIndexOf('/');
return index > -1 ? fsPath.substr(index + 1) : fsPath;
}

private onInitialize(params: InitializeParams): Thenable<InitializeResult | ResponseError<InitializeError>> {
this.workspaceRoot = params.rootPath;
return Files.resolveModule(this.workspaceRoot, 'jshint').then((value) => {
Expand Down
2 changes: 1 addition & 1 deletion jshint/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function activate(context: ExtensionContext) {
documentSelector: ['javascript', 'javascriptreact'],
synchronize: {
configurationSection: 'jshint',
fileEvents: workspace.createFileSystemWatcher('**/.jshintrc')
fileEvents: workspace.createFileSystemWatcher('**/.jshint{rc,ignore}')
}
}

Expand Down

0 comments on commit 49b9258

Please sign in to comment.