Skip to content

Commit 6f8c18a

Browse files
authored
Update eslint configuration and adding comment to all functions which do not have them. (#1414)
- Update eslint to throw errors when functions don't have documentation. - Ignoring eslint missing comments for spa, generated-html and src-electron/generator/matter - Update comments on all the js functions - Add eslint to pre-commit hook - Adding api documentation update to pre-commit hook - Using npx jsdoc2md src-shared/**/*.js src-electron/**/*.js > docs/api.md for api.md update on each commit - Updating API documentation - Updating the modules for all files in src-shared and src-electron such that their documentation is generated properly using jsdoc2md - Adding 2 scripts to generate api documentation and helper documentation such that users can now have one place to know about every helper available. - The 2 scripts are called as part of the pre-commit hook and fails if documentation is not added for any function. - The documentation for api.md and helpers.md is updated as part of the commit using the pre-commit hook - Clean up all the associated files and functions such that jsdoc2md works efficiently - Ignoring src directory for eslint - Updating the README.md with the template helper documentation link - Adding vue files to the ignore list in eslint - JIRA: ZAPP-1143 - Adding comments for the one missing file
1 parent e26dcfe commit 6f8c18a

File tree

131 files changed

+28230
-14619
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+28230
-14619
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
/dist
22
src-script/download-artifact.js
3+
/spa
4+
/generated-html
5+
/src-electron/generator/matter

.eslintrc.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,26 @@ module.exports = {
6262

6363
// random rules added
6464
'no-undef': 'off',
65-
'no-unused-vars': 'off'
66-
}
65+
'no-unused-vars': 'off',
66+
'require-jsdoc': [
67+
'error',
68+
{
69+
require: {
70+
FunctionDeclaration: true,
71+
MethodDefinition: true,
72+
ClassDeclaration: false,
73+
ArrowFunctionExpression: false,
74+
FunctionExpression: false
75+
}
76+
}
77+
]
78+
},
79+
overrides: [
80+
{
81+
files: ['test/**/*.js', 'src/**/*.vue'], // Path to the directory you want to ignore
82+
rules: {
83+
'require-jsdoc': 'off' // Disable the require-jsdoc rule for this directory
84+
}
85+
}
86+
]
6787
}

.husky/pre-commit

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ echo "🚀 > Pretty quick reformat..."
55
npx pretty-quick --staged
66

77
echo "🚀 > JSdoc regen..."
8-
npx jsdoc src-electron src-shared -r -d ./generated-html/
8+
node src-script/generate-all-api-docs.js
9+
node src-script/generate-template-helper-docs.js
10+
git add docs/api.md
11+
git add docs/helpers.md
912

1013
echo "🚀 > Eslint..."
11-
npx eslint --ext .js,.vue src src-electron src-shared src-script test
14+
npx eslint .
1215

1316
echo "🚀 > Reset version in package.json to 0.0.0..."
1417
src-script/zap-update-package-version.js -fake

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ This software is licensed under [Apache 2.0 license](LICENSE.txt).
3737

3838
## Detailed Developer Documentation
3939

40+
- [ZAP Template Helpers](docs/helpers.md)
4041
- [FAQ/Developer dependencies](docs/faq.md)
4142
- [Release instructions](docs/release.md)
4243
- [Development Instructions](docs/development-instructions.md)

docs/api.md

Lines changed: 20116 additions & 14456 deletions
Large diffs are not rendered by default.

docs/helpers.md

