diff --git a/README.md b/README.md index d664bad2d..f1d6ffa81 100644 --- a/README.md +++ b/README.md @@ -548,6 +548,7 @@ We recommend you specify exact versions of lint libraries, including `tslint-mic no-reserved-keywords + 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 allow-quoted-properties. If true, interface properties in quotes will be ignored. diff --git a/build-tasks/validate-config.js b/build-tasks/validate-config.js index 71bc7d7c9..4391bd6f6 100644 --- a/build-tasks/validate-config.js +++ b/build-tasks/validate-config.js @@ -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', diff --git a/recommended_ruleset.js b/recommended_ruleset.js index 07f7bf61e..0a5a62a43 100644 --- a/recommended_ruleset.js +++ b/recommended_ruleset.js @@ -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, @@ -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, diff --git a/src/noReservedKeywordsRule.ts b/src/noReservedKeywordsRule.ts index 3fb4b65ca..371fa60a2 100644 --- a/src/noReservedKeywordsRule.ts +++ b/src/noReservedKeywordsRule.ts @@ -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' }; @@ -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); } diff --git a/tslint.json b/tslint.json index 369b2fd0d..dabb684cd 100644 --- a/tslint.json +++ b/tslint.json @@ -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, @@ -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,