function-name / variable-name rule.
 - we allow much more configuration than tslint.
 - for example, you can define a convention for privates, and a different convention for statics

no-reserved-keywords / variable-name
 - the variable-name rule is not enough to pass the tests for no-reserved-keywords
 - we have more keywords and more usages

missing-jsdoc / file-header
 - missing-jsdoc makes sure you have a top level JSDoc comment somewhere. comment could be at start of file, start of module, or start of class
 - file-header makes sure you have a top level text at start of file

no-unnecessary-field-initialization / TSLint no-unnecessary-initializer
 - these are actually different rules
 - tslint analyzes everything *except* class members: https://github.com/palantir/tslint/blob/master/src/rules/noUnnecessaryInitializerRule.ts
 - our rule analyzes *only* class members

prefer-array-literal / TSLint array-type
 - these are not drop in replacements. Our rule does a fair bit more than the base TSLint rule.

prefer-type-cast / no-angle-bracket-type-assertion
 - These rules are actually opposites of each other
 - TSLint claims to be opinionated, so if they don't like a rule then they don't accept it into their ruleset
 - They told me they don't want this rule in the base product

promise-must-complete / TSLint no-floating-promises
 - These rules are coded fairly differently, and are not replacements
 - It appears that the tslint rule does not satisfy the unit tests for promise-must-complete.
 - no-floating-promises requires type checking

react-tsx-curly-spacing / tslint-react jsx-curly-spacing rule.
 - I generally don't recommend tslint-react over tslint-microsoft-contrib
 - There is a ton of overlap between the two projects
This commit is contained in:
Hamlet D'Arcy 2017-12-18 15:15:40 +01:00
Родитель 7ca996d949
Коммит d0694bcfad
14 изменённых файлов: 19 добавлений и 71 удалений

Просмотреть файл

