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

Deprecated now-duplicate rules from TSLint 5.12.0 (bumped devDependency to 5.12.0) #686

Merged
merged 10 commits into from
Dec 27, 2018
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ We recommend you specify exact versions of lint libraries, including `tslint-mic
<code>no-function-constructor-with-string-args</code>
</td>
<td>
Deprecated - This rule is in the TSLint product as <code>function-constructor</code>.
Do not use the version of the Function constructor that accepts a string argument to define the body of the function.
</td>
<td>0.0.1</td>
Expand Down Expand Up @@ -450,6 +451,7 @@ We recommend you specify exact versions of lint libraries, including `tslint-mic
<code>no-increment-decrement</code>
</td>
<td>
Deprecated - This rule is in the TSLint product as <code>increment-decrement</code>.
JoshuaKGoldberg marked this conversation as resolved.
Show resolved Hide resolved
Avoid use of increment and decrement operators particularly as part of complicated expressions.
</td>
<td>0.0.1</td>
Expand Down Expand Up @@ -655,6 +657,7 @@ We recommend you specify exact versions of lint libraries, including `tslint-mic
<code>no-unnecessary-bind</code>
</td>
<td>
Deprecated - This rule is in the TSLint product as <code>unnecessary-bind</code>.
Do not bind 'this' as the context for a function literal or lambda expression.
If you bind 'this' as the context to a function literal, then you should just use a lambda without the bind.
If you bind 'this' as the context to a lambda, then you can remove the bind call because 'this' is already the context for lambdas.
Expand Down
58 changes: 58 additions & 0 deletions additional_rule_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
"group": "Configurable",
"recommendation": "false, // only enable this if you have some code pattern that you want to ban"
},
"ban-ts-ignore": {
"issueClass": "Ignored",
"issueType": "Error",
"recommendation": "false,",
"severity": "Critical",
"level": "Opportunity for Excellence",
"group": "Configurable"
},
"class-name": {
"issueClass": "Non-SDL",
"issueType": "Error",
Expand All @@ -41,6 +49,15 @@
"group": "Clarity",
"commonWeaknessEnumeration": "398, 710"
},
"comment-type": {
"issueClass": "Non-SDL",
"issueType": "Warning",
"severity": "Low",
"level": "Opportunity for Excellence",
"group": "Clarity",
"commonWeaknessEnumeration": "398, 710",
"recommendation": "false,"
},
"curly": {
"issueClass": "Non-SDL",
"issueType": "Warning",
Expand Down Expand Up @@ -617,6 +634,22 @@
"recommendation": "false,",
"commonWeaknessEnumeration": "398, 710"
},
"unnecessary-bind": {
"issueClass": "Non-SDL",
"issueType": "Warning",
"severity": "Warning",
JoshuaKGoldberg marked this conversation as resolved.
Show resolved Hide resolved
"level": "Opportunity for Excellence",
"group": "Correctness",
"commonWeaknessEnumeration": "398, 710"
},
"unnecessary-constructor": {
"issueClass": "Non-SDL",
"issueType": "Warning",
"severity": "Moderate",
"level": "Opportunity for Excellence",
"group": "Correctness",
"commonWeaknessEnumeration": "398"
},
"use-isnan": {
"issueClass": "Non-SDL",
"issueType": "Error",
Expand Down Expand Up @@ -688,6 +721,14 @@
"recommendation": "false, // enable this rule only if you are legally required to add a file header",
"level": "Opportunity for Excellence"
},
"function-constructor": {
"issueClass": "SDL",
"issueType": "Error",
"severity": "Critical",
"level": "Mandatory",
"group": "Security",
"commonWeaknessEnumeration": "95, 676, 242, 116"
},
"max-classes-per-file": {
"issueClass": "Non-SDL",
"issueType": "Warning",
Expand Down Expand Up @@ -744,6 +785,14 @@
"recommendation": "true,",
"level": "Opportunity for Excellence"
},
"increment-decrement": {
"issueClass": "Non-SDL",
"issueType": "Warning",
"severity": "Low",
"level": "Opportunity for Excellence",
"group": "Correctness",
"commonWeaknessEnumeration": "398, 710"
},
"interface-over-type-literal": {
"issueClass": "Ignored",
"issueType": "Warning",
Expand Down Expand Up @@ -946,6 +995,15 @@
"group": "Whitespace",
"commonWeaknessEnumeration": "710"
},
"no-default-import": {
"issueClass": "Non-SDL",
"issueType": "Warning",
"severity": "Moderate",
"level": "Opportunity for Excellence",
"group": "Correctness",
"commonWeaknessEnumeration": "398",
"recommendation": "false,"
},
"no-duplicate-super": {
"issueClass": "Non-SDL",
"issueType": "Warning",
Expand Down
3 changes: 3 additions & 0 deletions build-tasks/validate-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ const disabledRules = new Set([
'no-duplicate-case',
'no-empty-interfaces',
'no-empty-line-after-opening-brace',
'no-function-constructor-with-string-args',
'no-increment-decrement',
'no-multiline-string',
'no-reserved-keywords',
'no-relative-imports',
'no-stateless-class',
'no-unexternalized-strings',
'no-unnecessary-bind',
'no-unnecessary-semicolons',
'no-var-self',
'react-tsx-curly-spacing',
Expand Down
68 changes: 15 additions & 53 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"prettier": "1.15.0",
"rimraf": "^2.6.2",
"strip-json-comments": "^2.0.1",
"tslint": "^5.11.0",
"tslint": "^5.12.0",
"tslint-config-prettier": "^1.15.0",
"typescript": "3.1.1",
"underscore": "1.9.1"
Expand Down
12 changes: 9 additions & 3 deletions recommended_ruleset.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
* Security Rules. The following rules should be turned on because they find security issues
* or are recommended in the Microsoft Secure Development Lifecycle (SDL)
*/
'function-constructor': true,
'insecure-random': true,
'no-banned-terms': true,
'no-cookies': true,
Expand All @@ -17,7 +18,7 @@ module.exports = {
'no-document-write': true,
'no-eval': true,
'no-exec-script': true,
'no-function-constructor-with-string-args': true,
'no-function-constructor-with-string-args': false, // use tslint function-constructor rule intsead
'no-http-string': [true, 'http://www.example.com/?.*', 'http://localhost:?.*'],
'no-inner-html': true,
'no-octal-literal': true,
Expand All @@ -37,6 +38,7 @@ module.exports = {
*/
'await-promise': true,
'forin': true,
'increment-decrement': true,
'jquery-deferred-must-complete': true,
'label-position': true,
'match-default-export-name': true,
Expand All @@ -59,7 +61,7 @@ module.exports = {
'no-for-in-array': true,
'no-implicit-dependencies': true,
'no-import-side-effect': true,
'no-increment-decrement': true,
'no-increment-decrement': false, // use tslint increment-decrement rule instead
'no-invalid-regexp': true,
'no-invalid-template-strings': true,
'no-invalid-this': true,
Expand All @@ -74,7 +76,7 @@ module.exports = {
'no-string-literal': true,
'no-string-throw': true,
'no-submodule-imports': true,
'no-unnecessary-bind': true,
'no-unnecessary-bind': false, // use tslint unnecessary-bind rule instead
'no-unnecessary-callback-wrapper': true,
'no-unnecessary-initializer': true,
'no-unnecessary-override': true,
Expand All @@ -93,6 +95,8 @@ module.exports = {
'switch-default': true,
'switch-final-break': true,
'triple-equals': [true, 'allow-null-check'],
'unnecessary-bind': true,
'unnecessary-constructor': true,
'use-isnan': true,
'use-named-parameter': true,
'use-simple-attributes': true,
Expand All @@ -111,6 +115,7 @@ module.exports = {
'chai-vague-errors': true,
'class-name': true,
'comment-format': true,
'comment-type': true,
JoshuaKGoldberg marked this conversation as resolved.
Show resolved Hide resolved
'completed-docs': [true, 'classes'],
'export-name': true,
'file-name-casing': true,
Expand Down Expand Up @@ -232,6 +237,7 @@ module.exports = {
* Controversial/Configurable rules.
*/
'ban': false, // only enable this if you have some code pattern that you want to ban
'ban-ts-ignore': true,
'ban-types': true,
'cyclomatic-complexity': true,
'deprecation': false, // deprecated APIs are sometimes unavoidable
Expand Down
10 changes: 10 additions & 0 deletions src/noFunctionConstructorWithStringArgsRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,23 @@ export class Rule extends Lint.Rules.AbstractRule {
issueType: 'Error',
severity: 'Critical',
level: 'Mandatory',
recommendation: 'false, // use tslint function-constructor rule intsead',
group: 'Security',
commonWeaknessEnumeration: '95, 676, 242, 116'
};

public static FAILURE_STRING: string = 'forbidden: Function constructor with string arguments ';

private static isWarningShown: boolean = false;

public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
if (Rule.isWarningShown === false) {
console.warn(
'Warning: no-function-constructor-with-string-args rule is deprecated. Replace your usage with the TSLint function-constructor rule.'
);
Rule.isWarningShown = true;
}

return this.applyWithWalker(new NoFunctionConstructorWithStringArgsWalker(sourceFile, this.getOptions()));
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/noIncrementDecrementRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,21 @@ export class Rule extends Lint.Rules.AbstractRule {
issueType: 'Warning',
severity: 'Low',
level: 'Opportunity for Excellence',
recommendation: 'false, // use tslint increment-decrement rule instead',
group: 'Correctness',
commonWeaknessEnumeration: '398, 710'
};

private static isWarningShown: boolean = false;

public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
if (Rule.isWarningShown === false) {
console.warn(
'Warning: no-increment-decrement rule is deprecated. Replace your usage with the TSLint increment-decrement rule.'
);
Rule.isWarningShown = true;
}

return this.applyWithWalker(new NoIncrementDecrementWalker(sourceFile, this.getOptions()));
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/noUnnecessaryBindRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class Rule extends Lint.Rules.AbstractRule {
issueType: 'Warning',
severity: 'Important',
level: 'Opportunity for Excellence',
recommendation: 'false, // use tslint unnecessary-bind rule instead',
group: 'Correctness',
commonWeaknessEnumeration: '398, 710'
};
Expand Down Expand Up @@ -51,7 +52,16 @@ export class Rule extends Lint.Rules.AbstractRule {
];
public static UNDERSCORE_TERNARY_FUNCTION_NAMES: string[] = ['foldl', 'foldr', 'inject', 'reduce', 'reduceRight'];

private static isWarningShown: boolean = false;

public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
if (Rule.isWarningShown === false) {
console.warn(
'Warning: no-unnecessary-bind rule is deprecated. Replace your usage with the TSLint unnecessary-bind rule.'
);
Rule.isWarningShown = true;
}

return this.applyWithWalker(new NoUnnecessaryBindRuleWalker(sourceFile, this.getOptions()));
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/noUnnecessaryOverrideRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ class NoUnnecessaryOverrideRuleWalker extends Lint.RuleWalker {
}

const allParameters: ReadonlyArray<ts.ParameterDeclaration> = node.parameters;
/* tslint:disable:no-increment-decrement */
/* tslint:disable:increment-decrement */
for (let i = 0; i < allParameters.length; i++) {
/* tslint:enable:no-increment-decrement */
/* tslint:enable:increment-decrement */
const parameter: ts.ParameterDeclaration = allParameters[i];
const argument: ts.Expression = call.arguments[i];
if (argument.kind !== ts.SyntaxKind.Identifier) {
Expand Down
Loading