Lines changed: 4692 additions & 0 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
"build-spa": "node src-script/build-spa.js",
5252
"build-backend": "node src-script/build-backend.js",
5353
"doc": "jsdoc src-electron src-shared -r -u docs -d ./generated-html/ README.md",
54-
"apidoc": "jsdoc2md src-shared/**/*.js src-electron/**/*.js > docs/api.md",
54+
"api-doc": "node src-script/generate-all-api-docs.js",
55+
"helper-doc": "node src-script/generate-template-helper-docs.js",
5556
"format-code": "pretty-quick",
5657
"pretty-quick": "pretty-quick",
5758
"version-stamp": "node src-script/zap-versionstamp.js",
@@ -213,7 +214,7 @@
213214
],
214215
"husky": {
215216
"hooks": {
216-
"pre-commit": "pretty-quick --staged && jsdoc src-electron src-shared -r -d ./generated-html/ && eslint --ext .js,.vue src src-electron src-shared src-script test"
217+
"pre-commit": "pretty-quick --staged && jsdoc src-electron src-shared -r -d ./generated-html/ && eslint ."
217218
}
218219
},
219220
"build": {

src-electron/client/ipc-client.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
* limitations under the License.
1616
*/
1717

18+
/**
19+
* This module provides IPC Client functionality.
20+
*
21+
* @module IPC Client API: Inter-process communication
22+
*/
23+
1824
const env = require('../util/env')
1925
const ipcServer = require('../server/ipc-server')
2026
const util = require('../util/util.js')
@@ -28,6 +34,10 @@ const client = {
2834

2935
let lastPong = ''
3036

37+
/**
38+
* Log ipc client message
39+
* @param {*} msg
40+
*/
3141
function log(msg) {
3242
env.logIpc(`Ipc client: ${msg}`)
3343
}

src-electron/db/db-api.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ const dbMapping = require('./db-mapping.js')
3838
//
3939
let inTransaction = false
4040

41+
/**
42+
* Begin Database transaction.
43+
* @param {*} db
44+
* @param {*} resolve
45+
* @param {*} reject
46+
*/
4147
function executeBeginTransaction(db, resolve, reject) {
4248
db.run('BEGIN TRANSACTION', [], function (err) {
4349
if (err) {
@@ -50,6 +56,12 @@ function executeBeginTransaction(db, resolve, reject) {
5056
})
5157
}
5258

59+
/**
60+
* Delay database transaction.
61+
* @param {*} db
62+
* @param {*} resolve
63+
* @param {*} reject
64+
*/
5365
function delayBeginTransaction(db, resolve, reject) {
5466
let cnt = 0
5567
let interval = setInterval(() => {
@@ -485,6 +497,13 @@ async function determineIfSchemaShouldLoad(db, filePath, crc) {
485497
return result
486498
}
487499

500+
/**
501+
* Update the CRC of the sql schema file.
502+
* @param {*} db
503+
* @param {*} filePath
504+
* @param {*} crc
505+
* @returns promise of insert transaction.
506+
*/
488507
async function updateCurrentSchemaCrc(db, filePath, crc) {
489508
return dbInsert(
490509
db,
@@ -493,6 +512,12 @@ async function updateCurrentSchemaCrc(db, filePath, crc) {
493512
)
494513
}
495514

515+
/**
516+
* Load SQL Schema
517+
* @param {*} db
518+
* @param {*} schemaContent
519+
* @returns Promise of loaded schema
520+
*/
496521
async function performSchemaLoad(db, schemaContent) {
497522
return new Promise((resolve, reject) => {
498523
env.logSql('Loading schema.')

src-electron/db/query-access.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
const dbApi = require('./db-api.js')
2424
const dbMapping = require('./db-mapping.js')
2525

26+
/**
27+
* Get access operations for package IDs given.
28+
* @param {*} db
29+
* @param {*} packageIds
30+
* @returns promise of access operation.
31+
*/
2632
async function selectAccessOperations(db, packageIds) {
2733
return dbApi
2834
.dbAll(
@@ -36,6 +42,12 @@ SELECT NAME, DESCRIPTION FROM OPERATION WHERE PACKAGE_REF IN (${dbApi.toInClause
3642
.then((rows) => rows.map(dbMapping.map.accessOperation))
3743
}
3844

45+
/**
46+
* Get access roles for package IDs given.
47+
* @param {*} db
48+
* @param {*} packageIds
49+
* @returns promise of access roles.
50+
*/
3951
async function selectAccessRoles(db, packageIds) {
4052
return dbApi
4153
.dbAll(
@@ -49,6 +61,12 @@ SELECT NAME, DESCRIPTION, LEVEL FROM ROLE WHERE PACKAGE_REF IN (${dbApi.toInClau
4961
.then((rows) => rows.map(dbMapping.map.accessRole))
5062
}
5163

64+
/**
65+
* Get access modifiers for package IDs given.
66+
* @param {*} db
67+
* @param {*} packageIds
68+
* @returns promise of access modifiers.
69+
*/
5270
async function selectAccessModifiers(db, packageIds) {
5371
return dbApi
5472
.dbAll(
@@ -99,6 +117,12 @@ ORDER BY OPERATION.NAME, ROLE.NAME, ACCESS_MODIFIER.NAME
99117
.then((rows) => rows.map(dbMapping.map.access))
100118
}
101119

120+
/**
121+
* Get attribute access information for the attribute id given.
122+
* @param {*} db
123+
* @param {*} attributeId
124+
* @returns Promise of attribute access information
125+
*/
102126
async function selectAttributeAccess(db, attributeId) {
103127
return dbApi
104128
.dbAll(
@@ -128,6 +152,12 @@ ORDER BY OPERATION.NAME, ROLE.NAME, ACCESS_MODIFIER.NAME
128152
.then((rows) => rows.map(dbMapping.map.access))
129153
}
130154

155+
/**
156+
* Get command access information for the attribute id given.
157+
* @param {*} db
158+
* @param {*} commandId
159+
* @returns Promise of command access information
160+
*/
131161
async function selectCommandAccess(db, commandId) {
132162
return dbApi
133163
.dbAll(
@@ -157,6 +187,12 @@ ORDER BY OPERATION.NAME, ROLE.NAME, ACCESS_MODIFIER.NAME
157187
.then((rows) => rows.map(dbMapping.map.access))
158188
}
159189

190+
/**
191+
* Get event access information for the attribute id given.
192+
* @param {*} db
193+
* @param {*} eventId
194+
* @returns Promise of event access information
195+
*/
160196
async function selectEventAccess(db, eventId) {
161197
return dbApi
162198
.dbAll(

0 commit comments

Comments
 (0)