@ -76,12 +76,12 @@ Rule Name | Description | Since
`chai-prefer-contains-to-index-of` | Avoid Chai assertions that invoke indexOf and compare for a -1 result. It is better to use the chai .contain() assertion API instead because the failure message will be more clearer if the test fails. | 2.0.10
`chai-vague-errors` | Avoid Chai assertions that result in vague errors. For example, asserting `expect(something).to.be.true` will result in the failure message "Expected true received false". This is a vague error message that does not reveal the underlying problem. It is especially vague in TypeScript because stack trace line numbers often do not match the source code. A better pattern to follow is the xUnit Patterns [Assertion Message](http://xunitpatterns.com/Assertion%20Message.html) pattern. The previous code sample could be better written as `expect(something).to.equal(true, 'expected something to have occurred');`| 1.0
`export-name` | The name of the exported module must match the filename of the source file. This is case-sensitive but ignores file extension. Since version 1.0, this rule takes a list of regular expressions as a parameter. Any export name matching that regular expression will be ignored. For example, to allow an exported name like myChartOptions, then configure the rule like this: "export-name": \[true, "myChartOptionsg"\]| 0.0.3
`function-name` | Deprecated - This rule can be replaced with TSLint's variable-name. Applies a naming convention to function names and method names. You can configure the naming convention by passing parameters. Please note, the private-method-regex does take precedence over the static-method-regex, so a private static method must match the private-method-regex. The default values are: <br> [ true, { <br> "method-regex": "^[a-z][\\w\\d]+$",<br> "private-method-regex": "^[a-z][\\w\\d]+$",<br> "protected-method-regex": "^[a-z][\\w\\d]+$",<br> "static-method-regex": "^[A-Z_\\d]+$",<br> "function-regex": "^[a-z][\\w\\d]+$"<br> }] | 2.0.7, 2.0.14
`function-name` | Applies a naming convention to function names and method names. You can configure the naming convention by passing parameters. Please note, the private-method-regex does take precedence over the static-method-regex, so a private static method must match the private-method-regex. The default values are: <br> [ true, { <br> "method-regex": "^[a-z][\\w\\d]+$",<br> "private-method-regex": "^[a-z][\\w\\d]+$",<br> "protected-method-regex": "^[a-z][\\w\\d]+$",<br> "static-method-regex": "^[A-Z_\\d]+$",<br> "function-regex": "^[a-z][\\w\\d]+$"<br> }<br/>This rule has some overlap with the [tslint variable-name rule](https://palantir.github.io/tslint/rules/variable-name/); however, the rule here is more configurable.] | 2.0.7, 2.0.14
`import-name` | The name of the imported module must match the name of the thing being imported. For example, it is valid to name imported modules the same as the module name: `import Service = require('x/y/z/Service')` and `import Service from 'x/y/z/Service'`. But it is invalid to change the name being imported, such as: `import MyCoolService = require('x/y/z/Service')` and `import MyCoolService from 'x/y/z/Service'`. Since version 2.0.9 it is possible to configure this rule with a list of exceptions. For example, to allow `underscore` to be imported as `_`, add this configuration: `'import-name': [ true, { 'underscore': '_' }]`| 2.0.5
`insecure-random` | Do not use insecure sources for random bytes. Use a secure random number generator instead. Bans all uses of Math.random and crypto.pseudoRandomBytes. Better alternatives are crypto.randomBytes and window.crypto.getRandomValues.<br/>References:<br/>* [CWE 330](https://cwe.mitre.org/data/definitions/330.html)<br/>* [MDN Math.random](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random)<br/>* [Node.js crypto.randomBytes()](http://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback)<br/>* [window.crypto.getRandomValues()](https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues)<br/> | 2.0.11
`jquery-deferred-must-complete` | When a JQuery Deferred instance is created, then either reject() or resolve() 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/26). | 1.0
`max-func-body-length` | Avoid long functions. The line count of a function body must not exceed the value configured within this rule's options. <br>You can setup a general max function body length applied for every function/method/arrow function e.g. \[true, 30\] or set different maximum length for every type e.g. \[true, \{ "func-body-length": 10 , "func-expression-body-length": 10 , "arrow-body-length": 5, "method-body-length": 15, "ctor-body-length": 5 \}\]. To specify a function name whose parameters you can ignore for this rule, pass a regular expression as a string(this can be useful for Mocha users to ignore the describe() function). Since version 2.0.9, you can also ignore single- and multi-line comments from the total function length, eg. \[true, \{ "ignore-comments": true \}\] | 2.0.3
`missing-jsdoc` | Deprecated - This rule can be replaced with TSLint's file-header. All files must have a top level [JSDoc](http://usejsdoc.org/) comment. A JSDoc comment starts with /** (not one more or one less asterisk) and a JSDoc at the 'top-level' appears without leading spaces. Trailing spaces are acceptable but not recommended. | 1.0
`missing-jsdoc` | All files must have a top level [JSDoc](http://usejsdoc.org/) comment. A JSDoc comment starts with /** (not one more or one less asterisk) and a JSDoc at the 'top-level' appears without leading spaces. Trailing spaces are acceptable but not recommended. | 1.0
`missing-optional-annotation` | Deprecated - This rule is now enforced by the TypeScript compiler. A parameter that follows one or more parameters marked as optional is not itself marked optional | 0.0.1
`mocha-avoid-only` | Do not invoke Mocha's describe.only, it.only or context.only functions. These functions are useful ways to run a single unit test or a single test case during your build, but please be careful to not push these methods calls to your version control repositiory because it will turn off any of the other tests.| 1.0
`mocha-no-side-effect-code` | All test logic in a Mocha test case should be within Mocha lifecycle method and not defined statically to execute when the module loads. Put all assignments and initialization statements in a before(), beforeEach(), beforeAll(), after(), afterEach(), afterAll(), or it() function. Code executed outside of these lifecycle methods can throw exceptions before the test runner is initialized and can result in errors or even test runner crashes. This rule can be configured with a regex to ignore certain initializations. For example, to ignore any calls to `RestDataFactory` configure the rule with: `[true, { ignore: '^RestDataFactory\\..*' }]`| 2.0.10
@ -114,7 +114,7 @@ Rule Name | Description | Since
`no-octal-literal` | Do not use octal literals or escaped octal sequences | 0.0.1
`no-regex-spaces` | Do not use multiple spaces in a regular expression literal. Similar to the [ESLint no-regex-spaces](http://eslint.org/docs/rules/no-regex-spaces.html) rule | 1.0
`no-relative-imports` | Do not use relative paths when importing external modules or ES6 import declarations. The advantages of removing all relative paths from imports is that 1) the import name will be consistent across all files and subdirectories so searching for usages is much easier. 2) Moving source files to different folders will not require you to edit your import statements. 3) It will be possible to copy and paste import lines between files regardless of the file location. And 4) version control diffs will be simplified by having overall fewer edits to the import lines.| 2.0.5
`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. This can be a useful way to avoid verbose suppress-warning comments for generated d.ts files.| 0.0.1, 2.0.9
`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. This can be a useful way to avoid verbose suppress-warning comments for generated d.ts files. <br/>This rule has some overlap with the [tslint variable-name rule](https://palantir.github.io/tslint/rules/variable-name/), however, the rule here finds more keywords and more usages.| 0.0.1, 2.0.9
`no-single-line-block-comment` | Avoid single line block comments and use single line comments instead. Block comments do not nest properly and have no advantages over normal single-line comments| 2.0.10
`no-stateless-class` | Deprecated - This rule can be replaced with TSLint's no-unnecessary-class. A stateless class represents a failure in the object oriented design of the system. A class without state is better modeled as a module or given some state. A stateless class is defined as a class with only static members and no parent class.| 2.0.4
`no-string-based-set-immediate` | Do not use the version of setImmediate that accepts code as a string argument. However, it is acceptable to use the version of setImmediate where a direct reference to a function is provided as the callback argument | 0.0.1
@ -124,7 +124,7 @@ Rule Name | Description | Since
`no-typeof-undefined` | Do not use the idiom `typeof x === 'undefined'`. You can safely use the simpler `x === undefined` or perhaps `x == null` if you want to check for either null or undefined. | 2.0.8
`no-unexternalized-strings` | Ensures that double quoted strings are passed to a localize call to provide proper strings for different locales. The rule can be configured using an object literal as document in the [feature request](https://github.com/Microsoft/tslint-microsoft-contrib/issues/95#issuecomment-173149989)| 2.0.1
`no-unnecessary-bind` | 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. Works for Underscore methods as well. | 1.0
`no-unnecessary-field-initialization` | Deprecated - This rule can be replaced with TSLint's no-unnecessary-initializer. Do not unnecessarily initialize the fields of a class to values they already have. For example, there is no need to explicitly set a field to `undefined` in the field's initialization or in the class' constructor. Also, if a field is initialized to a constant value (null, a string, a boolean, or some number) then there is no need to reassign the field to this value within the class constructor. | 2.0.9
`no-unnecessary-field-initialization` | Do not unnecessarily initialize the fields of a class to values they already have. For example, there is no need to explicitly set a field to `undefined` in the field's initialization or in the class' constructor. Also, if a field is initialized to a constant value (null, a string, a boolean, or some number) then there is no need to reassign the field to this value within the class constructor. | 2.0.9
`no-unnecessary-local-variable` | Do not declare a variable only to return it from the function on the next line. It is always less code to simply return the expression that initializes the variable. | 2.0.4
`no-unnecessary-override` | Do not write a method that only calls super() on the parent method with the same arguments. You can safely remove methods like this and Javascript will correctly dispatch the method to the parent object. | 2.0.4
`no-unnecessary-semicolons` | Remove unnecessary semicolons | 0.0.1
@ -134,9 +134,9 @@ Rule Name | Description | Since
`no-with-statement` | Do not use with statements. Assign the item to a new variable instead | 0.0.1
`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` | Deprecated - This rule can be replaced with TSLint's array-type. 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-type-cast` | Deprecated - This rule can be replaced with TSLint's no-angle-bracket-type-assertion. 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` | Deprecated - This rule can be replaced with TSLint's no-floating-promises. 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
`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 } ]`<br/>This rule has some overlap with the [TSLint array-type rule](https://palantir.github.io/tslint/rules/array-type/), however, the version here catches more instances. | 1.0, 2.0.10
`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). <br/><br/>This rule has some overlap with the [tslint no-floating-promises rule](https://palantir.github.io/tslint/rules/no-floating-promises/), but they are substantially different. | 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
`react-a11y-aria-unsupported-elements` | For accessibility of your website, enforce that elements that do not support ARIA roles, states, and properties do not have those attributes. | 2.0.11
`react-a11y-event-has-role` | For accessibility of your website, Elements with event handlers must have explicit role or implicit role.<br/>References:<br/>[WCAG Rule 94](http://oaa-accessibility.org/wcag20/rule/94/)<br/>[Using the button role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_button_role) | 2.0.11
@ -155,7 +155,7 @@ Rule Name | Description | Since
`react-iframe-missing-sandbox` | React iframes must specify a sandbox attribute. If specified as an empty string, this attribute enables extra restrictions on the content that can appear in the inline frame. The value of the attribute can either be an empty string (all the restrictions are applied), or a space-separated list of tokens that lift particular restrictions. You many not use both allow-scripts and allow-same-origin at the same time, as that allows the embedded document to programmatically remove the sandbox attribute in some scenarios. | 2.0.10
`react-no-dangerous-html` | Do not use React's dangerouslySetInnerHTML API. This rule finds usages of the dangerouslySetInnerHTML API (but not any JSX references). For more info see the [react-no-dangerous-html Rule wiki page](https://github.com/Microsoft/tslint-microsoft-contrib/wiki/react-no-dangerous-html-Rule). | 0.0.2
`react-this-binding-issue` | Several errors can occur when using React and React.Component subclasses. When using React components you must be careful to correctly bind the 'this' reference on any methods that you pass off to child components as callbacks. For example, it is common to define a private method called 'onClick' and then specify `onClick={this.onClick}` as a JSX attribute. If you do this then the 'this' reference will be undefined when your private method is invoked. The React documentation suggests that you bind the 'this' reference on all of your methods within the constructor: `this.onClick = this.onClick.bind(this);`. This rule will create a violation if 1) a method reference is passed to a JSX attribute without being bound in the constructor. And 2) a method is bound multiple times in the constructor. Another issue that can occur is binding the 'this' reference to a function within the render() method. For example, many people will create an anonymous lambda within the JSX attribute to avoid the 'this' binding issue: `onClick={() => { this.onClick(); }}`. The problem with this is that a new instance of an anonymous function is created every time render() is invoked. When React compares virutal DOM properties within shouldComponentUpdate() then the onClick property will look like a new property and force a re-render. You should avoid this pattern because creating function instances within render methods breaks any logic within shouldComponentUpdate() methods. This rule creates violations if 1) an anonymous function is passed as a JSX attribute. And 2) if a function instantiated in local scope is passed as a JSX attribute. This rule can be configured via the "allow-anonymous-listeners" parameter. If you want to suppress violations for the anonymous listener scenarios then configure that rule like this: `"react-this-binding-issue": [ true, { 'allow-anonymous-listeners': true } ]` | 2.0.8, 2.0.9
`react-tsx-curly-spacing` | Deprecated - This rule can be replaced with tslint-react's jsx-curly-spacing. Consistently use spaces around the brace characters of JSX attributes.You can either allow or bad spaces between the braces and the values they enclose. <br/><br/>One of the two following options are required:<br/>* "always" enforces a space inside of curly braces (default)<br/>* "never" disallows spaces inside of curly braces<br/><br/>By default, braces spanning multiple lines are not allowed with either setting. If you want to allow them you can specify an additional allowMultiline property with the value false. <br/><br/>Examples: <br/>* "react-tsx-curly-spacing": [true, "always"]<br/>* "react-tsx-curly-spacing": [true, "never"]<br/>* "react-tsx-curly-spacing": [true, "never", {"allowMultiline": false}]<br/><br/>References<br/>* [eslint-plugin-react jsx-curly-spacing rule](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md) | 2.0.14
`react-tsx-curly-spacing` | Consistently use spaces around the brace characters of JSX attributes. You can either allow or ban spaces between the braces and the values they enclose. <br/><br/>One of the two following options are required:<br/>* "always" enforces a space inside of curly braces (default)<br/>* "never" disallows spaces inside of curly braces<br/><br/>By default, braces spanning multiple lines are not allowed with either setting. If you want to allow them you can specify an additional allowMultiline property with the value false. <br/><br/>Examples: <br/>* "react-tsx-curly-spacing": [true, "always"]<br/>* "react-tsx-curly-spacing": [true, "never"]<br/>* "react-tsx-curly-spacing": [true, "never", {"allowMultiline": false}]<br/><br/>References<br/>* [eslint-plugin-react jsx-curly-spacing rule](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md) <br/>* [tslint-react jsx-curly-spacing rule](https://github.com/palantir/tslint-react) | 2.0.14
`react-unused-props-and-state` | Remove unneeded properties defined in React Props and State interfaces. Any interface named Props or State is defined as a React interface. All fields in these interfaces must be referenced. This rule can be configured with regexes to match custom Props and State interface names. <br/><br/>Example for including all interfaces ending with Props or State: <br/>*[ true, { 'props-interface-regex': 'Props$', 'state-interface-regex': 'State$' } ]* | 2.0.10
`underscore-consistent-invocation` | Enforce a consistent usage of the _ functions. By default, invoking underscore functions should begin with wrapping a variable in an underscore instance: `_(list).map(...)`. An alternative is to prefer using the static methods on the _ variable: `_.map(list, ...)`. The rule accepts single parameter called 'style' which can be the value 'static' or 'instance': `[true, { "style": "static" }]`| 2.0.10
`use-named-parameter` | Do not reference the arguments object by numerical index; instead, use a named parameter. This rule is similar to JSLint's [Use a named parameter](https://jslinterrors.com/use-a-named-parameter) rule. | 0.0.3

Просмотреть файл

@ -52,7 +52,6 @@ module.exports = {
"no-constant-condition": true,
"no-control-regex": true,
"no-debugger": true,
"no-duplicate-case": true,
"no-duplicate-super": true,
"no-duplicate-switch-case": true,
"no-duplicate-variable": true,
@ -97,7 +96,6 @@ module.exports = {
"triple-equals": [true, "allow-null-check"],
"use-isnan": true,
"use-named-parameter": true,
"valid-typeof": true,
/**
* Code Clarity. The following rules should be turned on because they make the code
@ -155,7 +153,6 @@ module.exports = {
"no-useless-files": true,
"no-var-keyword": true,
"no-var-requires": true,
"no-var-self": true,
"no-void-expression": true,
"number-literal-format": true,
"object-literal-sort-keys": false, // turn object-literal-sort-keys off and sort keys in a meaningful manner
@ -215,7 +212,6 @@ module.exports = {
"object-literal-key-quotes": [true, "as-needed"],
"one-line": [true, "check-open-brace", "check-catch", "check-else", "check-whitespace"],
"quotemark": [true, "single"],
"react-tsx-curly-spacing": true,
"semicolon": [true, "always"],
"space-within-parens": true,
"trailing-comma": [true, {"singleline": "never", "multiline": "never"}], // forcing trailing commas for multi-line
@ -254,13 +250,17 @@ module.exports = {
* Deprecated rules. The following rules are deprecated for various reasons.
*/
"missing-optional-annotation": false, // now supported by TypeScript compiler
"no-duplicate-case": true,
"no-duplicate-parameter-names": false, // now supported by TypeScript compiler
"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-stateless-class": true,
"no-switch-case-fall-through": false, // now supported by TypeScript compiler
"no-var-self": true,
"react-tsx-curly-spacing": true,
"typeof-compare": false, // the valid-typeof rule is currently superior to this version
"valid-typeof": true,
}
};

Просмотреть файл

@ -31,13 +31,7 @@ export class Rule extends Lint.Rules.AbstractRule {
commonWeaknessEnumeration: '398, 710'
};
private static isWarningShown: boolean = false;
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
if (Rule.isWarningShown === false) {
console.warn('Warning: function-name rule is deprecated. Replace your usage with the TSLint variable-name rule.');
Rule.isWarningShown = true;
}
return this.applyWithWalker(new FunctionNameRuleWalker(sourceFile, this.getOptions()));
}
}

