Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
small refactorings and updating the thirdpartynotices.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
egamma committed Apr 10, 2016
1 parent 1be249a commit 7aa840f
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 38 deletions.
21 changes: 11 additions & 10 deletions thirdpartynotices.txt
@@ -1,31 +1,32 @@
THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
For Microsoft vscode-tslint

This project incorporates material from the project(s) listed below (collectively, “Third Party Code”).
Microsoft is not the original author of the Third Party Code. The original copyright notice and license
under which Microsoft received such Third Party Code are set out below. This Third Party Code is licensed
to you under their original license terms set forth below. Microsoft reserves all other rights not expressly
Microsoft is not the original author of the Third Party Code. The original copyright notice and license
under which Microsoft received such Third Party Code are set out below. This Third Party Code is licensed
to you under their original license terms set forth below. Microsoft reserves all other rights not expressly
granted, whether by implication, estoppel or otherwise.

1. DefinitelyTyped version 0.0.1 (https://github.com/borisyankov/DefinitelyTyped)

This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
2. minimatch version 3.0.0 (https://github.com/isaacs/minimatch)
55 changes: 32 additions & 23 deletions tslint-server/src/server.ts
Expand Up @@ -11,7 +11,7 @@ import * as fs from 'fs';
interface Settings {
tslint: {
enable: boolean;
rulesDirectory: string;
rulesDirectory: string | string[];
configFile: string;
ignoreDefinitionFiles: boolean;
exclude: string | string[];
Expand Down Expand Up @@ -153,25 +153,8 @@ function doValidate(conn: server.IConnection, document: server.ITextDocument): s
return diagnostics;
}

if (settings && settings.tslint) {
if (settings.tslint.ignoreDefinitionFiles) {
if (minimatch(fsPath, "**/*.d.ts")) {
return diagnostics;
}
}

if (settings.tslint.exclude) {
if (Array.isArray(settings.tslint.exclude)) {
for (var pattern of settings.tslint.exclude) {
if (minimatch(fsPath, pattern)) {
return diagnostics;
}
}
}
else if (minimatch(fsPath, <string>settings.tslint.exclude)) {
return diagnostics;
}
}
if (fileIsExcluded(fsPath)) {
return diagnostics;
}

let contents = document.getText();
Expand All @@ -183,8 +166,8 @@ function doValidate(conn: server.IConnection, document: server.ITextDocument): s
return diagnostics;
}

if (configCache.isDefaultConfig && settings.tslint.validateWithDefaultConfig === false) {
return;
if (settings && settings.tslint && settings.tslint.validateWithDefaultConfig === false && configCache.isDefaultConfig) {
return diagnostics;
}

let result: Lint.LintResult;
Expand All @@ -203,10 +186,36 @@ function doValidate(conn: server.IConnection, document: server.ITextDocument): s
diagnostics.push(makeDiagnostic(each));
});
}

return diagnostics;
}

function fileIsExcluded(path: string): boolean {
function testForExclusionPattern(path: string, pattern: string): boolean {
return minimatch(path, pattern)
}

if (settings && settings.tslint) {
if (settings.tslint.ignoreDefinitionFiles) {
if (minimatch(path, "**/*.d.ts")) {
return true;
}
}

if (settings.tslint.exclude) {
if (Array.isArray(settings.tslint.exclude)) {
for (var pattern of settings.tslint.exclude) {
if (testForExclusionPattern(path, pattern)) {
return true;
}
}
}
else if (testForExclusionPattern(path, <string>settings.tslint.exclude)) {
return true;
}
}
}
}

// A text document has changed. Validate the document.
documents.onDidChangeContent((event) => {
// the contents of a text document has changed
Expand Down
2 changes: 1 addition & 1 deletion tslint-server/src/typings/tslint/tslint.d.ts
Expand Up @@ -14,7 +14,7 @@ declare module Lint {
configuration: any;
formatter: string;
formattersDirectory: string;
rulesDirectory: string;
rulesDirectory: string | string[];
}
class Linter {
static VERSION: string;
Expand Down
6 changes: 4 additions & 2 deletions tslint/README.md
Expand Up @@ -20,8 +20,10 @@ When you are using TypeScript version 1.7 then at least version 3.1.1 is require
- `tslint.validateWithDefaultConfig` - validate a file for which there was no custom tslint confguration found. The default is `false`.

# Release Notes
## 0.5.16
- Added the setting `tslint.validateWithDefaultConfig`. It enables to configure that no tslint validation is run when the default tslint configuration settings would be used.
## 0.5.17
- Added setting `tslint.validateWithDefaultConfig`.
- Added setting `tslint.ignoreDefinitionFiles`.
- Added setting `tslint.ignoreDefinitionFiles`.

## 0.5.15
- Watch for changes in the tslint.json when the file is located outside of the workspace.
Expand Down
7 changes: 5 additions & 2 deletions tslint/package.json
@@ -1,7 +1,7 @@
{
"name": "tslint",
"description": "TSLint for Visual Studio Code",
"version": "0.5.16",
"version": "0.5.17",
"publisher": "eg2",
"icon": "TSLint_icon.svg",
"galleryBanner": {
Expand Down Expand Up @@ -39,7 +39,10 @@
"description": "Control whether tslint is enabled for TypeScript files or not."
},
"tslint.rulesDirectory": {
"type": "string",
"type": ["string", "array"],
"items": {
"type": "string"
},
"description": "An additional rules directory",
"default": ""
},
Expand Down

0 comments on commit 7aa840f

Please sign in to comment.