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

Deprecated no-reserved-keywords #674

Merged
merged 4 commits into from
Dec 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ We recommend you specify exact versions of lint libraries, including `tslint-mic
<code>no-reserved-keywords</code>
</td>
<td>
Deprecated - This rule can be replaced with TSLint's variable-name.
Do not use reserved keywords as names of local variables, fields, functions, or other identifiers.
Since version 2.0.9 this rule accepts a parameter called <code>allow-quoted-properties</code>.
If true, interface properties in quotes will be ignored.
Expand Down
1 change: 1 addition & 0 deletions build-tasks/validate-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const disabledRules = new Set([
'no-empty-interfaces',
'no-empty-line-after-opening-brace',
'no-multiline-string',
'no-reserved-keywords',
'no-relative-imports',
'no-stateless-class',
'no-unexternalized-strings',
Expand Down
2 changes: 1 addition & 1 deletion recommended_ruleset.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ module.exports = {
'no-http-string': [true, 'http://www.example.com/?.*', 'http://localhost:?.*'],
'no-inner-html': true,
'no-octal-literal': true,
'no-reserved-keywords': true,
'no-string-based-set-immediate': true,
'no-string-based-set-interval': true,
'no-string-based-set-timeout': true,
Expand Down Expand Up @@ -264,6 +263,7 @@ module.exports = {
'no-empty-interfaces': false, // use tslint no-empty-interface rule instead
'no-missing-visibility-modifiers': false, // use tslint member-access rule instead
'no-multiple-var-decl': false, // use tslint one-variable-per-declaration rule instead
'no-reserved-keywords': false,
'no-stateless-class': false,
'no-switch-case-fall-through': false, // now supported by TypeScript compiler
'no-unnecessary-class': true,
Expand Down
10 changes: 9 additions & 1 deletion src/noReservedKeywordsRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ export class Rule extends Lint.Rules.AbstractRule {
typescriptOnly: true,
issueClass: 'SDL',
issueType: 'Error',
recommendation: 'false,',
severity: 'Critical',
level: 'Mandatory',
group: 'Security',
group: 'Deprecated',
commonWeaknessEnumeration: '398'
};

Expand Down Expand Up @@ -89,7 +90,14 @@ export class Rule extends Lint.Rules.AbstractRule {
'of'
];

private static isWarningShown: boolean = false;

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

const walker: Lint.RuleWalker = new BannedTermWalker(sourceFile, this.getOptions(), Rule.FAILURE_STRING, Rule.BANNED_TERMS);
return this.applyWithWalker(walker);
}
Expand Down
2 changes: 1 addition & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
"no-parameter-reassignment": false,
"no-redundant-jsdoc": true,
"no-regex-spaces": true,
"no-reserved-keywords": true,
"no-return-await": true,
"no-single-line-block-comment": true,
"no-string-based-set-immediate": true,
Expand Down Expand Up @@ -163,6 +162,7 @@
"no-empty-line-after-opening-brace": false,
"no-multiline-string": false,
"no-relative-imports": false,
"no-reserved-keywords": false,
"no-stateless-class": false,
"no-unexternalized-strings": false,
"no-var-self": false,
Expand Down