Просмотреть файл

@ -26,13 +26,7 @@ export class Rule extends Lint.Rules.AbstractRule {
public static FAILURE_STRING: string = 'File missing JSDoc comment at the top-level: ';
private static isWarningShown: boolean = false;
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
if (Rule.isWarningShown === false) {
console.warn('Warning: missing-jsdoc rule is deprecated. Replace your usage with the TSLint file-header rule.');
Rule.isWarningShown = true;
}
return this.applyWithWalker(new MissingJSDocWalker(sourceFile, this.getOptions()));
}
}

Просмотреть файл

@ -20,7 +20,7 @@ export class Rule extends Lint.Rules.AbstractRule {
issueType: 'Error',
severity: 'Critical',
level: 'Opportunity for Excellence',
group: 'Correctness',
group: 'Deprecated',
commonWeaknessEnumeration: '398, 710'
};

Просмотреть файл

@ -50,13 +50,7 @@ export class Rule extends Lint.Rules.AbstractRule {
'from', '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(),

Просмотреть файл

@ -28,14 +28,7 @@ export class Rule extends Lint.Rules.AbstractRule {
commonWeaknessEnumeration: '398, 710'
};
private static isWarningShown: boolean = false;
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
if (Rule.isWarningShown === false) {
console.warn('Warning: no-unnecessary-field-initialization rule is deprecated. ' +
'Replace your usage with the TSLint no-unnecessary-initializer rule.');
Rule.isWarningShown = true;
}
return this.applyWithWalker(new UnnecessaryFieldInitializationRuleWalker(sourceFile, this.getOptions()));
}
}

