diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index d10412f791a16befd901d8174f248bad6da19077..b298cfd31c6bb30a6c7d99e0150fae1399eb3dc9 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -605,6 +605,7 @@ export class TypeScriptLinter { tsParamMods && (this.tsUtils.hasModifier(tsParamMods, ts.SyntaxKind.PublicKeyword) || this.tsUtils.hasModifier(tsParamMods, ts.SyntaxKind.ProtectedKeyword) || + this.tsUtils.hasModifier(tsParamMods, ts.SyntaxKind.ReadonlyKeyword) || this.tsUtils.hasModifier(tsParamMods, ts.SyntaxKind.PrivateKeyword)) ) this.incrementCounters(node, FaultID.ParameterProperties); diff --git a/linter-4.2/test_rules/rule25.ts b/linter-4.2/test_rules/rule25.ts index a485b8eb2e68e663428d96a9115e620de0c63f3d..897e74605829164af9dda02e34ce037cd6344f07 100644 --- a/linter-4.2/test_rules/rule25.ts +++ b/linter-4.2/test_rules/rule25.ts @@ -28,4 +28,10 @@ class Person2{ getFullName(): string { return this.firstName + " " + this.lastName } -} \ No newline at end of file +} + +class A { + constructor(readonly a: A) { + this.a = a; + } +} diff --git a/linter-4.2/test_rules/rule25.ts.autofix.json b/linter-4.2/test_rules/rule25.ts.autofix.json index 4f15af43d3cd4d47c0002ae821eac58ee1385e8b..a8bfef4cc724ddbe3de376642327337059deabec 100644 --- a/linter-4.2/test_rules/rule25.ts.autofix.json +++ b/linter-4.2/test_rules/rule25.ts.autofix.json @@ -23,6 +23,14 @@ "autofixable": false, "suggest": "", "rule": "Declaring fields in \"constructor\" is not supported (arkts-no-ctor-prop-decls)" + }, + { + "line": 34, + "column": 17, + "problem": "ParameterProperties", + "autofixable": false, + "suggest": "", + "rule": "Declaring fields in \"constructor\" is not supported (arkts-no-ctor-prop-decls)" } ] } \ No newline at end of file diff --git a/linter-4.2/test_rules/rule25.ts.strict.json b/linter-4.2/test_rules/rule25.ts.strict.json index ec5820fcb3a10c4279732c61211e0e0f21f011d1..e76c79a3ecefa72a2faeb29a0e763a1336e17827 100644 --- a/linter-4.2/test_rules/rule25.ts.strict.json +++ b/linter-4.2/test_rules/rule25.ts.strict.json @@ -20,6 +20,13 @@ "problem": "ParameterProperties", "suggest": "", "rule": "Declaring fields in \"constructor\" is not supported (arkts-no-ctor-prop-decls)" + }, + { + "line": 34, + "column": 17, + "problem": "ParameterProperties", + "suggest": "", + "rule": "Declaring fields in \"constructor\" is not supported (arkts-no-ctor-prop-decls)" } ] } \ No newline at end of file diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index 9881df992619da5b97852efbec3123ab4e17b243..7219f7170a2ce975f141ec8216d39c1416d83bfe 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -498,6 +498,7 @@ export class TypeScriptLinter { tsParamMods && (this.tsUtils.hasModifier(tsParamMods, ts.SyntaxKind.PublicKeyword) || this.tsUtils.hasModifier(tsParamMods, ts.SyntaxKind.ProtectedKeyword) || + this.tsUtils.hasModifier(tsParamMods, ts.SyntaxKind.ReadonlyKeyword) || this.tsUtils.hasModifier(tsParamMods, ts.SyntaxKind.PrivateKeyword)) ) { this.incrementCounters(node, FaultID.ParameterProperties); diff --git a/linter/test_rules/rule25.ts b/linter/test_rules/rule25.ts index a485b8eb2e68e663428d96a9115e620de0c63f3d..19985f8d6a507c57115b70629094d99c266236bb 100644 --- a/linter/test_rules/rule25.ts +++ b/linter/test_rules/rule25.ts @@ -28,4 +28,11 @@ class Person2{ getFullName(): string { return this.firstName + " " + this.lastName } -} \ No newline at end of file +} + +class A { + constructor(readonly a: A) { + this.a = a; + } +} + \ No newline at end of file diff --git a/linter/test_rules/rule25.ts.autofix.json b/linter/test_rules/rule25.ts.autofix.json index 4f15af43d3cd4d47c0002ae821eac58ee1385e8b..a8bfef4cc724ddbe3de376642327337059deabec 100644 --- a/linter/test_rules/rule25.ts.autofix.json +++ b/linter/test_rules/rule25.ts.autofix.json @@ -23,6 +23,14 @@ "autofixable": false, "suggest": "", "rule": "Declaring fields in \"constructor\" is not supported (arkts-no-ctor-prop-decls)" + }, + { + "line": 34, + "column": 17, + "problem": "ParameterProperties", + "autofixable": false, + "suggest": "", + "rule": "Declaring fields in \"constructor\" is not supported (arkts-no-ctor-prop-decls)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule25.ts.strict.json b/linter/test_rules/rule25.ts.strict.json index ec5820fcb3a10c4279732c61211e0e0f21f011d1..e76c79a3ecefa72a2faeb29a0e763a1336e17827 100644 --- a/linter/test_rules/rule25.ts.strict.json +++ b/linter/test_rules/rule25.ts.strict.json @@ -20,6 +20,13 @@ "problem": "ParameterProperties", "suggest": "", "rule": "Declaring fields in \"constructor\" is not supported (arkts-no-ctor-prop-decls)" + }, + { + "line": 34, + "column": 17, + "problem": "ParameterProperties", + "suggest": "", + "rule": "Declaring fields in \"constructor\" is not supported (arkts-no-ctor-prop-decls)" } ] } \ No newline at end of file