Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
feat: adding jsdoc TS type checking approach
Browse files Browse the repository at this point in the history
  • Loading branch information
helio-frota committed Dec 6, 2021
1 parent 505e3cc commit 2a0d4a6
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 8 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/nodejs-ci-action.yml
Expand Up @@ -25,8 +25,10 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
- name: Checking JS types
run: npm run check
continue-on-error: true
- run: npm test
- run: npm run coverage
- name: Coveralls Parallel
uses: coverallsapp/github-action@master
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,4 +1,5 @@
/node_modules
license.html
coverage
*.log
*.log
generated_types
10 changes: 10 additions & 0 deletions lib/utils/checker.js
@@ -1,11 +1,21 @@
'use strict';

// @ts-check

// @ts-ignore
const licenseChecker = require('license-checker');

/**
* Grabs all the licenses information from dependencies.
* @param {string} cwd Current working directory.
* @param {boolean} productionOnly true to avoid devDependencies.
* @returns {object} License information about dependencies.
*/
const check = (cwd, productionOnly) => {
return new Promise((resolve, reject) => {
licenseChecker.init(
{ start: cwd, production: productionOnly },
// @ts-ignore
(error, json) => {
if (error) {
reject(error);
Expand Down
6 changes: 6 additions & 0 deletions lib/utils/project.js
@@ -1,5 +1,11 @@
'use strict';

/**
* Returns project name pointed by the current working
* directory.
* @param {string} cwd The current working directory.
* @returns {string} name The project name.
*/
const name = (cwd) => require(`${cwd}/package.json`).name;
const version = (cwd) => require(`${cwd}/package.json`).version;
const license = (cwd) => require(`${cwd}/package.json`).license;
Expand Down
1 change: 1 addition & 0 deletions lib/utils/unified-list.js
Expand Up @@ -3,6 +3,7 @@
const fileReader = require('./file-reader');
const messages = require('./messages');

/** @type { Object } */
let unifiedList;

const foundInList = (license, listItem) => {
Expand Down
156 changes: 153 additions & 3 deletions package-lock.json

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

8 changes: 6 additions & 2 deletions package.json
Expand Up @@ -9,7 +9,8 @@
"watch-test": "jest --watch",
"coverage": "jest --coverage",
"prepare": "husky install",
"release": "standard-version"
"release": "standard-version",
"check": "tsc --noEmit true"
},
"files": [
"bin",
Expand All @@ -35,6 +36,7 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@types/node": "^16.11.11",
"eslint": "^7.32.0",
"eslint-config-semistandard": "^16.0.0",
"eslint-config-standard": "^16.0.3",
Expand All @@ -43,9 +45,11 @@
"eslint-plugin-promise": "^5.1.0",
"husky": "^7.0.1",
"jest": "^27.0.6",
"jsdoc": "^3.6.7",
"proxyquire": "^2.1.3",
"rewire": "^5.0.0",
"standard-version": "^9.3.1"
"standard-version": "^9.3.1",
"typescript": "^4.5.2"
},
"preferGlobal": true,
"bin": {
Expand Down
9 changes: 9 additions & 0 deletions tsconfig.json
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"allowJs": true,
"strict": true,
"checkJs": true,
},
"include": ["**.js"],
"exclude": ["node_modules"]
}

0 comments on commit 2a0d4a6

Please sign in to comment.