Просмотреть файл

@ -21,7 +21,7 @@ export class Rule extends Lint.Rules.AbstractRule {
issueType: 'Warning',
severity: 'Important',
level: 'Opportunity for Excellence',
group: 'Clarity',
group: 'Deprecated',
commonWeaknessEnumeration: '398, 710'
};

Просмотреть файл

@ -28,13 +28,7 @@ export class Rule extends Lint.Rules.AbstractRule {
public static GENERICS_FAILURE_STRING: string = 'Replace generic-typed Array with array literal: ';
public static CONSTRUCTOR_FAILURE_STRING: string = 'Replace Array constructor with an array literal: ';
private static isWarningShown: boolean = false;
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
if (Rule.isWarningShown === false) {
console.warn('Warning: prefer-array-literal rule is deprecated. Replace your usage with the TSLint array-type rule.');
Rule.isWarningShown = true;
}
return this.applyWithWalker(new NoGenericArrayWalker(sourceFile, this.getOptions()));
}
}

Просмотреть файл

@ -27,14 +27,7 @@ export class Rule extends Lint.Rules.AbstractRule {
commonWeaknessEnumeration: '398, 710'
};
private static isWarningShown: boolean = false;
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
if (Rule.isWarningShown === false) {
console.warn('Warning: prefer-type-cast rule is deprecated. ' +
'Replace your usage with the TSLint no-angle-bracket-type-assertion rule.');
Rule.isWarningShown = true;
}
return this.applyWithWalker(new PreferTypeCastRuleWalker(sourceFile, this.getOptions()));
}
}

