Comparing version 5.10.0 to 5.11.0
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
export declare const rules: { | ||
@@ -115,2 +131,3 @@ "adjacent-overload-signatures": boolean; | ||
"encoding": boolean; | ||
"file-name-casing": (string | boolean)[]; | ||
"import-spacing": boolean; | ||
@@ -117,0 +134,0 @@ "interface-name": boolean; |
@@ -187,2 +187,3 @@ "use strict"; | ||
"encoding": true, | ||
"file-name-casing": [true, "camel-case"], | ||
"import-spacing": true, | ||
@@ -189,0 +190,0 @@ "interface-name": true, |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { IOptions, RuleSeverity } from "./language/rule/rule"; | ||
@@ -2,0 +18,0 @@ export interface IConfigurationFile { |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2014 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import { RuleFailure } from "./language/rule/rule"; |
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
/** | ||
* Generic error typing for EcmaScript errors | ||
@@ -17,3 +33,3 @@ * Define `Error` here to avoid using `Error` from @types/node. | ||
message: string; | ||
innerError: Error | undefined; | ||
innerError?: Error | undefined; | ||
static NAME: string; | ||
@@ -20,0 +36,0 @@ constructor(message: string, innerError?: Error | undefined); |
@@ -0,2 +1,18 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { FormatterConstructor } from "./index"; | ||
export declare function findFormatter(name: string | FormatterConstructor, formattersDirectory?: string): FormatterConstructor | undefined; |
@@ -23,3 +23,3 @@ /** | ||
format(failures: RuleFailure[]): string; | ||
private escapeXml(str); | ||
private escapeXml; | ||
} |
@@ -23,3 +23,3 @@ /** | ||
format(failures: RuleFailure[]): string; | ||
private escapeXml(str); | ||
private escapeXml; | ||
} |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { AbstractFormatter } from "../language/formatter/abstractFormatter"; | ||
@@ -2,0 +18,0 @@ import { IFormatterMetadata } from "../language/formatter/formatter"; |
@@ -23,6 +23,6 @@ /** | ||
format(failures: RuleFailure[]): string; | ||
private mapToMessages(failures); | ||
private pad(str, len); | ||
private getPositionMaxSize(failures); | ||
private getRuleMaxSize(failures); | ||
private mapToMessages; | ||
private pad; | ||
private getPositionMaxSize; | ||
private getRuleMaxSize; | ||
} |
@@ -23,3 +23,3 @@ /** | ||
format(failures: RuleFailure[]): string; | ||
private mapToMessages(failures); | ||
private mapToMessages; | ||
} |
@@ -23,3 +23,3 @@ /** | ||
format(failures: RuleFailure[]): string; | ||
private mapToMessages(failures); | ||
private mapToMessages; | ||
} |
@@ -168,3 +168,3 @@ /** | ||
private readonly ruleName; | ||
private readonly fix; | ||
private readonly fix?; | ||
private readonly fileName; | ||
@@ -189,3 +189,3 @@ private readonly startPosition; | ||
equals(ruleFailure: RuleFailure): boolean; | ||
private createFailurePosition(position); | ||
private createFailurePosition; | ||
} |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import { IDisabledInterval, RuleFailure } from "./rule/rule"; |
@@ -37,3 +37,3 @@ /** | ||
protected visitNode(node: ts.Node): void; | ||
private isBlockScopeBoundary(node); | ||
private isBlockScopeBoundary; | ||
} |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -10,3 +26,3 @@ import { findConfiguration, findConfigurationPath, getRulesDirectories, IConfigurationFile, loadConfigurationFromPath } from "./configuration"; | ||
private readonly options; | ||
private program; | ||
private program?; | ||
static VERSION: string; | ||
@@ -31,9 +47,9 @@ static findConfiguration: typeof findConfiguration; | ||
getResult(): LintResult; | ||
private getAllFailures(sourceFile, enabledRules); | ||
private applyAllFixes(enabledRules, fileFailures, sourceFile, sourceFileName); | ||
private getAllFailures; | ||
private applyAllFixes; | ||
protected applyFixes(sourceFilePath: string, source: string, fixableFailures: RuleFailure[]): string; | ||
private updateProgram(sourceFilePath); | ||
private applyRule(rule, sourceFile); | ||
private getEnabledRules(configuration, isJs); | ||
private getSourceFile(fileName, source); | ||
private updateProgram; | ||
private applyRule; | ||
private getEnabledRules; | ||
private getSourceFile; | ||
} |
@@ -230,3 +230,3 @@ "use strict"; | ||
}; | ||
Linter.VERSION = "5.10.0"; | ||
Linter.VERSION = "5.11.0"; | ||
Linter.findConfiguration = configuration_1.findConfiguration; | ||
@@ -233,0 +233,0 @@ Linter.findConfigurationPath = configuration_1.findConfigurationPath; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { IOptions, IRule, RuleConstructor } from "./language/rule/rule"; | ||
@@ -2,0 +18,0 @@ export declare function loadRules(ruleOptionsList: IOptions[], rulesDirectories?: string | string[], isJs?: boolean): IRule[]; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -52,3 +52,3 @@ "use strict"; | ||
tsutils_1.isInterfaceDeclaration(node)) { | ||
if (!isPascalCased(node.name.text)) { | ||
if (!utils_1.isPascalCased(node.name.text)) { | ||
ctx.addFailureAtNode(node.name, Rule.FAILURE_STRING); | ||
@@ -60,5 +60,2 @@ } | ||
} | ||
function isPascalCased(name) { | ||
return utils_1.isUpperCase(name[0]) && !name.includes("_"); | ||
} | ||
var templateObject_1; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
export declare const codeExamples: { | ||
@@ -2,0 +18,0 @@ description: string; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
export declare const codeExamples: { | ||
@@ -2,0 +18,0 @@ description: string; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2018 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
export declare const codeExamples: { | ||
@@ -2,0 +18,0 @@ description: string; |
@@ -26,6 +26,6 @@ "use strict"; | ||
config: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n \"rules\": { \"prefer-while\": true }\n "], ["\n \"rules\": { \"prefer-while\": true }\n "]))), | ||
pass: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n for(let x = 1; x < 10; x++) {\n console.log(x);\n }\n\n for (let i = 0; i < 10; x+=1) {\n console.log(x);\n }\n\n for (let i = 0; i < 10;) {\n i += 1;\n }\n "], ["\n for(let x = 1; x < 10; x++) {\n console.log(x);\n }\n\n for (let i = 0; i < 10; x+=1) {\n console.log(x);\n }\n\n for (let i = 0; i < 10;) {\n i += 1;\n }\n "]))), | ||
fail: Lint.Utils.dedent(templateObject_3 || (templateObject_3 = tslib_1.__makeTemplateObject(["\n for(;;) {\n console.log(x);\n }\n\n for(;true===true;) {\n console.log(x);\n }\n "], ["\n for(;;) {\n console.log(x);\n }\n\n for(;true===true;) {\n console.log(x);\n }\n "]))), | ||
pass: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n for(let i = 1; i < 10; i++) {\n console.log(i);\n }\n\n for (let i = 0; i < 10; i+=1) {\n console.log(i);\n }\n\n for (let i = 0; i < 10;) {\n i += 1;\n }\n "], ["\n for(let i = 1; i < 10; i++) {\n console.log(i);\n }\n\n for (let i = 0; i < 10; i+=1) {\n console.log(i);\n }\n\n for (let i = 0; i < 10;) {\n i += 1;\n }\n "]))), | ||
fail: Lint.Utils.dedent(templateObject_3 || (templateObject_3 = tslib_1.__makeTemplateObject(["\n for(;;) {\n console.log('Hello World');\n }\n\n for(;true===true;) {\n console.log('Hello World');\n }\n "], ["\n for(;;) {\n console.log('Hello World');\n }\n\n for(;true===true;) {\n console.log('Hello World');\n }\n "]))), | ||
}, | ||
]; | ||
var templateObject_1, templateObject_2, templateObject_3; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import { Visibility } from "../completedDocsRule"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -12,4 +28,4 @@ import { Location, Privacy } from "../completedDocsRule"; | ||
excludes(node: ts.Node): boolean; | ||
private shouldLocationBeDocumented(node); | ||
private shouldPrivacyBeDocumented(node); | ||
private shouldLocationBeDocumented; | ||
private shouldPrivacyBeDocumented; | ||
} |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { DocType } from "../completedDocsRule"; | ||
@@ -7,4 +23,4 @@ import { Exclusion } from "./exclusion"; | ||
constructExclusionsMap(ruleArguments: IInputExclusionDescriptors[]): ExclusionsMap; | ||
private addRequirements(exclusionsMap, descriptors); | ||
private createRequirementsForDocType(docType, descriptor); | ||
private addRequirements; | ||
private createRequirementsForDocType; | ||
} |
@@ -32,4 +32,4 @@ /** | ||
excludes(node: ts.Node): boolean; | ||
private getDocumentationNode(node); | ||
private parseTagsWithContents(nodeText); | ||
private getDocumentationNode; | ||
private parseTagsWithContents; | ||
} |
@@ -109,3 +109,3 @@ /** | ||
applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; | ||
private getExclusionsMap(ruleArguments); | ||
private getExclusionsMap; | ||
} |
@@ -20,2 +20,3 @@ "use strict"; | ||
var tslib_1 = require("tslib"); | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q; | ||
var ts = require("typescript"); | ||
@@ -345,2 +346,1 @@ var Lint = require("../index"); | ||
var templateObject_1, templateObject_2; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -69,3 +69,3 @@ "use strict"; | ||
var maxBytesRead = 3; // Only need 3 bytes to detect the encoding. | ||
var buffer = new Buffer(maxBytesRead); | ||
var buffer = Buffer.allocUnsafe(maxBytesRead); | ||
var bytesRead = fs.readSync(fd, buffer, /*offset*/ 0, /*length*/ maxBytesRead, /*position*/ 0); | ||
@@ -72,0 +72,0 @@ fs.closeSync(fd); |
@@ -23,3 +23,3 @@ /** | ||
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; | ||
private createComment(sourceFile, commentText, leadingNewlines?, trailingNewlines?); | ||
private createComment; | ||
} |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -55,3 +55,3 @@ "use strict"; | ||
function walk(ctx) { | ||
for (var _i = 0, _a = tsutils_1.findImports(ctx.sourceFile, 31 /* All */); _i < _a.length; _i++) { | ||
for (var _i = 0, _a = tsutils_1.findImports(ctx.sourceFile, 63 /* All */); _i < _a.length; _i++) { | ||
var name = _a[_i]; | ||
@@ -58,0 +58,0 @@ if (ctx.options.indexOf(name.text) !== -1) { |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -8,3 +24,3 @@ import * as Lint from "../index"; | ||
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; | ||
private getRuleOptions(); | ||
private getRuleOptions; | ||
} |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -128,3 +128,4 @@ "use strict"; | ||
description: "Enforces member ordering.", | ||
rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n A consistent ordering for class members can make classes easier to read, navigate, and edit.\n\n A common opposite practice to `member-ordering` is to keep related groups of classes together.\n Instead of creating clases with multiple separate groups, consider splitting class responsibilities\n apart across multiple single-responsibility classes.\n "], ["\n A consistent ordering for class members can make classes easier to read, navigate, and edit.\n\n A common opposite practice to \\`member-ordering\\` is to keep related groups of classes together.\n Instead of creating clases with multiple separate groups, consider splitting class responsibilities\n apart across multiple single-responsibility classes.\n "]))), | ||
hasFix: true, | ||
rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n A consistent ordering for class members can make classes easier to read, navigate, and edit.\n\n A common opposite practice to `member-ordering` is to keep related groups of classes together.\n Instead of creating classes with multiple separate groups, consider splitting class responsibilities\n apart across multiple single-responsibility classes.\n "], ["\n A consistent ordering for class members can make classes easier to read, navigate, and edit.\n\n A common opposite practice to \\`member-ordering\\` is to keep related groups of classes together.\n Instead of creating classes with multiple separate groups, consider splitting class responsibilities\n apart across multiple single-responsibility classes.\n "]))), | ||
optionsDescription: optionsDescription, | ||
@@ -192,3 +193,5 @@ options: { | ||
function MemberOrderingWalker() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.fixes = []; | ||
return _this; | ||
} | ||
@@ -198,2 +201,4 @@ MemberOrderingWalker.prototype.walk = function (sourceFile) { | ||
var cb = function (node) { | ||
// NB: iterate through children first! | ||
ts.forEachChild(node, cb); | ||
switch (node.kind) { | ||
@@ -206,9 +211,23 @@ case ts.SyntaxKind.ClassDeclaration: | ||
} | ||
return ts.forEachChild(node, cb); | ||
}; | ||
return ts.forEachChild(sourceFile, cb); | ||
ts.forEachChild(sourceFile, cb); | ||
// assign Replacements which have not been merged into surrounding ones to their RuleFailures. | ||
this.fixes.forEach(function (_a) { | ||
var failure = _a[0], replacement = _a[1]; | ||
failure.getFix().push(replacement); | ||
}); | ||
}; | ||
/** | ||
* Check wether the passed members adhere to the configured order. If not, RuleFailures are generated and a single | ||
* Lint.Replacement is generated, which replaces the entire NodeArray with a correctly sorted one. The Replacement | ||
* is not immediately added to a RuleFailure, as incorrectly sorted nodes can be nested (e.g. a class declaration | ||
* in a method implementation), but instead temporarily stored in `this.fixes`. Nested Replacements are manually | ||
* merged, as TSLint doesn't handle overlapping ones. For this reason it is important that the recursion happens | ||
* before the checkMembers call in this.walk(). | ||
*/ | ||
MemberOrderingWalker.prototype.checkMembers = function (members) { | ||
var _this = this; | ||
var prevRank = -1; | ||
var prevName; | ||
var failureExists = false; | ||
for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { | ||
@@ -230,3 +249,5 @@ var member = members_1[_i]; | ||
("Instead, this should come " + locationHint + "."); | ||
this.addFailureAtNode(member, errorLine1); | ||
// add empty array as fix so we can add a replacement later. (fix itself is readonly) | ||
this.addFailureAtNode(member, errorLine1, []); | ||
failureExists = true; | ||
} | ||
@@ -241,3 +262,4 @@ else { | ||
if (prevName !== undefined && caseInsensitiveLess(curName, prevName)) { | ||
this.addFailureAtNode(member.name, Rule.FAILURE_STRING_ALPHABETIZE(this.findLowerName(members, rank, curName), curName)); | ||
this.addFailureAtNode(member.name, Rule.FAILURE_STRING_ALPHABETIZE(this.findLowerName(members, rank, curName), curName), []); | ||
failureExists = true; | ||
} | ||
@@ -252,2 +274,52 @@ else { | ||
} | ||
if (failureExists) { | ||
var sortedMemberIndexes = members.map(function (_, i) { return i; }).sort(function (ai, bi) { | ||
var a = members[ai]; | ||
var b = members[bi]; | ||
// first, sort by member rank | ||
var rankDiff = _this.memberRank(a) - _this.memberRank(b); | ||
if (rankDiff !== 0) { | ||
return rankDiff; | ||
} | ||
// then lexicographically if alphabetize == true | ||
if (_this.options.alphabetize && a.name !== undefined && b.name !== undefined) { | ||
var aName = nameString(a.name); | ||
var bName = nameString(b.name); | ||
var nameDiff = aName.localeCompare(bName); | ||
if (nameDiff !== 0) { | ||
return nameDiff; | ||
} | ||
} | ||
// finally, sort by position in original NodeArray so the sort remains stable. | ||
return ai - bi; | ||
}); | ||
var splits_1 = getSplitIndexes(members, this.sourceFile.text); | ||
var sortedMembersText = sortedMemberIndexes.map(function (i) { | ||
var start = splits_1[i]; | ||
var end = splits_1[i + 1]; | ||
var nodeText = _this.sourceFile.text.substring(start, end); | ||
while (true) { | ||
// check if there are previous fixes which we need to merge into this one | ||
// if yes, remove it from the list so that we do not return overlapping Replacements | ||
var fixIndex = arrayFindLastIndex(_this.fixes, function (_a) { | ||
var r = _a[1]; | ||
return r.start >= start && r.start + r.length <= end; | ||
}); | ||
if (fixIndex === -1) { | ||
break; | ||
} | ||
var fix = _this.fixes.splice(fixIndex, 1)[0]; | ||
var replacement = fix[1]; | ||
nodeText = applyReplacementOffset(nodeText, replacement, start); | ||
} | ||
return nodeText; | ||
}); | ||
// instead of assigning the fix immediately to the last failure, we temporarily store it in `this.fixes`, | ||
// in case a containing node needs to be fixed too. We only "add" the fix to the last failure, although | ||
// it fixes all failures in this NodeArray, as TSLint doesn't handle duplicate Replacements. | ||
this.fixes.push([ | ||
arrayLast(this.failures), | ||
Lint.Replacement.replaceFromTo(splits_1[0], arrayLast(splits_1), sortedMembersText.join("")), | ||
]); | ||
} | ||
}; | ||
@@ -444,2 +516,108 @@ /** Finds the lowest name higher than 'targetName'. */ | ||
} | ||
/** | ||
* Returns the last element of an array. (Or undefined). | ||
*/ | ||
function arrayLast(array) { | ||
return array[array.length - 1]; | ||
} | ||
/** | ||
* Array.prototype.findIndex, but the last index. | ||
*/ | ||
function arrayFindLastIndex(array, predicate) { | ||
for (var i = array.length; i-- > 0;) { | ||
if (predicate(array[i], i, array)) { | ||
return i; | ||
} | ||
} | ||
return -1; | ||
} | ||
/** | ||
* Applies a Replacement to a part of the text which starts at offset. | ||
* See also Replacement.apply | ||
*/ | ||
function applyReplacementOffset(content, replacement, offset) { | ||
return content.substring(0, replacement.start - offset) | ||
+ replacement.text | ||
+ content.substring(replacement.start - offset + replacement.length); | ||
} | ||
/** | ||
* Get the indexes of the boundaries between nodes in the node array. The following points must be taken into account: | ||
* - Trivia should stay with its corresponding node (comments on the same line following the token belong to the | ||
* previous token, the rest to the next). | ||
* - Reordering the subtexts should not result in code being commented out due to being moved between a "//" and | ||
* the following newline. | ||
* - The end of one node must be the start of the next, otherwise the intravening whitespace will be lost when | ||
* reordering. | ||
* | ||
* Hence, the boundaries are chosen to be _after_ the newline following the node, or the beginning of the next token, | ||
* if that comes first. | ||
*/ | ||
function getSplitIndexes(members, text) { | ||
var result = members.map(function (member) { return getNextSplitIndex(text, member.getFullStart()); }); | ||
result.push(getNextSplitIndex(text, arrayLast(members).getEnd())); | ||
return result; | ||
} | ||
/** | ||
* Calculates the index after the newline following pos, or the beginning of the next token, whichever comes first. | ||
* See also getSplitIndexes. | ||
* This method is a modified version of TypeScript's internal iterateCommentRanges function. | ||
*/ | ||
function getNextSplitIndex(text, pos) { | ||
scan: while (pos >= 0 && pos < text.length) { | ||
var ch = text.charCodeAt(pos); | ||
switch (ch) { | ||
case 13 /* carriageReturn */: | ||
if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { | ||
pos++; | ||
} | ||
// falls through | ||
case 10 /* lineFeed */: | ||
pos++; | ||
// split is after new line | ||
return pos; | ||
case 9 /* tab */: | ||
case 11 /* verticalTab */: | ||
case 12 /* formFeed */: | ||
case 32 /* space */: | ||
// skip whitespace | ||
pos++; | ||
continue; | ||
case 47 /* slash */: | ||
var nextChar = text.charCodeAt(pos + 1); | ||
if (nextChar === 47 /* slash */ || nextChar === 42 /* asterisk */) { | ||
var isSingleLineComment = nextChar === 47 /* slash */; | ||
pos += 2; | ||
if (isSingleLineComment) { | ||
while (pos < text.length) { | ||
if (ts.isLineBreak(text.charCodeAt(pos))) { | ||
// the comment ends here, go back to default logic to handle parsing new line and result | ||
continue scan; | ||
} | ||
pos++; | ||
} | ||
} | ||
else { | ||
while (pos < text.length) { | ||
if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { | ||
pos += 2; | ||
continue scan; | ||
} | ||
pos++; | ||
} | ||
} | ||
// if we arrive here, it's because pos == text.length | ||
return pos; | ||
} | ||
break scan; | ||
default: | ||
// skip whitespace: | ||
if (ch > 127 /* maxAsciiCharacter */ && (ts.isWhiteSpaceLike(ch))) { | ||
pos++; | ||
continue; | ||
} | ||
break scan; | ||
} | ||
} | ||
return pos; | ||
} | ||
var templateObject_1, templateObject_2; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from ".."; |
@@ -67,2 +67,3 @@ "use strict"; | ||
function hasChildCall(node) { | ||
var _a; | ||
var expression = node.expression; | ||
@@ -74,4 +75,3 @@ while (tsutils_1.isPropertyAccessExpression(expression) || | ||
return expression.kind === ts.SyntaxKind.CallExpression; | ||
var _a; | ||
} | ||
var templateObject_1, templateObject_2; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2015 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -54,8 +54,7 @@ "use strict"; | ||
return ts.forEachChild(ctx.sourceFile, function cb(node) { | ||
if (tsutils_1.isCallExpression(node) && | ||
tsutils_1.isPropertyAccessExpression(node.expression) && | ||
tsutils_1.isIdentifier(node.expression.expression) && | ||
node.expression.expression.text === "console" && | ||
(ctx.options.length === 0 || ctx.options.indexOf(node.expression.name.text) !== -1)) { | ||
ctx.addFailureAtNode(node.expression, Rule.FAILURE_STRING_FACTORY(node.expression.name.text)); | ||
if (tsutils_1.isPropertyAccessExpression(node) && | ||
tsutils_1.isIdentifier(node.expression) && | ||
node.expression.text === "console" && | ||
(ctx.options.length === 0 || ctx.options.indexOf(node.name.text) !== -1)) { | ||
ctx.addFailureAtNode(node, Rule.FAILURE_STRING_FACTORY(node.name.text)); | ||
} | ||
@@ -62,0 +61,0 @@ return ts.forEachChild(node, cb); |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -62,3 +62,5 @@ "use strict"; | ||
function NoDuplicateVariableWalker() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.scope = new Set(); | ||
return _this; | ||
} | ||
@@ -65,0 +67,0 @@ NoDuplicateVariableWalker.prototype.walk = function (sourceFile) { |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -93,3 +93,4 @@ "use strict"; | ||
if (options.allowEmptyFunctions && | ||
(node.kind === ts.SyntaxKind.FunctionDeclaration || | ||
(node.kind === ts.SyntaxKind.MethodDeclaration || | ||
node.kind === ts.SyntaxKind.FunctionDeclaration || | ||
node.kind === ts.SyntaxKind.FunctionExpression || | ||
@@ -96,0 +97,0 @@ node.kind === ts.SyntaxKind.ArrowFunction)) { |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -45,3 +45,3 @@ "use strict"; | ||
optionExamples: [true, [true, "JQueryPromise"]], | ||
rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Creating a Promise and not storing or returning may lets other code run independent of of its results.\n This can cause unexpected and/or non-deterministic behavior depending on external timing factors.\n\n It's typically better to return Promises from functions that start them, then handle them in calling code.\n\n Use `no-unused-expression` in addition to this rule to reveal even more floating promises.\n "], ["\n Creating a Promise and not storing or returning may lets other code run independent of of its results.\n This can cause unexpected and/or non-deterministic behavior depending on external timing factors.\n\n It's typically better to return Promises from functions that start them, then handle them in calling code.\n\n Use \\`no-unused-expression\\` in addition to this rule to reveal even more floating promises.\n "]))), | ||
rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Creating a Promise and not storing or returning it may let other code run independently of its result.\n This can cause unexpected and/or non-deterministic behavior depending on external timing factors.\n\n It's typically better to return Promises from functions that start them, then handle them in calling code.\n\n Use `no-unused-expression` in addition to this rule to reveal even more floating promises.\n "], ["\n Creating a Promise and not storing or returning it may let other code run independently of its result.\n This can cause unexpected and/or non-deterministic behavior depending on external timing factors.\n\n It's typically better to return Promises from functions that start them, then handle them in calling code.\n\n Use \\`no-unused-expression\\` in addition to this rule to reveal even more floating promises.\n "]))), | ||
type: "functionality", | ||
@@ -48,0 +48,0 @@ typescriptOnly: true, |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -38,5 +38,10 @@ "use strict"; | ||
Rule.prototype.apply = function (sourceFile) { | ||
var whitelist = this.ruleArguments.find(function (arg) { return Array.isArray(arg); }); | ||
if (whitelist === null || whitelist === undefined) { | ||
whitelist = []; | ||
} | ||
return this.applyWithFunction(sourceFile, walk, { | ||
dev: this.ruleArguments.indexOf(OPTION_DEV) !== -1, | ||
optional: this.ruleArguments.indexOf(OPTION_OPTIONAL) !== -1, | ||
whitelist: whitelist, | ||
}); | ||
@@ -49,13 +54,23 @@ }; | ||
descriptionDetails: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Disallows importing transient dependencies and modules installed above your package's root directory.\n "], ["\n Disallows importing transient dependencies and modules installed above your package's root directory.\n "]))), | ||
optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n By default the rule looks at `\"dependencies\"` and `\"peerDependencies\"`.\n By adding the `\"", "\"` option the rule looks at `\"devDependencies\"` instead of `\"peerDependencies\"`.\n By adding the `\"", "\"` option the rule also looks at `\"optionalDependencies\"`.\n "], ["\n By default the rule looks at \\`\"dependencies\"\\` and \\`\"peerDependencies\"\\`.\n By adding the \\`\"", "\"\\` option the rule looks at \\`\"devDependencies\"\\` instead of \\`\"peerDependencies\"\\`.\n By adding the \\`\"", "\"\\` option the rule also looks at \\`\"optionalDependencies\"\\`.\n "])), OPTION_DEV, OPTION_OPTIONAL), | ||
optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n By default the rule looks at `\"dependencies\"` and `\"peerDependencies\"`.\n By adding the `\"", "\"` option the rule also looks at `\"devDependencies\"`.\n By adding the `\"", "\"` option the rule also looks at `\"optionalDependencies\"`.\n An array of whitelisted modules can be added to skip checking their existence in package.json.\n "], ["\n By default the rule looks at \\`\"dependencies\"\\` and \\`\"peerDependencies\"\\`.\n By adding the \\`\"", "\"\\` option the rule also looks at \\`\"devDependencies\"\\`.\n By adding the \\`\"", "\"\\` option the rule also looks at \\`\"optionalDependencies\"\\`.\n An array of whitelisted modules can be added to skip checking their existence in package.json.\n "])), OPTION_DEV, OPTION_OPTIONAL), | ||
options: { | ||
type: "array", | ||
items: { | ||
type: "string", | ||
enum: [OPTION_DEV, OPTION_OPTIONAL], | ||
}, | ||
items: [ | ||
{ | ||
type: "string", | ||
enum: [OPTION_DEV, OPTION_OPTIONAL], | ||
}, | ||
{ | ||
type: "array", | ||
}, | ||
], | ||
minItems: 0, | ||
maxItems: 2, | ||
maxItems: 3, | ||
}, | ||
optionExamples: [true, [true, OPTION_DEV], [true, OPTION_OPTIONAL]], | ||
optionExamples: [ | ||
true, | ||
[true, OPTION_DEV], | ||
[true, OPTION_OPTIONAL], | ||
[true, ["src", "app"]], | ||
], | ||
type: "functionality", | ||
@@ -70,7 +85,8 @@ typescriptOnly: false, | ||
var dependencies; | ||
for (var _i = 0, _a = tsutils_1.findImports(ctx.sourceFile, 31 /* All */); _i < _a.length; _i++) { | ||
var whitelist = new Set(options.whitelist); | ||
for (var _i = 0, _a = tsutils_1.findImports(ctx.sourceFile, 63 /* All */); _i < _a.length; _i++) { | ||
var name = _a[_i]; | ||
if (!ts.isExternalModuleNameRelative(name.text)) { | ||
var packageName = getPackageName(name.text); | ||
if (builtins.indexOf(packageName) === -1 && !hasDependency(packageName)) { | ||
if (!whitelist.has(packageName) && builtins.indexOf(packageName) === -1 && !hasDependency(packageName)) { | ||
ctx.addFailureAtNode(name, Rule.FAILURE_STRING_FACTORY(packageName)); | ||
@@ -105,3 +121,3 @@ } | ||
} | ||
if (!options.dev && content.peerDependencies !== undefined) { | ||
if (content.peerDependencies !== undefined) { | ||
addDependencies(result, content.peerDependencies); | ||
@@ -108,0 +124,0 @@ } |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -20,2 +20,3 @@ "use strict"; | ||
var tslib_1 = require("tslib"); | ||
var _a; | ||
var utils = require("tsutils"); | ||
@@ -77,2 +78,1 @@ var Lint = require("../index"); | ||
var templateObject_1; | ||
var _a; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2015 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from ".."; |
@@ -30,4 +30,3 @@ "use strict"; | ||
Rule.prototype.apply = function (sourceFile) { | ||
var allowedNumbers = this.ruleArguments.length > 0 ? this.ruleArguments : Rule.DEFAULT_ALLOWED; | ||
return this.applyWithWalker(new NoMagicNumbersWalker(sourceFile, this.ruleName, new Set(allowedNumbers.map(String)))); | ||
return this.applyWithWalker(new NoMagicNumbersWalker(sourceFile, this.ruleName, this.ruleArguments.length > 0 ? this.ruleArguments : Rule.DEFAULT_ALLOWED)); | ||
}; | ||
@@ -91,3 +90,5 @@ /* tslint:disable:object-literal-sort-keys */ | ||
NoMagicNumbersWalker.prototype.checkNumericLiteral = function (node, num) { | ||
if (!Rule.ALLOWED_NODES.has(node.parent.kind) && !this.options.has(num)) { | ||
/* Using Object.is() to differentiate between pos/neg zero */ | ||
if (!Rule.ALLOWED_NODES.has(node.parent.kind) && | ||
!this.options.some(function (allowedNum) { return Object.is(allowedNum, parseFloat(num)); })) { | ||
this.addFailureAtNode(node, Rule.FAILURE_STRING); | ||
@@ -94,0 +95,0 @@ } |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2015 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -98,3 +98,5 @@ "use strict"; | ||
function NoShadowedVariableWalker() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.scope = new Scope(); | ||
return _this; | ||
} | ||
@@ -101,0 +103,0 @@ NoShadowedVariableWalker.prototype.walk = function (sourceFile) { |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -6,3 +22,4 @@ import * as Lint from "../index"; | ||
static FAILURE_STRING: string; | ||
static id(input: string): string; | ||
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; | ||
} |
@@ -28,2 +28,5 @@ "use strict"; | ||
} | ||
Rule.id = function (input) { | ||
return input; | ||
}; | ||
Rule.prototype.apply = function (sourceFile) { | ||
@@ -54,4 +57,8 @@ return this.applyWithFunction(sourceFile, walk); | ||
if (argument !== undefined && tsutils_1.isStringLiteral(argument) && tsutils_1.isValidPropertyAccess(argument.text)) { | ||
// for compatibility with typescript@<2.5.0 to avoid fixing expr['__foo'] to expr.___foo | ||
var propertyName = ts.unescapeIdentifier(argument.text); // tslint:disable-line:deprecation | ||
// typescript@<2.5.0 has an extra underscore in escaped identifier text content, | ||
// to avoid fixing issue `expr['__foo'] → expr.___foo`, unescapeIdentifier() is to be used | ||
// As of typescript@3, unescapeIdentifier() removed, thus check in runtime, if the method exists | ||
// tslint:disable-next-line no-unsafe-any strict-boolean-expressions | ||
var unescapeIdentifier = ts.unescapeIdentifier || Rule.id; | ||
var propertyName = unescapeIdentifier(argument.text); | ||
ctx.addFailureAtNode(argument, Rule.FAILURE_STRING, | ||
@@ -58,0 +65,0 @@ // expr['foo'] -> expr.foo |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -52,3 +52,3 @@ "use strict"; | ||
function walk(ctx) { | ||
for (var _i = 0, _a = tsutils_1.findImports(ctx.sourceFile, 31 /* All */); _i < _a.length; _i++) { | ||
for (var _i = 0, _a = tsutils_1.findImports(ctx.sourceFile, 63 /* All */); _i < _a.length; _i++) { | ||
var name = _a[_i]; | ||
@@ -55,0 +55,0 @@ if (!ts.isExternalModuleNameRelative(name.text) && |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -10,4 +26,4 @@ import * as Lint from "../index"; | ||
walk(sourceFile: ts.SourceFile): void | undefined; | ||
private visitSwitchStatement({caseBlock: {clauses}}); | ||
private isFallThroughAllowed(clause); | ||
private visitSwitchStatement; | ||
private isFallThroughAllowed; | ||
} |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -20,2 +20,3 @@ "use strict"; | ||
var tslib_1 = require("tslib"); | ||
var _a, _b; | ||
var utils = require("tsutils"); | ||
@@ -129,2 +130,1 @@ var ts = require("typescript"); | ||
var templateObject_1, templateObject_2; | ||
var _a, _b; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2014 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2014 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -20,2 +20,3 @@ "use strict"; | ||
var tslib_1 = require("tslib"); | ||
var semver = require("semver"); | ||
var utils = require("tsutils"); | ||
@@ -67,2 +68,5 @@ var ts = require("typescript"); | ||
requiresTypeInfo: true, | ||
deprecationMessage: semver.gte(ts.version, "2.9.0-dev.0") | ||
? "Since TypeScript 2.9. Please use the built-in compiler checks instead." | ||
: undefined, | ||
}; | ||
@@ -106,3 +110,4 @@ return Rule; | ||
var failure = ts.flattenDiagnosticMessageText(diag.messageText, "\n"); | ||
if (ignorePattern !== undefined) { | ||
// BUG: this means imports / destructures with all (2+) unused variables don't respect ignore pattern | ||
if (ignorePattern !== undefined && kind !== 2 /* DECLARATION */ && kind !== 3 /* ALL_DESTRUCTURES */) { | ||
var varName = /'(.*)'/.exec(failure)[1]; | ||
@@ -378,2 +383,4 @@ if (ignorePattern.test(varName)) { | ||
return 2 /* DECLARATION */; // "All imports in import declaration are unused." | ||
case 6198: | ||
return 3 /* ALL_DESTRUCTURES */; // "All destructured elements are unused." | ||
default: | ||
@@ -380,0 +387,0 @@ return undefined; |
@@ -21,3 +21,5 @@ "use strict"; | ||
var ts = require("typescript"); | ||
var tsutils_1 = require("tsutils"); | ||
var Lint = require("../index"); | ||
var noUseBeforeDeclare_examples_1 = require("./code-examples/noUseBeforeDeclare.examples"); | ||
var Rule = /** @class */ (function (_super) { | ||
@@ -46,2 +48,3 @@ tslib_1.__extends(Rule, _super); | ||
requiresTypeInfo: true, | ||
codeExamples: noUseBeforeDeclare_examples_1.codeExamples, | ||
}; | ||
@@ -61,2 +64,5 @@ return Rule; | ||
case ts.SyntaxKind.Identifier: | ||
if (isPropNameInBinding(node)) { | ||
return; | ||
} | ||
return checkIdentifier(node, checker.getSymbolAtLocation(node)); | ||
@@ -89,3 +95,10 @@ case ts.SyntaxKind.ExportSpecifier: | ||
} | ||
/** | ||
* Destructured vars/args w/ rename are declared later in the source. | ||
* var { x: y } = { x: 43 }; | ||
*/ | ||
function isPropNameInBinding(node) { | ||
return node.parent !== undefined && tsutils_1.isBindingElement(node.parent) && node.parent.propertyName === node; | ||
} | ||
} | ||
var templateObject_1; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2015 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from ".."; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -243,2 +243,3 @@ "use strict"; | ||
Walker.prototype.getReplacements = function () { | ||
var _a; | ||
var importDeclarationsList = this.importsBlocks | ||
@@ -252,3 +253,2 @@ .map(function (block) { return block.getImportDeclarations(); }) | ||
return replacements; | ||
var _a; | ||
}; | ||
@@ -255,0 +255,0 @@ Walker.prototype.getReplacementsForExistingImports = function (importDeclarationsList) { |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -90,3 +90,5 @@ "use strict"; | ||
function PreferConstWalker() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.scope = new Scope(); | ||
return _this; | ||
} | ||
@@ -93,0 +95,0 @@ PreferConstWalker.prototype.walk = function (sourceFile) { |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -20,2 +20,3 @@ "use strict"; | ||
var tslib_1 = require("tslib"); | ||
var _a, _b; | ||
var utils = require("tsutils"); | ||
@@ -141,2 +142,1 @@ var ts = require("typescript"); | ||
var templateObject_1; | ||
var _a, _b; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2018 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -7,4 +23,4 @@ import * as Lint from "../index"; | ||
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; | ||
private doesNodeViolateRule(node); | ||
private createFailure(sourceFile, node); | ||
private doesNodeViolateRule; | ||
private createFailure; | ||
} |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -20,2 +20,3 @@ "use strict"; | ||
var tslib_1 = require("tslib"); | ||
var _a; | ||
var tsutils_1 = require("tsutils"); | ||
@@ -111,2 +112,1 @@ var ts = require("typescript"); | ||
var templateObject_1; | ||
var _a; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -47,2 +47,16 @@ "use strict"; | ||
exports.Rule = Rule; | ||
function isParseInt(expression) { | ||
return tsutils_1.isIdentifier(expression) && expression.text === "parseInt"; | ||
} | ||
function isPropertyAccessParseInt(expression) { | ||
return tsutils_1.isPropertyAccessExpression(expression) && expression.name.text === "parseInt"; | ||
} | ||
function isPropertyAccessOfIdentifier(expression, identifers) { | ||
return tsutils_1.isPropertyAccessExpression(expression) && tsutils_1.isIdentifier(expression.expression) && | ||
identifers.some(function (identifer) { return expression.expression.text === identifer; }); | ||
} | ||
function isPropertyAccessOfProperty(expression, identifers) { | ||
return tsutils_1.isPropertyAccessExpression(expression) && tsutils_1.isPropertyAccessExpression(expression.expression) && | ||
identifers.some(function (identifer) { return expression.expression.name.text === identifer; }); | ||
} | ||
function walk(ctx) { | ||
@@ -53,9 +67,10 @@ return ts.forEachChild(ctx.sourceFile, function cb(node) { | ||
// parseInt("123") | ||
tsutils_1.isIdentifier(node.expression) && node.expression.text === "parseInt" || | ||
// window.parseInt("123") || global.parseInt("123") | ||
tsutils_1.isPropertyAccessExpression(node.expression) && | ||
node.expression.name.text === "parseInt" && | ||
tsutils_1.isIdentifier(node.expression.expression) && | ||
(node.expression.expression.text === "global" || | ||
node.expression.expression.text === "window"))) { | ||
isParseInt(node.expression) || | ||
// window.parseInt("123") || global.parseInt("123") || Number.parseInt("123") | ||
isPropertyAccessParseInt(node.expression) && | ||
isPropertyAccessOfIdentifier(node.expression, ["global", "window", "Number"]) || | ||
// window.Number.parseInt("123") || global.Number.parseInt("123") | ||
isPropertyAccessParseInt(node.expression) && | ||
isPropertyAccessOfProperty(node.expression, ["Number"]) && | ||
isPropertyAccessOfIdentifier(node.expression.expression, ["global", "window"]))) { | ||
ctx.addFailureAtNode(node, Rule.FAILURE_STRING); | ||
@@ -62,0 +77,0 @@ } |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -16,3 +32,3 @@ import * as Lint from "../index"; | ||
Enum = 6, | ||
Mixes = 7, | ||
Mixes = 7 | ||
} | ||
@@ -19,0 +35,0 @@ declare module "typescript" { |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2015 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -36,2 +36,3 @@ "use strict"; | ||
description: "Checks whether the final clause of a switch statement ends in \`break;\`.", | ||
hasFix: true, | ||
optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n If no options are passed, a final 'break;' is forbidden.\n If the \"always\" option is passed this will require a 'break;' to always be present\n unless control flow is escaped in some other way."], ["\n If no options are passed, a final 'break;' is forbidden.\n If the \"always\" option is passed this will require a 'break;' to always be present\n unless control flow is escaped in some other way."]))), | ||
@@ -69,24 +70,40 @@ options: { | ||
if (!tsutils_1.endsControlFlow(clause)) { | ||
ctx.addFailureAtNode(clause.getChildAt(0), Rule.FAILURE_STRING_ALWAYS); | ||
ctx.addFailureAtNode(clause.getChildAt(0), Rule.FAILURE_STRING_ALWAYS, createAddFix(clause)); | ||
} | ||
return; | ||
} | ||
if (clause.statements.length === 0) { | ||
var lastStatement = getLastStatement(clause); | ||
if (lastStatement === undefined || !tsutils_1.isBreakStatement(lastStatement)) { | ||
return; | ||
} | ||
var block = clause.statements[0]; | ||
var statements = clause.statements.length === 1 && tsutils_1.isBlock(block) ? block.statements : clause.statements; | ||
var lastStatement = last(statements); | ||
if (lastStatement !== undefined && tsutils_1.isBreakStatement(lastStatement)) { | ||
if (lastStatement.label !== undefined) { | ||
var parent = node.parent; | ||
if (!tsutils_1.isLabeledStatement(parent) || parent.label === lastStatement.label) { | ||
// break jumps somewhere else, don't complain | ||
return; | ||
} | ||
if (lastStatement.label !== undefined) { | ||
var parent = node.parent; | ||
if (!tsutils_1.isLabeledStatement(parent) || parent.label === lastStatement.label) { | ||
// break jumps somewhere else, don't complain | ||
return; | ||
} | ||
ctx.addFailureAtNode(lastStatement, Rule.FAILURE_STRING_NEVER); | ||
} | ||
ctx.addFailureAtNode(lastStatement, Rule.FAILURE_STRING_NEVER, createRemoveFix(lastStatement)); | ||
} | ||
function createAddFix(clause) { | ||
var lastStatement = getLastStatement(clause); | ||
if (lastStatement === undefined) { | ||
return Lint.Replacement.appendText(clause.end, " break;"); | ||
} | ||
var fullText = lastStatement.getFullText(ctx.sourceFile); | ||
var indentation = fullText.slice(0, fullText.search(/\S+/)); | ||
return Lint.Replacement.appendText(lastStatement.end, indentation + "break;"); | ||
} | ||
function createRemoveFix(lastStatement) { | ||
return Lint.Replacement.replaceFromTo(lastStatement.getFullStart(), lastStatement.end, ""); | ||
} | ||
} | ||
function getLastStatement(clause) { | ||
if (clause.statements.length === 0) { | ||
return undefined; | ||
} | ||
var block = clause.statements[0]; | ||
var statements = clause.statements.length === 1 && tsutils_1.isBlock(block) ? block.statements : clause.statements; | ||
return last(statements); | ||
} | ||
function last(arr) { | ||
@@ -93,0 +110,0 @@ return arr[arr.length - 1]; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -8,4 +24,4 @@ import * as Lint from "../index"; | ||
static FAILURE_STRING_SINGLE_PARAMETER_DIFFERENCE(otherLine: number | undefined, type1: string, type2: string): string; | ||
private static FAILURE_STRING_START(otherLine?); | ||
private static FAILURE_STRING_START; | ||
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; | ||
} |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import * as ts from "typescript"; | ||
@@ -2,0 +18,0 @@ import * as Lint from "../index"; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2013 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
export interface Options { | ||
@@ -63,3 +79,3 @@ /** | ||
FatalError = 1, | ||
LintError = 2, | ||
LintError = 2 | ||
} | ||
@@ -66,0 +82,0 @@ export interface Logger { |
@@ -228,3 +228,3 @@ "use strict"; | ||
} | ||
buffer = new Buffer(256); | ||
buffer = Buffer.allocUnsafe(256); | ||
fd = fs.openSync(filename, "r"); | ||
@@ -231,0 +231,0 @@ try { |
@@ -0,1 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { Logger } from "./runner"; | ||
@@ -2,0 +18,0 @@ import { LintError } from "./verify/lintError"; |
@@ -53,3 +53,3 @@ "use strict"; | ||
if (error !== undefined) { | ||
throw new Error(JSON.stringify(error)); | ||
throw new Error(ts.formatDiagnostics([error], ts.createCompilerHost({}))); | ||
} | ||
@@ -218,13 +218,22 @@ var parseConfigHost = { | ||
logger.log(chalk_1.default.red("Actual (from TSLint)\n")); | ||
for (var _i = 0, diffResults_1 = diffResults; _i < diffResults_1.length; _i++) { | ||
var diffResult = diffResults_1[_i]; | ||
var _loop_2 = function (diffResult) { | ||
var color = chalk_1.default.grey; | ||
var prefix = " "; | ||
if (diffResult.added) { | ||
color = chalk_1.default.green.underline; | ||
prefix = "+ "; | ||
} | ||
else if (diffResult.removed) { | ||
color = chalk_1.default.red.underline; | ||
prefix = "- "; | ||
} | ||
logger.log(color(diffResult.value)); | ||
logger.log(color(diffResult.value.split(/\r\n|\r|\n/) | ||
// strings end on a newline which we do not want to include the prefix. | ||
// tslint:disable-next-line:prefer-template | ||
.map(function (line, index, array) { return index === array.length - 1 ? line : prefix + line + "\n"; }).join(""))); | ||
}; | ||
for (var _i = 0, diffResults_1 = diffResults; _i < diffResults_1.length; _i++) { | ||
var diffResult = diffResults_1[_i]; | ||
_loop_2(diffResult); | ||
} | ||
} |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
/** | ||
@@ -18,2 +17,3 @@ * @license | ||
*/ | ||
/// <reference types="node" /> | ||
/** | ||
@@ -61,1 +61,4 @@ * Enforces the invariant that the input is an array. | ||
export declare function denormalizeWinPath(path: string): string; | ||
export declare function isPascalCased(name: string): boolean; | ||
export declare function isCamelCased(name: string): boolean; | ||
export declare function isKebabCased(name: string): boolean; |
@@ -219,1 +219,19 @@ "use strict"; | ||
exports.denormalizeWinPath = denormalizeWinPath; | ||
function isPascalCased(name) { | ||
return isUpperCase(name[0]) && !name.includes("_") && !name.includes("-"); | ||
} | ||
exports.isPascalCased = isPascalCased; | ||
function isCamelCased(name) { | ||
return isLowerCase(name[0]) && !name.includes("_") && !name.includes("-"); | ||
} | ||
exports.isCamelCased = isCamelCased; | ||
function isKebabCased(name) { | ||
for (var i = 0; i < name.length; i++) { | ||
var c = name.charAt(i); | ||
if (c === "_" || !isLowerCase(c)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
exports.isKebabCased = isKebabCased; |
"use strict"; | ||
/* | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
@@ -4,0 +5,0 @@ * |
"use strict"; | ||
/* | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
@@ -4,0 +5,0 @@ * |
"use strict"; | ||
/* | ||
* @license | ||
* Copyright 2016 Palantir Technologies, Inc. | ||
@@ -4,0 +5,0 @@ * |
{ | ||
"name": "tslint", | ||
"version": "5.10.0", | ||
"version": "5.11.0", | ||
"description": "An extensible static analysis linter for the TypeScript language", | ||
@@ -51,3 +51,3 @@ "bin": { | ||
"tslib": "^1.8.0", | ||
"tsutils": "^2.12.1" | ||
"tsutils": "^2.27.2" | ||
}, | ||
@@ -79,3 +79,3 @@ "peerDependencies": { | ||
"tslint-test-config-non-relative": "file:test/external/tslint-test-config-non-relative", | ||
"typescript": "~2.8.3" | ||
"typescript": "~2.9.2" | ||
}, | ||
@@ -82,0 +82,0 @@ "license": "Apache-2.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1524032
411
30906
Updatedtsutils@^2.27.2