diff --git a/README.md b/README.md index 6a8c8323968..9c77ceae6ff 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ The configuration file specifies which rules are enabled and their options. Thes /* * Any rules specified here will override those from the base config we are extending */ - "no-constructor-vars": true + "no-parameter-properties": true }, "rulesDirectory": [ /* diff --git a/docs/_data/rules.json b/docs/_data/rules.json index f98b7f7ddd6..cf2f09bccb1 100644 --- a/docs/_data/rules.json +++ b/docs/_data/rules.json @@ -421,17 +421,6 @@ ], "type": "functionality" }, - { - "ruleName": "no-constructor-vars", - "description": "Disallows parameter properties.", - "rationale": "\nParameter properties can be confusing to those new to TS as they are less explicit\nthan other ways of declaring and initializing class members.", - "optionsDescription": "Not configurable.", - "options": null, - "optionExamples": [ - "true" - ], - "type": "style" - }, { "ruleName": "no-construct", "description": "Disallows access to the constructors of `String`, `Number`, and `Boolean`.", @@ -624,6 +613,17 @@ ], "type": "functionality" }, + { + "ruleName": "no-parameter-properties", + "description": "Disallows parameter properties.", + "rationale": "\nParameter properties can be confusing to those new to TS as they are less explicit\nthan other ways of declaring and initializing class members.", + "optionsDescription": "Not configurable.", + "options": null, + "optionExamples": [ + "true" + ], + "type": "style" + }, { "ruleName": "no-reference", "description": "Disallows `/// ` imports (use ES6-style imports instead).", diff --git a/docs/rules/no-constructor-vars/index.html b/docs/rules/no-parameter-properties/index.html similarity index 100% rename from docs/rules/no-constructor-vars/index.html rename to docs/rules/no-parameter-properties/index.html diff --git a/src/configs/recommended.ts b/src/configs/recommended.ts index 99b52e95cb7..2f4992afa3b 100644 --- a/src/configs/recommended.ts +++ b/src/configs/recommended.ts @@ -52,7 +52,6 @@ export const rules = { "trace", ], "no-construct": true, - "no-constructor-vars": false, "no-debugger": true, "no-duplicate-key": true, "no-duplicate-variable": true, @@ -60,6 +59,7 @@ export const rules = { "no-eval": true, "no-internal-module": true, "no-namespace": true, + "no-parameter-properties": false, "no-reference": true, "no-shadowed-variable": true, "no-string-literal": true, diff --git a/src/rules/noConstructorVarsRule.ts b/src/rules/noParameterPropertiesRule.ts similarity index 88% rename from src/rules/noConstructorVarsRule.ts rename to src/rules/noParameterPropertiesRule.ts index 446bb1e1138..eba4b6e8c4f 100644 --- a/src/rules/noConstructorVarsRule.ts +++ b/src/rules/noParameterPropertiesRule.ts @@ -22,8 +22,8 @@ import * as Lint from "../lint"; export class Rule extends Lint.Rules.AbstractRule { /* tslint:disable:object-literal-sort-keys */ public static metadata: Lint.IRuleMetadata = { - ruleName: "no-constructor-vars", - description: "Disallows parameter properties.", + ruleName: "no-parameter-properties", + description: "Disallows parameter properties in class constructors.", rationale: Lint.Utils.dedent` Parameter properties can be confusing to those new to TS as they are less explicit than other ways of declaring and initializing class members.`, @@ -37,11 +37,11 @@ export class Rule extends Lint.Rules.AbstractRule { public static FAILURE_STRING_FACTORY = (ident: string) => `Property '${ident}' cannot be declared in the constructor`; public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { - return this.applyWithWalker(new NoConstructorVarsWalker(sourceFile, this.getOptions())); + return this.applyWithWalker(new NoParameterPropertiesWalker(sourceFile, this.getOptions())); } } -export class NoConstructorVarsWalker extends Lint.RuleWalker { +export class NoParameterPropertiesWalker extends Lint.RuleWalker { public visitConstructorDeclaration(node: ts.ConstructorDeclaration) { const parameters = node.parameters; for (let parameter of parameters) { diff --git a/src/tsconfig.json b/src/tsconfig.json index a4db5f9f864..9e3da7de7fa 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -103,7 +103,6 @@ "rules/noConditionalAssignmentRule.ts", "rules/noConsecutiveBlankLinesRule.ts", "rules/noConsoleRule.ts", - "rules/noConstructorVarsRule.ts", "rules/noConstructRule.ts", "rules/noDebuggerRule.ts", "rules/noDefaultExportRule.ts", @@ -118,6 +117,7 @@ "rules/noMergeableNamespaceRule.ts", "rules/noNamespaceRule.ts", "rules/noNullKeywordRule.ts", + "rules/noParameterPropertiesRule.ts", "rules/noReferenceRule.ts", "rules/noRequireImportsRule.ts", "rules/noShadowedVariableRule.ts", @@ -157,4 +157,4 @@ "test/parse.ts", "test/utils.ts" ] -} +} \ No newline at end of file diff --git a/test/rules/no-constructor-vars/tslint.json b/test/rules/no-constructor-vars/tslint.json deleted file mode 100644 index 6a614c47fcf..00000000000 --- a/test/rules/no-constructor-vars/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-constructor-vars": true - } -} diff --git a/test/rules/no-constructor-vars/test.ts.lint b/test/rules/no-parameter-properties/test.ts.lint similarity index 100% rename from test/rules/no-constructor-vars/test.ts.lint rename to test/rules/no-parameter-properties/test.ts.lint diff --git a/test/rules/no-parameter-properties/tslint.json b/test/rules/no-parameter-properties/tslint.json new file mode 100644 index 00000000000..c65a294034b --- /dev/null +++ b/test/rules/no-parameter-properties/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-parameter-properties": true + } +} diff --git a/test/tsconfig.json b/test/tsconfig.json index 1643ad32432..f95a9ac9338 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -98,7 +98,6 @@ "../src/rules/noConditionalAssignmentRule.ts", "../src/rules/noConsecutiveBlankLinesRule.ts", "../src/rules/noConsoleRule.ts", - "../src/rules/noConstructorVarsRule.ts", "../src/rules/noConstructRule.ts", "../src/rules/noDebuggerRule.ts", "../src/rules/noDefaultExportRule.ts", @@ -113,6 +112,7 @@ "../src/rules/noMergeableNamespaceRule.ts", "../src/rules/noNamespaceRule.ts", "../src/rules/noNullKeywordRule.ts", + "../src/rules/noParameterPropertiesRule.ts", "../src/rules/noReferenceRule.ts", "../src/rules/noRequireImportsRule.ts", "../src/rules/noShadowedVariableRule.ts", @@ -179,4 +179,4 @@ "rule-tester/testData.ts", "rule-tester/utilsTests.ts" ] -} +} \ No newline at end of file