#407 deprecate no-stateless-class rule in favor of no-unnecessary-class

closes #407
This commit is contained in:
Hamlet D'Arcy 2017-12-18 14:11:18 +01:00
Родитель b5e3cfc11e
Коммит 7ca996d949
3 изменённых файлов: 9 добавлений и 3 удалений

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

@ -116,7 +116,7 @@ Rule Name | Description | Since
`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-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` | 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-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
`no-string-based-set-interval` | Do not use the version of setInterval that accepts code as a string argument. However, it is acceptable to use the version of setInterval where a direct reference to a function is provided as the callback argument | 0.0.1
`no-string-based-set-timeout` | Do not use the version of setTimeout that accepts code as a string argument. However, it is acceptable to use the version of setTimeout where a direct reference to a function is provided as the callback argument | 0.0.1

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

@ -73,7 +73,6 @@ module.exports = {
"no-reference-import": true,
"no-regex-spaces": true,
"no-sparse-arrays": true,
"no-stateless-class": true,
"no-string-literal": true,
"no-string-throw": true,
"no-submodule-imports": true,
@ -259,6 +258,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-stateless-class": true,
"no-switch-case-fall-through": false, // now supported by TypeScript compiler
"typeof-compare": false, // the valid-typeof rule is currently superior to this version
}

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

@ -24,11 +24,17 @@ export class Rule extends Lint.Rules.AbstractRule {
issueType: 'Warning',
severity: 'Important',
level: 'Opportunity for Excellence',
group: 'Correctness',
group: 'Deprecated',
commonWeaknessEnumeration: '398, 710'
};
private static isWarningShown: boolean = false;
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
if (Rule.isWarningShown === false) {
console.warn('Warning: no-stateless-class rule is deprecated. Replace your usage with the TSLint no-unnecessary-class rule.');
Rule.isWarningShown = true;
}
return this.applyWithWalker(new NoStatelessClassRuleWalker(sourceFile, this.getOptions()));
}
}