Skip to content

Commit

Permalink
chore: enable noImplicitAny on new-package.js
Browse files Browse the repository at this point in the history
  • Loading branch information
lishaduck committed Nov 4, 2024
1 parent 3552ccd commit 98a0279
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
47 changes: 42 additions & 5 deletions lib/new-package.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/**
* @import {ElmJson} from './types/content';
* @import {ApplicationElmJson, PackageName} from './types/content';
* @import {Path} from './types/path';
* @import {Options, RuleType} from './types/options';
*/
const childProcess = require('node:child_process');
const path = require('node:path');
Expand All @@ -14,6 +16,9 @@ const MinVersion = require('./min-version');
const NewRule = require('./new-rule');
const Spinner = require('./spinner');

/**
* @param {Options} options
*/
async function create(options) {
const onCancelOptions = {
onCancel: () => {
Expand All @@ -25,7 +30,7 @@ async function create(options) {
let canceled = false;

const authorName =
options.prefilledAnswers.authorName ||
options.prefilledAnswers.authorName ??
(await prompts(
[
{
Expand All @@ -49,7 +54,7 @@ async function create(options) {
}

const license =
options.prefilledAnswers.license ||
options.prefilledAnswers.license ??
(await prompts(
[
{
Expand All @@ -73,7 +78,7 @@ async function create(options) {
return;
}

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

/**
* @param {string} packageName
*/
function validatePackageName(packageName) {
if (!packageName.startsWith('elm-review-')) {
throw new ErrorMessage.CustomError(
Expand Down Expand Up @@ -146,10 +154,24 @@ const elmToolingJson = {
}
};

/**
* @param {Path} dir
* @param {string} fileName
* @param {string} content
* @returns {Promise<void>}
*/
async function writeFile(dir, fileName, content) {
await FS.writeFile(path.join(dir, fileName), content);
}

/**
* @param {Options} options
* @param {string} authorName
* @param {PackageName} packageName
* @param {string} ruleName
* @param {RuleType} ruleType
* @param {string} license
*/
async function createProject(
options,
authorName,
Expand Down Expand Up @@ -196,7 +218,7 @@ async function createProject(

// Adding package to the example's elm.json
const previewElmJsonPath = path.join(pathToPreview, 'elm.json');
const previewElmJson = /** @type {ElmJson} */ (
const previewElmJson = /** @type {ApplicationElmJson} */ (
await FS.readJsonFile(previewElmJsonPath)
);
previewElmJson['source-directories'] = [
Expand Down Expand Up @@ -320,6 +342,12 @@ ElmjutsuDumMyM0DuL3.elm
Spinner.succeed();
}

/**
* @param {string} authorName
* @param {PackageName} packageName
* @param {string} ruleName
* @param {string} license
*/
function elmJson(authorName, packageName, ruleName, license) {
return {
type: 'package',
Expand All @@ -340,6 +368,11 @@ function elmJson(authorName, packageName, ruleName, license) {
};
}

/**
* @param {string} authorName
* @param {PackageName} packageName
* @param {string} ruleName
*/
function readme(authorName, packageName, ruleName) {
return `# ${packageName}
Expand Down Expand Up @@ -373,6 +406,10 @@ elm-review --template ${authorName}/${packageName}/example
`;
}

/**
* @param {Options} options
* @param {PackageName} packageName
*/
function packageJson(options, packageName) {
return {
name: packageName,
Expand Down
1 change: 1 addition & 0 deletions tsconfig.no-implicit-any.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"lib/init.js",
"lib/load-compiled-app.js",
"lib/min-version.js",
"lib/new-package.js",
"lib/new-rule.js",
"lib/npx.js",
"lib/optimize-js.js",
Expand Down

0 comments on commit 98a0279

Please sign in to comment.