From 79caabdfe10dec9e8d9fa83949c22a88e44f55a3 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Thu, 13 Dec 2018 14:28:22 -0800 Subject: [PATCH 1/4] Deprecated no-reserved-keywords --- README.md | 1 + build-tasks/validate-config.js | 1 + recommended_ruleset.js | 2 +- src/noReservedKeywordsRule.ts | 11 ++++++++++- tslint-warnings.csv | 4 ++-- tslint.json | 2 +- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d664bad2d..f40b5fe0d 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 no-reserved-keywords. 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..f57ccb4f8 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': true, '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..137843176 100644 --- a/src/noReservedKeywordsRule.ts +++ b/src/noReservedKeywordsRule.ts @@ -16,7 +16,7 @@ export class Rule extends Lint.Rules.AbstractRule { issueType: 'Error', severity: 'Critical', level: 'Mandatory', - group: 'Security', + group: 'Deprecated', commonWeaknessEnumeration: '398' }; @@ -89,7 +89,16 @@ 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-duplicate-case rule is deprecated. Replace your usage with the TSLint no-duplicate-switch-case 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-warnings.csv b/tslint-warnings.csv index efa1804a1..b3f3c0397 100644 --- a/tslint-warnings.csv +++ b/tslint-warnings.csv @@ -262,9 +262,9 @@ react-a11y-no-onchange,"For accessibility of your website, enforce usage of onBl react-a11y-props,Enforce all `aria-*` attributes are valid. Elements cannot use an invalid `aria-*` attribute.,TSLINT1682S78,tslint,Non-SDL,Warning,Important,Opportunity for Excellence,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,, react-a11y-proptypes,Enforce ARIA state and property values are valid.,TSLINT1DLB1JE,tslint,Non-SDL,Warning,Important,Opportunity for Excellence,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,, react-a11y-required,Enforce that required input elements must have aria-required set to true,TSLINTNF1C97,tslint,Non-SDL,Warning,Low,Opportunity for Excellence,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,, -react-a11y-role,"Elements with aria roles must use a **valid**, **non-abstract** aria role.",TSLINTQ0A2FU,tslint,Non-SDL,Warning,Important,Opportunity for Excellence,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,, +react-a11y-role,"Elements with aria roles must use a **valid**, **non-abstract** aria role. A reference to role definitions can be found at [WAI-ARIA roles](https://www.w3.org/TR/wai-aria/roles#role_definitions).",TSLINTQ0A2FU,tslint,Non-SDL,Warning,Important,Opportunity for Excellence,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,, react-a11y-role-has-required-aria-props,Elements with aria roles must have all required attributes according to the role.,TSLINT1R1B60O,tslint,Non-SDL,Warning,Important,Opportunity for Excellence,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,, -react-a11y-role-supports-aria-props,Enforce that elements with explicit or implicit roles defined contain only `aria-*` properties supported by that `role`.,TSLINT1IFADTQ,tslint,Non-SDL,Warning,Important,Opportunity for Excellence,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,, +react-a11y-role-supports-aria-props,"Enforce that elements with explicit or implicit roles defined contain only `aria-*` properties supported by that `role`.Many aria attributes (states and properties) can only be used on elements with particular roles.Some elements have implicit roles, such as ``, which will be resolved to `role='link'`.A reference for the implicit roles can be found at [Default Implicit ARIA Semantics](https://www.w3.org/TR/html-aria/#sec-strong-native-semantics).",TSLINT1IFADTQ,tslint,Non-SDL,Warning,Important,Opportunity for Excellence,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,, react-a11y-tabindex-no-positive,Enforce tabindex value is **not greater than zero**.,TSLINTEO7FKT,tslint,Non-SDL,Warning,Important,Opportunity for Excellence,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,, react-a11y-titles,"For accessibility of your website, HTML title elements must be concise and non-empty.",TSLINT1506S53,tslint,Non-SDL,Warning,Moderate,Opportunity for Excellence,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,, react-anchor-blank-noopener,Anchor tags with target="_blank" should also include rel="noreferrer",TSLINT1GKPCB4,tslint,SDL,Error,Critical,Mandatory,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,"242,676","CWE 242 - Use of Inherently Dangerous Function 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, From aaf92018b97578dcfb87b0ef7f44c8f13aeb6e3d Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Thu, 13 Dec 2018 14:31:31 -0800 Subject: [PATCH 2/4] Fixed silly copy & paste errors --- README.md | 2 +- src/noReservedKeywordsRule.ts | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f40b5fe0d..f1d6ffa81 100644 --- a/README.md +++ b/README.md @@ -548,7 +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 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/src/noReservedKeywordsRule.ts b/src/noReservedKeywordsRule.ts index 137843176..6386e79b8 100644 --- a/src/noReservedKeywordsRule.ts +++ b/src/noReservedKeywordsRule.ts @@ -93,9 +93,7 @@ export class Rule extends Lint.Rules.AbstractRule { public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { if (Rule.isWarningShown === false) { - console.warn( - 'Warning: no-duplicate-case rule is deprecated. Replace your usage with the TSLint no-duplicate-switch-case rule.' - ); + console.warn('Warning: no-reserved-keywords rule is deprecated. Replace your usage with the TSLint variable-name rule.'); Rule.isWarningShown = true; } From 3079f007fd82eb4f8564ef5f1681beab31d7eba4 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Thu, 13 Dec 2018 14:35:27 -0800 Subject: [PATCH 3/4] Fixed recommendation to be false --- recommended_ruleset.js | 2 +- src/noReservedKeywordsRule.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/recommended_ruleset.js b/recommended_ruleset.js index f57ccb4f8..0a5a62a43 100644 --- a/recommended_ruleset.js +++ b/recommended_ruleset.js @@ -263,7 +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': true, + '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 6386e79b8..371fa60a2 100644 --- a/src/noReservedKeywordsRule.ts +++ b/src/noReservedKeywordsRule.ts @@ -14,6 +14,7 @@ export class Rule extends Lint.Rules.AbstractRule { typescriptOnly: true, issueClass: 'SDL', issueType: 'Error', + recommendation: 'false,', severity: 'Critical', level: 'Mandatory', group: 'Deprecated', From 9d8f6e9f13bc423b6338cbb3be0ca2d3b211d3f8 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Fri, 14 Dec 2018 08:48:34 -0800 Subject: [PATCH 4/4] Undid changes to tslint-warnings.csv --- tslint-warnings.csv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tslint-warnings.csv b/tslint-warnings.csv index b3f3c0397..efa1804a1 100644 --- a/tslint-warnings.csv +++ b/tslint-warnings.csv @@ -262,9 +262,9 @@ react-a11y-no-onchange,"For accessibility of your website, enforce usage of onBl react-a11y-props,Enforce all `aria-*` attributes are valid. Elements cannot use an invalid `aria-*` attribute.,TSLINT1682S78,tslint,Non-SDL,Warning,Important,Opportunity for Excellence,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,, react-a11y-proptypes,Enforce ARIA state and property values are valid.,TSLINT1DLB1JE,tslint,Non-SDL,Warning,Important,Opportunity for Excellence,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,, react-a11y-required,Enforce that required input elements must have aria-required set to true,TSLINTNF1C97,tslint,Non-SDL,Warning,Low,Opportunity for Excellence,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,, -react-a11y-role,"Elements with aria roles must use a **valid**, **non-abstract** aria role. A reference to role definitions can be found at [WAI-ARIA roles](https://www.w3.org/TR/wai-aria/roles#role_definitions).",TSLINTQ0A2FU,tslint,Non-SDL,Warning,Important,Opportunity for Excellence,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,, +react-a11y-role,"Elements with aria roles must use a **valid**, **non-abstract** aria role.",TSLINTQ0A2FU,tslint,Non-SDL,Warning,Important,Opportunity for Excellence,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,, react-a11y-role-has-required-aria-props,Elements with aria roles must have all required attributes according to the role.,TSLINT1R1B60O,tslint,Non-SDL,Warning,Important,Opportunity for Excellence,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,, -react-a11y-role-supports-aria-props,"Enforce that elements with explicit or implicit roles defined contain only `aria-*` properties supported by that `role`.Many aria attributes (states and properties) can only be used on elements with particular roles.Some elements have implicit roles, such as ``, which will be resolved to `role='link'`.A reference for the implicit roles can be found at [Default Implicit ARIA Semantics](https://www.w3.org/TR/html-aria/#sec-strong-native-semantics).",TSLINT1IFADTQ,tslint,Non-SDL,Warning,Important,Opportunity for Excellence,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,, +react-a11y-role-supports-aria-props,Enforce that elements with explicit or implicit roles defined contain only `aria-*` properties supported by that `role`.,TSLINT1IFADTQ,tslint,Non-SDL,Warning,Important,Opportunity for Excellence,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,, react-a11y-tabindex-no-positive,Enforce tabindex value is **not greater than zero**.,TSLINTEO7FKT,tslint,Non-SDL,Warning,Important,Opportunity for Excellence,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,, react-a11y-titles,"For accessibility of your website, HTML title elements must be concise and non-empty.",TSLINT1506S53,tslint,Non-SDL,Warning,Moderate,Opportunity for Excellence,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,, react-anchor-blank-noopener,Anchor tags with target="_blank" should also include rel="noreferrer",TSLINT1GKPCB4,tslint,SDL,Error,Critical,Mandatory,See description on the tslint or tslint-microsoft-contrib website,TSLint Procedure,"242,676","CWE 242 - Use of Inherently Dangerous Function