Skip to content

Commit 879d5db

Browse files
authored
chore: make error message about statics more descriptive (#253)
Add a 'non-const' qualifier to indicate that you probably forgot to add 'const' on your 'public static' properties.
1 parent 7e600f9 commit 879d5db

9 files changed

+9
-9
lines changed

Diff for: packages/jsii/lib/validator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function _defaultValidations(): ValidationFunction[] {
7575
if (member.static && (member as spec.Property).const) { continue; }
7676
if (member.name && member.name !== Case.camel(member.name)) {
7777
diagnostic(ts.DiagnosticCategory.Error,
78-
`Method and property names must use camelCase: ${member.name}`);
78+
`Method and non-static non-readonly property names must use camelCase: ${member.name}`);
7979
}
8080
}
8181
}

Diff for: packages/jsii/test/negatives/neg.method-name.1.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
///!MATCH_ERROR: Method and property names must use camelCase: METHOD
1+
///!MATCH_ERROR: Method and non-static non-readonly property names must use camelCase: METHOD
22

33
export class MyClass {
44
public METHOD() {

Diff for: packages/jsii/test/negatives/neg.method-name.2.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
///!MATCH_ERROR: Method and property names must use camelCase: hello_world
1+
///!MATCH_ERROR: Method and non-static non-readonly property names must use camelCase: hello_world
22

33
export class MyClass {
44
public hello_world() {

Diff for: packages/jsii/test/negatives/neg.property-name.1.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
///!MATCH_ERROR: Method and property names must use camelCase: PROP
1+
///!MATCH_ERROR: Method and non-static non-readonly property names must use camelCase: PROP
22

33
export class MyClass {
44
public PROP?: number;

Diff for: packages/jsii/test/negatives/neg.property-name.2.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
///!MATCH_ERROR: Method and property names must use camelCase: my_Prop
1+
///!MATCH_ERROR: Method and non-static non-readonly property names must use camelCase: my_Prop
22

33
export class MyClass {
44
public my_Prop?: number;

Diff for: packages/jsii/test/negatives/neg.static-method-name.1.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
///!MATCH_ERROR: Method and property names must use camelCase: MethodIsNotCamelCase
1+
///!MATCH_ERROR: Method and non-static non-readonly property names must use camelCase: MethodIsNotCamelCase
22

33
export class MyClass {
44
MethodIsNotCamelCase() {

Diff for: packages/jsii/test/negatives/neg.static-method-name.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
///!MATCH_ERROR: Method and property names must use camelCase: METHOD
1+
///!MATCH_ERROR: Method and non-static non-readonly property names must use camelCase: METHOD
22

33
export class MyClass {
44
METHOD() {

Diff for: packages/jsii/test/negatives/neg.static-prop-name.1.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
///!MATCH_ERROR: Method and property names must use camelCase: Prop
1+
///!MATCH_ERROR: Method and non-static non-readonly property names must use camelCase: Prop
22

33
export class MyClass {
44
static get Prop() {

Diff for: packages/jsii/test/negatives/neg.static-prop-name.2.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
///!MATCH_ERROR: Method and property names must use camelCase: PROP
1+
///!MATCH_ERROR: Method and non-static non-readonly property names must use camelCase: PROP
22

33
export class MyClass {
44
static get PROP() {

0 commit comments

Comments
 (0)