Skip to content

Commit

Permalink
start for docblock check
Browse files Browse the repository at this point in the history
  • Loading branch information
kalisjoshua committed Nov 18, 2024
1 parent 831d752 commit c96f37d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"indexer": "turbo index",
"license": "pnpm zx scripts/license.mjs",
"lint": "turbo lint",
"postlint": "pnpm zx scripts/docblock.mjs",
"lint:fs": "pnpm ls-lint",
"test": "turbo test"
},
Expand All @@ -34,6 +35,7 @@
"@biomejs/biome": "^1.9.3",
"@changesets/changelog-git": "^0.2.0",
"@changesets/cli": "^2.27.9",
"comment-parser": "^1.4.1",
"@ls-lint/ls-lint": "2.3.0-beta.1",
"@swc/core": "^1.7.36",
"rimraf": "^5.0.10",
Expand Down
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions scripts/docblock.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env zx

/*
* Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/

import { parse } from 'comment-parser';
import { fs, glob } from 'zx';

const filesMissingDocblock = (
await glob(['**/*.{js,ts,tsx,mjs}'], {
ignore: [
'**/.github/**',
'**/__fixtures__/**',
'**/__mock__/**',
'**/coverage/**',
'**/dist/**',
'**/node_modules/**',
],
})
).filter(
(file) =>
/** Count files that do not have a docblock. */
!parse(fs.readFileSync(file, 'utf8')).length,
);

if (filesMissingDocblock.length) {
console.error(
`${filesMissingDocblock.length} files missing a docblock:`,
JSON.stringify(filesMissingDocblock, null, 4),
);

// TODO: enable error-ing once all file are complying
// process.exit(1);
}

0 comments on commit c96f37d

Please sign in to comment.