1- /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
21import { pipe , flow } from "fp-ts/lib/function" ;
32import {
43 JiraClient ,
@@ -22,27 +21,31 @@ import clc from "cli-color";
2221 * Dynamic type for global arguments. This needs to be its own as we use a
2322 * require below to import all the commands
2423 */
24+ // eslint-disable-next-line functional/type-declaration-immutability
2525export type RootCommand = typeof rootCommand ;
2626
2727/**
2828 * Add global arguments here using the .option function.
2929 * E.g. const rootCommand = yargs.option('example', {type: 'string'});
3030 */
31+ // eslint-disable-next-line functional/prefer-immutable-types
3132const rootCommand = yargs ;
3233
33- const CliConfig = T . type ( {
34- jiraProtocol : T . union ( [ T . string , T . undefined ] ) ,
35- jiraHost : T . union ( [ T . string , T . undefined ] ) ,
36- qualityFieldName : T . union ( [ T . string , T . undefined ] ) ,
37- qualityReasonFieldName : T . union ( [ T . string , T . undefined ] ) ,
38- personalAccessToken : T . union ( [ T . string , T . undefined ] ) ,
39- jiraConsumerKey : T . union ( [ T . string , T . undefined ] ) ,
40- jiraConsumerSecret : T . union ( [ T . string , T . undefined ] ) ,
41- accessToken : T . union ( [ T . string , T . undefined ] ) ,
42- accessSecret : T . union ( [ T . string , T . undefined ] ) ,
43- username : T . union ( [ T . string , T . undefined ] ) ,
44- password : T . union ( [ T . string , T . undefined ] ) ,
45- } ) ;
34+ const CliConfig = T . readonly (
35+ T . type ( {
36+ jiraProtocol : T . union ( [ T . string , T . undefined ] ) ,
37+ jiraHost : T . union ( [ T . string , T . undefined ] ) ,
38+ qualityFieldName : T . union ( [ T . string , T . undefined ] ) ,
39+ qualityReasonFieldName : T . union ( [ T . string , T . undefined ] ) ,
40+ personalAccessToken : T . union ( [ T . string , T . undefined ] ) ,
41+ jiraConsumerKey : T . union ( [ T . string , T . undefined ] ) ,
42+ jiraConsumerSecret : T . union ( [ T . string , T . undefined ] ) ,
43+ accessToken : T . union ( [ T . string , T . undefined ] ) ,
44+ accessSecret : T . union ( [ T . string , T . undefined ] ) ,
45+ username : T . union ( [ T . string , T . undefined ] ) ,
46+ password : T . union ( [ T . string , T . undefined ] ) ,
47+ } )
48+ ) ;
4649type CliConfig = T . TypeOf < typeof CliConfig > ;
4750
4851const currentDirectory = process . cwd ( ) ;
@@ -89,7 +92,6 @@ const configIfExists = (dir: string): CliConfig | undefined => {
8992 E . chain ( decodeJson ( jiralintConfigFileName , CliConfig . decode ) ) ,
9093 E . fold (
9194 ( error ) => {
92- // eslint-disable-next-line functional/no-expression-statement
9395 console . error (
9496 `\n${ clc . red . bold (
9597 jiralintConfigFileName
@@ -136,7 +138,7 @@ type JiraParameters = {
136138
137139type JiraClientBuilder = JiraParameters & {
138140 readonly missingParameters : readonly PropertyKey [ ] ;
139- readonly client ?: JiraClient ;
141+ readonly client ?: Readonly < JiraClient > ;
140142} ;
141143
142144/**
@@ -282,7 +284,7 @@ const verifyClient = (builder: JiraClientBuilder): JiraClient =>
282284 ? ( ( ) => {
283285 // we throw an error here as it's the only way to communicate these
284286 // errors with yargs at this point.
285- // eslint-disable-next-line functional/no-throw-statement
287+ // eslint-disable-next-line functional/no-throw-statements
286288 throw new Error (
287289 `Missing required argument${
288290 builder . missingParameters . length === 1 ? ":" : "s:\n"
@@ -296,6 +298,7 @@ const verifyClient = (builder: JiraClientBuilder): JiraClient =>
296298 */
297299const config : CliConfig | undefined = findConfig ( process . cwd ( ) ) ;
298300
301+ // eslint-disable-next-line functional/prefer-immutable-types
299302export const withCommonOptions = < C extends RootCommand > ( command : C ) =>
300303 command
301304 . option ( jiraProtocolOptionKey , {
@@ -326,11 +329,13 @@ export const withCommonOptions = <C extends RootCommand>(command: C) =>
326329 } )
327330 . group ( [ jiraHostOptionKey , jiraProtocolOptionKey ] , "Common Required:" ) ;
328331
332+ // eslint-disable-next-line functional/prefer-immutable-types
329333export const withAuthenticationOptions = < C extends RootCommand > ( command : C ) =>
330334 withCommonOptions ( command )
331335 . group ( [ jiraConsumerKeyOptionKey , jiraConsumerSecretOptionKey ] , "Auth:" )
332336 . demandOption ( [ jiraHostOptionKey , jiraConsumerSecretOptionKey ] ) ;
333337
338+ // eslint-disable-next-line functional/prefer-immutable-types
334339export const withAuthOptions = < C extends RootCommand > ( command : C ) =>
335340 withCommonOptions ( command )
336341 . option ( jiraAccessTokenOptionKey , {
@@ -402,6 +407,7 @@ export const withAuthOptions = <C extends RootCommand>(command: C) =>
402407 )
403408 . demandOption ( "jira" ) ;
404409
410+ // eslint-disable-next-line functional/prefer-immutable-types
405411export const withQualityFieldsOption = < C extends RootCommand > ( command : C ) =>
406412 withAuthOptions ( command )
407413 . option ( "qualityFieldName" , {
@@ -417,11 +423,11 @@ export const withQualityFieldsOption = <C extends RootCommand>(command: C) =>
417423 } )
418424 . demandOption ( [ "qualityFieldName" , "qualityReasonFieldName" ] ) ;
419425
420- /* eslint-disable functional/no-expression-statement */
426+ /* eslint-disable functional/no-expression-statements */
421427auth ( rootCommand ) ;
422428rate ( rootCommand ) ;
423429search ( rootCommand ) ;
424430
425431// eslint-disable-next-line @typescript-eslint/no-floating-promises
426432rootCommand . demandCommand ( ) . strict ( ) . help ( ) . argv ;
427- /* eslint-enable functional/no-expression-statement */
433+ /* eslint-enable functional/no-expression-statements */
0 commit comments