Просмотреть файл

@ -28,14 +28,7 @@ export class Rule extends Lint.Rules.AbstractRule {
public static FAILURE_STRING: string = 'A Promise was found that appears to not have resolve or reject invoked on all code paths';
private static isWarningShown: boolean = false;
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
if (Rule.isWarningShown === false) {
console.warn('Warning: promise-must-complete rule is deprecated. ' +
'Replace your usage with the TSLint no-floating-promises rule.');
Rule.isWarningShown = true;
}
return this.applyWithWalker(new PromiseAnalyzer(sourceFile, this.getOptions()));
}
}

Просмотреть файл

@ -20,17 +20,10 @@ export class Rule extends Lint.Rules.AbstractRule {
issueType: 'Warning',
severity: 'Low',
level: 'Opportunity for Excellence',
group: 'Whitespace'
group: 'Deprecated'
};
private static isWarningShown: boolean = false;
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
if (Rule.isWarningShown === false) {
console.warn('Warning: react-tsx-curly-spacing rule is deprecated. ' +
'Replace your usage with the tslint-react jsx-curly-spacing rule.');
Rule.isWarningShown = true;
}
return this.applyWithWalker(new TsxCurlySpacingWalker(sourceFile, this.getOptions()));
}
}

Просмотреть файл

@ -20,7 +20,7 @@ export class Rule extends Lint.Rules.AbstractRule {
issueType: 'Error',
severity: 'Critical',
level: 'Opportunity for Excellence',
group: 'Correctness'
group: 'Deprecated'
};
public static FAILURE_STRING: string = 'Invalid comparison in typeof. Did you mean ';

Просмотреть файл

@ -155,7 +155,7 @@
"no-shadowed-variable": true,
"no-single-line-block-comment": true,
"no-sparse-arrays": true,
"no-stateless-class": true,
"no-stateless-class": false,
"no-string-based-set-immediate": true,
"no-string-based-set-interval": true,
"no-string-based-set-timeout": true,
@ -181,7 +181,7 @@
"no-use-before-declare": true,
"no-var-keyword": true,
"no-var-requires": true,
"no-var-self": true,
"no-var-self": false,
"no-void-expression": false,
"no-with-statement": true,
"non-literal-require": true,
@ -272,7 +272,7 @@
"unified-signatures": true,
"use-isnan": true,
"use-named-parameter": true,
"valid-typeof": true,
"valid-typeof": false,
"variable-name": true,
"whitespace": [
true,