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

Commit

Permalink
#333 remove prefer-const rule
Browse files Browse the repository at this point in the history
There is no way to enable this rule because tslint created
a rule with the exact same name

closes #333
  • Loading branch information
HamletDRC committed Jan 18, 2017
1 parent 1c90b70 commit a7d12bb
Show file tree
Hide file tree
Showing 11 changed files with 233 additions and 560 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ Rule Name | Description | Since
`non-literal-require` | Detect `require()` function calls for something that is not a string literal. For security reasons, it is best to only require() string literals. Otherwise, it is perhaps possible for an attacker to somehow change the value and download arbitrary Javascript into your page. | 2.0.14
`possible-timing-attack` | Avoid timing attacks by not making direct string comparisons to sensitive data. Do not compare against variables named password, secret, api, apiKey, token, auth, pass, or hash. For more info see [Using Node.js Event Loop for Timing Attacks](https://snyk.io/blog/node-js-timing-attack-ccc-ctf/) | 2.0.11
`prefer-array-literal` | Use array literal syntax when declaring or instantiating array types. For example, prefer the Javascript form of string[] to the TypeScript form Array<string>. Prefer '[]' to 'new Array()'. Prefer '[4, 5]' to 'new Array(4, 5)'. Prefer '[undefined, undefined]' to 'new Array(4)'. Since 2.0.10, this rule can be configured to allow Array type parameters. To ignore type parameters, configure the rule with the values: `[ true, { 'allow-type-parameters': true } ]`| 1.0, 2.0.10
`prefer-const` | Use `const` to declare variables if they are only assigned a value once. | 2.0.6
`prefer-type-cast` | Prefer the tradition type casts instead of the new 'as-cast' syntax. For example, prefer `<string>myVariable` instead of `myVariable as string`. Rule ignores any file ending in .tsx. If you prefer the opposite and want to see the `as type` casts, then enable the tslint rule named 'no-angle-bracket-type-assertion'| 2.0.4
`promise-must-complete` | When a Promise instance is created, then either the reject() or resolve() parameter must be called on it within all code branches in the scope. For more examples see the [feature request](https://github.com/Microsoft/tslint-microsoft-contrib/issues/34). | 1.0
`react-a11y-anchors` | For accessibility of your website, anchor element link text should be at least 4 characters long. Links with the same HREF should have the same link text. Links that point to different HREFs should have different link text. Links with images and text content, the alt attribute should be unique to the text content or empty. An an anchor element's href prop value must not be just #. <br/>References:<br/>[WCAG Rule 38: Link text should be as least four 4 characters long](http://oaa-accessibility.org/wcag20/rule/38/)<br/>[WCAG Rule 39: Links with the same HREF should have the same link text](http://oaa-accessibility.org/wcag20/rule/39/)<br/>[WCAG Rule 41: Links that point to different HREFs should have different link text](http://oaa-accessibility.org/wcag20/rule/41/)<br/>[WCAG Rule 43: Links with images and text content, the alt attribute should be unique to the text content or empty](http://oaa-accessibility.org/wcag20/rule/43/)<br/> | 2.0.11
Expand Down Expand Up @@ -172,7 +171,6 @@ Formatter Name | Description | Since
`fix-no-require-imports`| This formatter automatically converts imports from the require syntax to the ES6 syntax. For example `import Utils = require('Utils');` becomes `import {Utils} from 'Utils';`. However, be warned that the fix assumes that your imported module exports the correct thing. If anything goes wrong with your exports then you'll get a compiler failure saying there is no default export. | 2.0.8
`fix-no-unused-imports` | This formatter automatically fixes any unused imports found by the no-unused-imports rule. | 2.0.8
`fix-no-var-keyword` | This formatter automatically converts var variable declarations into let variable declarations found by the no-var-keyword rule. | 2.0.8
`fix-prefer-const` | This formatter automatically converts let variable declarations into const declarations found by the prefer-const rule. | 2.0.8

Development
-----------
Expand Down
121 changes: 121 additions & 0 deletions additional_rule_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -679,5 +679,126 @@
"group": "Clarity",
"recommendation": "true,",
"level": "Opportunity for Excellence"
},
"callable-types": {
"issueClass": "Non-SDL",
"issueType": "Warning",
"severity": "Low",
"group": "Clarity",
"recommendation": "true,",
"level": "Opportunity for Excellence"
},
"import-blacklist": {
"issueClass": "Ignored",
"issueType": "Warning",
"severity": "Low",
"group": "Configurable",
"recommendation": "false, // enable and configure this as you desire",
"level": "Opportunity for Excellence"
},
"import-spacing": {
"issueClass": "Non-SDL",
"issueType": "Warning",
"severity": "Low",
"group": "Whitespace",
"recommendation": "true,",
"level": "Opportunity for Excellence"
},
"interface-over-type-literal": {
"issueClass": "Ignored",
"issueType": "Warning",
"severity": "Low",
"group": "Configurable",
"recommendation": "false, // there are plenty of reasons to prefer interfaces",
"level": "Opportunity for Excellence"
},
"no-empty-interface": {
"issueClass": "Ignored",
"issueType": "Warning",
"severity": "Low",
"group": "Configurable",
"recommendation": "false, // it is currently better to use the MS version of this rule",
"level": "Opportunity for Excellence"
},
"no-inferred-empty-object-type": {
"issueClass": "Ignored",
"issueType": "Warning",
"severity": "Low",
"group": "Configurable",
"recommendation": "false, // if the compiler is satisfied then this is probably not an issue",
"level": "Opportunity for Excellence"
},
"no-magic-numbers": {
"issueClass": "Ignored",
"issueType": "Warning",
"severity": "Low",
"group": "Configurable",
"recommendation": "false, // by default it will find too many false positives",
"level": "Opportunity for Excellence"
},
"no-string-throw": {
"issueClass": "Non-SDL",
"issueType": "Warning",
"severity": "High",
"group": "Correctness",
"recommendation": "true,",
"level": "Opportunity for Excellence"
},
"no-void-expression": {
"issueClass": "Non-SDL",
"issueType": "Warning",
"severity": "Important",
"group": "Clarity",
"recommendation": "true,",
"level": "Opportunity for Excellence"
},
"prefer-const": {
"issueClass": "Non-SDL",
"issueType": "Warning",
"severity": "Important",
"group": "Clarity",
"recommendation": "true,",
"level": "Opportunity for Excellence",
"commonWeaknessEnumeration": "398, 705, 710"
},
"promise-function-async": {
"issueClass": "Non-SDL",
"issueType": "Warning",
"severity": "Important",
"group": "Correctness",
"recommendation": "true,",
"level": "Opportunity for Excellence"
},
"space-before-function-paren": {
"issueClass": "Ignored",
"issueType": "Warning",
"severity": "Low",
"group": "Configurable",
"recommendation": "false, // turn this on if this is really your coding standard",
"level": "Opportunity for Excellence"
},
"strict-boolean-expressions": {
"issueClass": "Non-SDL",
"issueType": "Warning",
"severity": "Important",
"group": "Correctness",
"recommendation": "true,",
"level": "Opportunity for Excellence"
},
"typeof-compare": {
"issueClass": "Ignored",
"issueType": "Warning",
"severity": "High",
"group": "Deprecated",
"recommendation": "false, // the valid-typeof rule is currently superior to this version",
"level": "Opportunity for Excellence"
},
"unified-signatures": {
"issueClass": "Non-SDL",
"issueType": "Warning",
"severity": "Important",
"group": "Clarity",
"recommendation": "true,",
"level": "Opportunity for Excellence"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"load-grunt-tasks": "3.2.0",
"mocha": "2.2.5",
"time-grunt": "1.2.1",
"tslint": "4.0.2",
"tslint": "4.3.0",
"typescript": "2.1.4",
"underscore": "1.8.3"
},
Expand Down
14 changes: 14 additions & 0 deletions recommended_ruleset.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,21 @@ module.exports = {
"no-sparse-arrays": true,
"no-stateless-class": true,
"no-string-literal": true,
"no-string-throw": true,
"no-unnecessary-bind": true,
"no-unnecessary-override": true,
"no-unsafe-finally": true,
"no-unused-expression": true,
"no-unused-new": true,
"no-use-before-declare": true,
"no-with-statement": true,
"promise-function-async": true,
"promise-must-complete": true,
"radix": true,
"react-this-binding-issue": true,
"react-unused-props-and-state": true,
"restrict-plus-operands": true, // the plus operand should really only be used for strings and numbers
"strict-boolean-expressions": true,
"switch-default": true,
"triple-equals": [true, "allow-null-check"],
"use-isnan": true,
Expand All @@ -87,6 +90,7 @@ module.exports = {
"adjacent-overload-signatures": true,
"array-type": [true, "array"],
"arrow-parens": false, // for simple functions the parens on arrow functions are not needed
"callable-types": true,
"chai-prefer-contains-to-index-of": true,
"chai-vague-errors": true,
"class-name": true,
Expand Down Expand Up @@ -126,6 +130,7 @@ module.exports = {
"no-var-keyword": true,
"no-var-requires": true,
"no-var-self": true,
"no-void-expression": true,
"object-literal-sort-keys": false, // turn object-literal-sort-keys off and sort keys in a meaningful manner
"one-variable-per-declaration": true,
"only-arrow-functions": false, // there are many valid reasons to declare a function
Expand All @@ -135,6 +140,7 @@ module.exports = {
"prefer-for-of": true,
"typedef": [true, "callSignature", "indexSignature", "parameter", "propertySignature", "variableDeclarator", "memberVariableDeclarator"],
"underscore-consistent-invocation": true,
"unified-signatures": true,
"variable-name": true,

/**
Expand Down Expand Up @@ -163,6 +169,7 @@ module.exports = {
"align": [true, "parameters", "arguments", "statements"],
"curly": true,
"eofline": true,
"import-spacing": true,
"indent": [true, "spaces"],
"linebreak-style": true,
"no-consecutive-blank-lines": true,
Expand All @@ -188,14 +195,20 @@ module.exports = {
"ban": false, // only enable this if you have some code pattern that you want to ban
"cyclomatic-complexity": true,
"file-header": false, // enable this rule only if you are legally required to add a file header
"import-blacklist": false, // enable and configure this as you desire
"interface-over-type-literal": false, // there are plenty of reasons to prefer interfaces
"no-angle-bracket-type-assertion": false, // pick either type-cast format and use it consistently
"no-empty-interface": false, // it is currently better to use the MS version of this rule
"no-inferred-empty-object-type": false, // if the compiler is satisfied then this is probably not an issue
"no-internal-module": false, // only enable this if you are not using internal modules
"no-magic-numbers": false, // by default it will find too many false positives
"no-mergeable-namespace": false, // your project may require mergeable namespaces
"no-namespace": false, // only enable this if you are not using modules/namespaces
"no-reference": true, // in general you should use a module system and not /// reference imports
"no-unexternalized-strings": false, // the VS Code team has a specific localization process that this rule enforces
"object-literal-shorthand": false, // object-literal-shorthand offers an abbreviation not an abstraction
"prefer-type-cast": true, // pick either type-cast format and use it consistently
"space-before-function-paren": false, // turn this on if this is really your coding standard

/**
* Deprecated rules. The following rules are deprecated for various reasons.
Expand All @@ -207,6 +220,7 @@ module.exports = {
"no-switch-case-fall-through": false, // now supported by TypeScript compiler
"no-unused-imports": false, // use tslint no-unused-variable rule instead
"no-unused-variable": false, // now supported by TypeScript 2.0 compiler
"typeof-compare": false, // the valid-typeof rule is currently superior to this version
}
};

30 changes: 0 additions & 30 deletions src/fixPreferConstFormatter.ts

This file was deleted.

Loading

0 comments on commit a7d12bb

Please sign in to comment.