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
55 changes: 55 additions & 0 deletions additional_rule_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
"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",
"severity": "Critical",
"level": "Opportunity for Excellence",
"group": "Configurable"
},
"class-name": {
"issueClass": "Non-SDL",
"issueType": "Error",
Expand All @@ -41,6 +48,14 @@
"group": "Clarity",
"commonWeaknessEnumeration": "398, 710"
},
"comment-type": {
"issueClass": "Non-SDL",
"issueType": "Warning",
"severity": "Low",
"level": "Opportunity for Excellence",
"group": "Clarity",
"commonWeaknessEnumeration": "398, 710"
},
"curly": {
"issueClass": "Non-SDL",
"issueType": "Warning",
Expand Down Expand Up @@ -617,6 +632,22 @@
"recommendation": "false,",
"commonWeaknessEnumeration": "398, 710"
},
"unnecessary-bind": {
"issueClass": "Non-SDL",
"issueType": "Warning",
"severity": "Moderate",
JoshuaKGoldberg marked this conversation as resolved.
Show resolved Hide resolved
"level": "Opportunity for Excellence",
"group": "Correctness",
"commonWeaknessEnumeration": "398"
},
"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 +719,14 @@
"recommendation": "false, // enable this rule only if you are legally required to add a file header",
"level": "Opportunity for Excellence"
},
"function-constructor": {
"issueClass": "Non-SDL",
JoshuaKGoldberg marked this conversation as resolved.
Show resolved Hide resolved
"issueType": "Warning",
"severity": "Moderate",
"level": "Opportunity for Excellence",
"group": "Correctness",
"commonWeaknessEnumeration": "398"
},
"max-classes-per-file": {
"issueClass": "Non-SDL",
"issueType": "Warning",
Expand Down Expand Up @@ -744,6 +783,14 @@
"recommendation": "true,",
"level": "Opportunity for Excellence"
},
"increment-decrement": {
"issueClass": "Non-SDL",
"issueType": "Warning",
"severity": "Moderate",
JoshuaKGoldberg marked this conversation as resolved.
Show resolved Hide resolved
"level": "Opportunity for Excellence",
"group": "Correctness",
"commonWeaknessEnumeration": "398"
},
"interface-over-type-literal": {
"issueClass": "Ignored",
"issueType": "Warning",
Expand Down Expand Up @@ -946,6 +993,14 @@
"group": "Whitespace",
"commonWeaknessEnumeration": "710"
},
"no-default-import": {
"issueClass": "Non-SDL",
"issueType": "Warning",
"severity": "Moderate",
"level": "Opportunity for Excellence",
"group": "Correctness",
"commonWeaknessEnumeration": "398"
},
"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
72 changes: 17 additions & 55 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
14 changes: 11 additions & 3 deletions recommended_ruleset.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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 +37,8 @@ module.exports = {
*/
'await-promise': true,
'forin': true,
'function-constructor': true,
'increment-decrement': true,
'jquery-deferred-must-complete': true,
'label-position': true,
'match-default-export-name': true,
Expand All @@ -51,6 +53,7 @@ module.exports = {
'no-constant-condition': true,
'no-control-regex': true,
'no-debugger': true,
'no-default-import': true,
'no-duplicate-super': true,
'no-duplicate-switch-case': true,
'no-duplicate-variable': true,
Expand All @@ -59,7 +62,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 +77,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 +96,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 +116,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 @@ -180,6 +186,7 @@ module.exports = {
* Accessibility. The following rules should be turned on to guarantee the best user
* experience for keyboard and screen reader users.
*/
'react-a11y-accessible-headings': true,
'react-a11y-anchors': true,
'react-a11y-aria-unsupported-elements': true,
'react-a11y-event-has-role': true,
Expand Down Expand Up @@ -232,6 +239,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 no-increment-decrement rule.'
JoshuaKGoldberg marked this conversation as resolved.
Show resolved Hide resolved
);
Rule.isWarningShown = true;
}

return this.applyWithWalker(new NoIncrementDecrementWalker(sourceFile, this.getOptions()));
}
}
Expand Down
Loading