@komaci/static-analyzer 242.3.2 → 242.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/RULES.md +102 -0
  2. package/build/rules.js +3 -3
  3. package/package.json +3 -3
package/RULES.md CHANGED
@@ -1251,3 +1251,105 @@ export default class Example extends LightningElement {
1251
1251
  }
1252
1252
  }
1253
1253
  ```
1254
+
1255
+ ## `komaci1039`: no-render-function-contains-more-than-return-statement
1256
+
1257
+ | Code | Description | Message | Severity |
1258
+ | ------------ | ------------------------------------------------------------- | -------------------------------------------------------------- | -------- |
1259
+ | `komaci1039` | Flags render functions that do more than just return a value. | Supported render functions can only contain a return statement | error |
1260
+
1261
+ ### ❌ Incorrect
1262
+
1263
+ ```js
1264
+ import { LightningElement } from 'lwc';
1265
+ import template from './tesTemplate.html';
1266
+ export default class Example extends LightningElement {
1267
+ render() {
1268
+ const val = 'val';
1269
+ return val ? template : undefined;
1270
+ }
1271
+ }
1272
+ ```
1273
+
1274
+ ### ✅ Correct
1275
+
1276
+ ```js
1277
+ import { LightningElement } from 'lwc';
1278
+ import template from './tesTemplate.html';
1279
+ export default class Example extends LightningElement {
1280
+ render() {
1281
+ return template;
1282
+ }
1283
+ }
1284
+ ```
1285
+
1286
+ ## `komaci1040`: no-render-function-return-statement
1287
+
1288
+ | Code | Description | Message | Severity |
1289
+ | ------------ | ------------------------------------------------------------ | ------------------------------------------------------------- | -------- |
1290
+ | `komaci1040` | Flags render functions that don't contain a return statement | Supported render functions need to contain a return statement | error |
1291
+
1292
+ ### ❌ Incorrect
1293
+
1294
+ ```js
1295
+ import { LightningElement } from 'lwc';
1296
+ export default class Example extends LightningElement {
1297
+ render() {
1298
+ const val = 'val';
1299
+ }
1300
+ }
1301
+ ```
1302
+
1303
+ ### ✅ Correct
1304
+
1305
+ ```js
1306
+ import { LightningElement } from 'lwc';
1307
+ import template from './tesTemplate.html';
1308
+ export default class Example extends LightningElement {
1309
+ render() {
1310
+ return template;
1311
+ }
1312
+ }
1313
+ ```
1314
+
1315
+ ## `komaci1041`: no-render-function-return-statement-not-returning-imported-template
1316
+
1317
+ | Code | Description | Message | Severity |
1318
+ | ------------ | --------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | -------- |
1319
+ | `komaci1041` | Flags render functions that attempt to return something that isn't an imported local template | Supported render functions can only return supported imported templates | error |
1320
+
1321
+ ### ❌ Incorrect
1322
+
1323
+ ```js
1324
+ import { LightningElement, api } from 'lwc';
1325
+ import template from 'lightning/something';
1326
+ export default class Example extends LightningElement {
1327
+ @api
1328
+ firstOrSecondTemplate;
1329
+
1330
+ @api
1331
+ passedInTemplate;
1332
+
1333
+ render() {
1334
+ return this.firstOrSecondTemplate
1335
+ ? this.passedInTemplate //not suported because it's passed through the prop
1336
+ : template; // not supported because it's imported from another module
1337
+ }
1338
+ }
1339
+ ```
1340
+
1341
+ ### ✅ Correct
1342
+
1343
+ ```js
1344
+ import { LightningElement, api } from 'lwc';
1345
+ import firstTemplate from './firstTemplate.html';
1346
+ import secondTemplate from './secondTemplate.html';
1347
+ export default class Example extends LightningElement {
1348
+ @api
1349
+ firstOrSecondTemplate;
1350
+
1351
+ render() {
1352
+ return this.firstOrSecondTemplate ? firstTemplate : secondTemplate;
1353
+ }
1354
+ }
1355
+ ```
package/build/rules.js CHANGED
@@ -193,19 +193,19 @@ exports.diagnosticMessages = {
193
193
  source: SOURCE_PREFIX_OFFLINE_CODE_ANALYZER,
194
194
  },
195
195
  NO_RENDER_FUNCTION_CONTAINS_MORE_THAN_RETURN_STATEMENT: {
196
- code: `${MESSAGE_CODE_PREFIX}1025`,
196
+ code: `${MESSAGE_CODE_PREFIX}1039`,
197
197
  severity: SEVERITY.ERROR,
198
198
  message: 'Supported render functions in custom components can only contain a return statement',
199
199
  source: SOURCE_PREFIX_OFFLINE_CODE_ANALYZER,
200
200
  },
201
201
  NO_RENDER_FUNCTION_RETURN_STATEMENT: {
202
- code: `${MESSAGE_CODE_PREFIX}1025`,
202
+ code: `${MESSAGE_CODE_PREFIX}1040`,
203
203
  severity: SEVERITY.ERROR,
204
204
  message: 'Supported render functions need to contain a return statement',
205
205
  source: SOURCE_PREFIX_OFFLINE_CODE_ANALYZER,
206
206
  },
207
207
  NO_RENDER_FUNCTION_RETURN_STATEMENT_NOT_RETURNING_IMPORTED_TEMPLATE: {
208
- code: `${MESSAGE_CODE_PREFIX}1025`,
208
+ code: `${MESSAGE_CODE_PREFIX}1041`,
209
209
  severity: SEVERITY.ERROR,
210
210
  message: 'Supported render functions can only return supported imported templates',
211
211
  source: SOURCE_PREFIX_OFFLINE_CODE_ANALYZER,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@komaci/static-analyzer",
3
- "version": "242.3.2",
3
+ "version": "242.3.4",
4
4
  "description": "Komaci Diagnostics API",
5
5
  "homepage": "https://komaci.dev/",
6
6
  "repository": {
@@ -29,10 +29,10 @@
29
29
  ],
30
30
  "dependencies": {
31
31
  "@babel/types": "^7.9.0",
32
- "@komaci/common-shared": "242.3.2"
32
+ "@komaci/common-shared": "242.3.4"
33
33
  },
34
34
  "devDependencies": {
35
- "@komaci/types": "242.3.2"
35
+ "@komaci/types": "242.3.4"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@lwc/metadata": "2.22.0-0",