Skip to content

Commit

Permalink
Rename no-constructor-vars to no-parameter-properties (palantir#1616)
Browse files Browse the repository at this point in the history
Resolves palantir#1296.
  • Loading branch information
adidahiya authored Oct 9, 2016
1 parent 2534fc9 commit 01e9e3c
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
/*
Expand Down
22 changes: 11 additions & 11 deletions docs/_data/rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -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`.",
Expand Down Expand Up @@ -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 `/// <reference path=>` imports (use ES6-style imports instead).",
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/configs/recommended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ export const rules = {
"trace",
],
"no-construct": true,
"no-constructor-vars": false,
"no-debugger": true,
"no-duplicate-key": true,
"no-duplicate-variable": true,
"no-empty": true,
"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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -157,4 +157,4 @@
"test/parse.ts",
"test/utils.ts"
]
}
}
5 changes: 0 additions & 5 deletions test/rules/no-constructor-vars/tslint.json

This file was deleted.

File renamed without changes.
5 changes: 5 additions & 0 deletions test/rules/no-parameter-properties/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"no-parameter-properties": true
}
}
4 changes: 2 additions & 2 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -179,4 +179,4 @@
"rule-tester/testData.ts",
"rule-tester/utilsTests.ts"
]
}
}

0 comments on commit 01e9e3c

Please sign in to comment.