-
Notifications
You must be signed in to change notification settings - Fork 439
Expand file tree
/
Copy pathlwc-class.ts
More file actions
237 lines (206 loc) · 7.93 KB
/
lwc-class.ts
File metadata and controls
237 lines (206 loc) · 7.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/*
* Copyright (c) 2024, Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { DiagnosticLevel, type LWCErrorInfo } from '../../shared/types';
/*
* For the next available error code, reference (and update!) the value in ./index.ts
*/
export const LWCClassErrors = {
INVALID_DYNAMIC_IMPORT_SOURCE_STRICT: {
code: 1121,
message:
'Invalid import. The argument "{0}" must be a stringLiteral for dynamic imports when strict mode is enabled.',
url: 'https://lwc.dev/guide/error_codes#lwc1121',
level: DiagnosticLevel.Error,
},
} as const satisfies Record<string, LWCErrorInfo>;
export const DecoratorErrors = {
ADAPTER_SHOULD_BE_FIRST_PARAMETER: {
code: 1092,
message:
'@wire expects an adapter as first parameter. @wire(adapter: WireAdapter, config?: any).',
level: DiagnosticLevel.Error,
url: 'https://lwc.dev/guide/error_codes#lwc1092',
},
API_AND_TRACK_DECORATOR_CONFLICT: {
code: 1093,
message: '@api method or property cannot be used with @track',
level: DiagnosticLevel.Error,
url: 'https://lwc.dev/guide/error_codes#lwc1093',
},
CONFIG_OBJECT_SHOULD_BE_SECOND_PARAMETER: {
code: 1094,
message: '@wire expects a configuration object expression as second parameter.',
level: DiagnosticLevel.Error,
url: 'https://lwc.dev/guide/error_codes#lwc1094',
},
CONFLICT_WITH_ANOTHER_DECORATOR: {
code: 1095,
message: '@wire method or property cannot be used with @{0}',
level: DiagnosticLevel.Error,
url: 'https://lwc.dev/guide/error_codes#lwc1095',
},
DUPLICATE_API_PROPERTY: {
code: 1096,
message: 'Duplicate @api property "{0}".',
level: DiagnosticLevel.Error,
url: 'https://lwc.dev/guide/error_codes#lwc1096',
},
FUNCTION_IDENTIFIER_SHOULD_BE_FIRST_PARAMETER: {
code: 1097,
message: '@wire expects a function identifier as first parameter.',
level: DiagnosticLevel.Error,
url: 'https://lwc.dev/guide/error_codes#lwc1097',
},
IMPORTED_FUNCTION_IDENTIFIER_SHOULD_BE_FIRST_PARAMETER: {
code: 1098,
message: '@wire expects a function identifier to be imported as first parameter.',
level: DiagnosticLevel.Error,
url: '',
},
INVALID_BOOLEAN_PUBLIC_PROPERTY: {
code: 1099,
message: 'Boolean public property must default to false.',
level: DiagnosticLevel.Error,
url: 'https://lwc.dev/guide/error_codes#lwc1099',
},
INVALID_DECORATOR: {
code: 1100,
message:
'Invalid decorator usage. Supported decorators ({0}) should be imported from "{1}"',
level: DiagnosticLevel.Error,
url: '',
},
INVALID_DECORATOR_TYPE: {
code: 1101,
message: 'Invalid property of field type',
level: DiagnosticLevel.Error,
url: '',
},
INVALID_DECORATOR_WITH_NAME: {
code: 1102,
message:
'Invalid \'{0}\' decorator usage. Supported decorators ({1}) should be imported from "{2}"',
level: DiagnosticLevel.Error,
url: '',
},
IS_NOT_CLASS_PROPERTY_OR_CLASS_METHOD: {
code: 1103,
message: '"@{0}" can only be applied on class properties',
level: DiagnosticLevel.Error,
url: '',
},
IS_NOT_DECORATOR: {
code: 1104,
message: '"{0}" can only be used as a class decorator',
level: DiagnosticLevel.Error,
url: '',
},
ONE_WIRE_DECORATOR_ALLOWED: {
code: 1105,
message: 'Method or property can only have 1 @wire decorator',
level: DiagnosticLevel.Error,
url: 'https://lwc.dev/guide/error_codes#lwc1105',
},
PROPERTY_CANNOT_BE_COMPUTED: {
code: 1106,
message: '@api cannot be applied to a computed property, getter, setter or method.',
level: DiagnosticLevel.Error,
url: 'https://lwc.dev/guide/error_codes#lwc1106',
},
PROPERTY_NAME_CANNOT_START_WITH_DATA: {
code: 1107,
message:
'Invalid property name "{0}". Properties starting with "data" are reserved attributes.',
level: DiagnosticLevel.Error,
url: 'https://lwc.dev/guide/error_codes#lwc1107',
},
PROPERTY_NAME_CANNOT_START_WITH_ON: {
code: 1108,
message:
'Invalid property name "{0}". Properties starting with "on" are reserved for event handlers.',
level: DiagnosticLevel.Error,
url: 'https://lwc.dev/guide/error_codes#lwc1108',
},
PROPERTY_NAME_IS_AMBIGUOUS: {
code: 1109,
message:
'Ambiguous attribute name "{0}". "{0}" will never be called from template because its corresponding property is camel cased. Consider renaming to "{1}".',
level: DiagnosticLevel.Error,
url: 'https://lwc.dev/guide/error_codes#lwc1109',
},
PROPERTY_NAME_IS_RESERVED: {
code: 1110,
message: 'Invalid property name "{0}". "{0}" is a reserved attribute.',
level: DiagnosticLevel.Error,
url: 'https://lwc.dev/guide/error_codes#lwc1110',
},
PROPERTY_NAME_PART_IS_RESERVED: {
code: 1111,
message:
'Invalid property name "{0}". "part" is a future reserved attribute for web components.',
level: DiagnosticLevel.Error,
url: 'https://lwc.dev/guide/error_codes#lwc1111',
},
SINGLE_DECORATOR_ON_SETTER_GETTER_PAIR: {
code: 1112,
message:
'@api get {0} and @api set {0} detected in class declaration. Only one of the two needs to be decorated with @api.',
level: DiagnosticLevel.Error,
url: 'https://lwc.dev/guide/error_codes#lwc1112',
},
TRACK_ONLY_ALLOWED_ON_CLASS_PROPERTIES: {
code: 1113,
message: '@track decorator can only be applied to class properties.',
level: DiagnosticLevel.Error,
url: '',
},
WIRE_ADAPTER_SHOULD_BE_IMPORTED: {
code: 1119,
message: 'Failed to resolve @wire adapter "{0}". Ensure it is imported.',
level: DiagnosticLevel.Error,
url: '',
},
FUNCTION_IDENTIFIER_CANNOT_HAVE_COMPUTED_PROPS: {
code: 1131,
message: '@wire identifier cannot contain computed properties',
level: DiagnosticLevel.Error,
url: 'https://lwc.dev/guide/error_codes#lwc1131',
},
FUNCTION_IDENTIFIER_CANNOT_HAVE_NESTED_MEMBER_EXRESSIONS: {
code: 1132,
message: '@wire identifier cannot contain nested member expressions',
level: DiagnosticLevel.Error,
url: 'https://lwc.dev/guide/error_codes#lwc1132',
},
COMPUTED_PROPERTY_CANNOT_BE_TEMPLATE_LITERAL: {
code: 1199,
message:
'Cannot use a template literal as a computed property key. Instead, use a string or extract the value to a constant.',
level: DiagnosticLevel.Error,
url: 'https://lwc.dev/guide/error_codes#lwc1199',
},
COMPUTED_PROPERTY_MUST_BE_CONSTANT_OR_LITERAL: {
code: 1200,
message: 'Computed property in @wire config must be a constant or primitive literal.',
level: DiagnosticLevel.Error,
url: 'https://lwc.dev/guide/error_codes#lwc1200',
},
DECORATOR_ON_PRIVATE_METHOD: {
code: 1212,
message:
'Decorators cannot be applied to private methods. Private methods are not part of the component API.',
level: DiagnosticLevel.Error,
url: 'https://lwc.dev/guide/error_codes#lwc1212',
},
PRIVATE_METHOD_NAME_COLLISION: {
code: 1213,
message:
"Method '{0}' conflicts with internal naming conventions. Please rename this function to avoid conflict.",
level: DiagnosticLevel.Error,
url: 'https://lwc.dev/guide/error_codes#lwc1213',
},
} as const satisfies Record<string, LWCErrorInfo>;