Skip to content

Commit c8c9e87

Browse files
committed
chore: enable noImplicitAny on new-package.js
1 parent fcbb6cf commit c8c9e87

File tree

2 files changed

+43
-5
lines changed

2 files changed

+43
-5
lines changed

lib/new-package.js

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/**
2-
* @import {ElmJson} from './types/content';
2+
* @import {ApplicationElmJson, PackageName} from './types/content';
3+
* @import {Path} from './types/path';
4+
* @import {Options, RuleType} from './types/options';
35
*/
46
const childProcess = require('node:child_process');
57
const path = require('node:path');
@@ -14,6 +16,9 @@ const MinVersion = require('./min-version');
1416
const NewRule = require('./new-rule');
1517
const Spinner = require('./spinner');
1618

19+
/**
20+
* @param {Options} options
21+
*/
1722
async function create(options) {
1823
const onCancelOptions = {
1924
onCancel: () => {
@@ -25,7 +30,7 @@ async function create(options) {
2530
let canceled = false;
2631

2732
const authorName =
28-
options.prefilledAnswers.authorName ||
33+
options.prefilledAnswers.authorName ??
2934
(await prompts(
3035
[
3136
{
@@ -49,7 +54,7 @@ async function create(options) {
4954
}
5055

5156
const license =
52-
options.prefilledAnswers.license ||
57+
options.prefilledAnswers.license ??
5358
(await prompts(
5459
[
5560
{
@@ -73,7 +78,7 @@ async function create(options) {
7378
return;
7479
}
7580

76-
const ruleType = options.ruleType || (await NewRule.askForRuleType());
81+
const ruleType = options.ruleType ?? (await NewRule.askForRuleType());
7782
if (!ruleType) {
7883
return;
7984
}
@@ -98,6 +103,9 @@ I hope you'll enjoy working with ${chalk.greenBright('elm-review')}! ❤️
98103
);
99104
}
100105

106+
/**
107+
* @param {string} packageName
108+
*/
101109
function validatePackageName(packageName) {
102110
if (!packageName.startsWith('elm-review-')) {
103111
throw new ErrorMessage.CustomError(
@@ -146,10 +154,24 @@ const elmToolingJson = {
146154
}
147155
};
148156

157+
/**
158+
* @param {Path} dir
159+
* @param {string} fileName
160+
* @param {string} content
161+
* @returns {Promise<void>}
162+
*/
149163
async function writeFile(dir, fileName, content) {
150164
await FS.writeFile(path.join(dir, fileName), content);
151165
}
152166

167+
/**
168+
* @param {Options} options
169+
* @param {string} authorName
170+
* @param {PackageName} packageName
171+
* @param {string} ruleName
172+
* @param {RuleType} ruleType
173+
* @param {string} license
174+
*/
153175
async function createProject(
154176
options,
155177
authorName,
@@ -196,7 +218,7 @@ async function createProject(
196218

197219
// Adding package to the example's elm.json
198220
const previewElmJsonPath = path.join(pathToPreview, 'elm.json');
199-
const previewElmJson = /** @type {ElmJson} */ (
221+
const previewElmJson = /** @type {ApplicationElmJson} */ (
200222
await FS.readJsonFile(previewElmJsonPath)
201223
);
202224
previewElmJson['source-directories'] = [
@@ -320,6 +342,12 @@ ElmjutsuDumMyM0DuL3.elm
320342
Spinner.succeed();
321343
}
322344

345+
/**
346+
* @param {string} authorName
347+
* @param {PackageName} packageName
348+
* @param {string} ruleName
349+
* @param {string} license
350+
*/
323351
function elmJson(authorName, packageName, ruleName, license) {
324352
return {
325353
type: 'package',
@@ -340,6 +368,11 @@ function elmJson(authorName, packageName, ruleName, license) {
340368
};
341369
}
342370

371+
/**
372+
* @param {string} authorName
373+
* @param {PackageName} packageName
374+
* @param {string} ruleName
375+
*/
343376
function readme(authorName, packageName, ruleName) {
344377
return `# ${packageName}
345378
@@ -373,6 +406,10 @@ elm-review --template ${authorName}/${packageName}/example
373406
`;
374407
}
375408

409+
/**
410+
* @param {Options} options
411+
* @param {PackageName} packageName
412+
*/
376413
function packageJson(options, packageName) {
377414
return {
378415
name: packageName,

tsconfig.no-implicit-any.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"lib/init.js",
2828
"lib/load-compiled-app.js",
2929
"lib/min-version.js",
30+
"lib/new-package.js",
3031
"lib/new-rule.js",
3132
"lib/npx.js",
3233
"lib/optimize-js.js",

0 commit comments

Comments
 (0)