diff --git a/lib/config.js b/lib/config.js index a3912cc0..33b96ee2 100644 --- a/lib/config.js +++ b/lib/config.js @@ -194,6 +194,7 @@ const getFullConfig = async ({ __NAME__: NAME, __CONFIG_KEY__: CONFIG_KEY, __VERSION__: LATEST_VERSION, + jsdoc: pkgConfig.jsdoc, } if (!pkgConfig.eslint && Array.isArray(pkgConfig.requiredPackages?.devDependencies)) { @@ -240,6 +241,16 @@ const getFullConfig = async ({ ]) } + if (pkgConfig.jsdoc) { + defaultsDeep(pkgConfig, { requiredPackages: { devDependencies: [] } }) + pkgConfig.requiredPackages.devDependencies = uniq([ + ...pkgConfig.requiredPackages.devDependencies, + 'typescript', + '@typescript-eslint/parser', + '@types/node' + ]) + } + const gitUrl = await git.getUrl(rootPkg.path) if (gitUrl) { derived.repository = { diff --git a/lib/content/eslintrc-js.hbs b/lib/content/eslintrc-js.hbs index c01ead8e..0d9c67ed 100644 --- a/lib/content/eslintrc-js.hbs +++ b/lib/content/eslintrc-js.hbs @@ -21,6 +21,9 @@ module.exports = { }, }, {{/if}} + {{#if jsdoc}} + parser: '@typescript-eslint/parser', + {{/if}} extends: [ '@npmcli', ...localConfigs, diff --git a/lib/content/index.js b/lib/content/index.js index 4100bb7b..f2101652 100644 --- a/lib/content/index.js +++ b/lib/content/index.js @@ -28,7 +28,7 @@ const sharedRootAdd = name => ({ }, 'tsconfig.json': { file: 'tsconfig-json.hbs', - filter: p => p.config.typescript, + filter: p => p.config.typescript || p.config.jsdoc, parser: p => p.JsonMergeNoComment, }, // this lint commits which is only necessary for releases diff --git a/lib/content/tsconfig-json.hbs b/lib/content/tsconfig-json.hbs index 42776f85..ca6a25c3 100644 --- a/lib/content/tsconfig-json.hbs +++ b/lib/content/tsconfig-json.hbs @@ -1,3 +1,22 @@ +{{#if jsdoc}} +{ + "compilerOptions": { + "target": "ES2022", + "module": "node16", + "allowJs": true, + "checkJs": true, + "declaration": true, + "emitDeclarationOnly": true, + "strict": true, + "moduleResolution": "node16", + "esModuleInterop": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "types": ["node"] + }, + "include": ["lib/**/*.js", "lib/**/*.ts"] +} +{{else}} { "compilerOptions": { "jsx": "react", @@ -15,3 +34,4 @@ "module": "nodenext" } } +{{/if}}