Skip to content

Commit e4453df

Browse files
authored
Merge pull request #254 from agiledigital/update-linting-redux
Update dependencies, linting, readonlyness
2 parents aa5ca3f + b8c7bad commit e4453df

26 files changed

+17411
-20960
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![CI Status](https://github.com/agiledigital/jiralint/actions/workflows/build-test-release.yml/badge.svg)
44

5-
Contains simple issue checks that can be applied to individual issues and a bare-bones CLI tool for applying them.
5+
Contains issue checks that can be applied to individual issues and a bare-bones CLI tool for applying them.
66

77
## Build
88

cli/.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ module.exports = {
2020
"total-functions",
2121
],
2222
rules: {
23-
"functional/no-return-void": "warn",
2423
// https://github.com/aotaduy/eslint-plugin-spellcheck
2524
"spellcheck/spell-checker": [
2625
"warn",

cli/package.json

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,45 +19,46 @@
1919
"clear": "0.1.0",
2020
"clui": "0.3.6",
2121
"colors": "1.4.0",
22-
"date-fns": "2.29.2",
23-
"fp-ts": "2.12.3",
22+
"date-fns": "2.29.3",
23+
"fp-ts": "2.13.1",
2424
"inquirer": "8.2.4",
25-
"io-ts": "2.2.18",
26-
"io-ts-types": "0.5.16",
25+
"io-ts": "2.2.20",
26+
"io-ts-types": "0.5.19",
2727
"monocle-ts": "2.3.13",
2828
"newtype-ts": "0.3.5",
2929
"oauth": "0.10.0",
30-
"readonly-types": "3.0.0",
30+
"readonly-types": "4.5.0",
3131
"string-length": "4.0.2",
32-
"ts-pattern": "3.3.5",
32+
"ts-pattern": "4.2.1",
3333
"yargs": "17.5.1"
3434
},
3535
"devDependencies": {
3636
"@types/clear": "0.1.2",
3737
"@types/clui": "0.3.1",
3838
"@types/inquirer": "7.3.3",
39-
"@types/jest": "29.0.0",
39+
"@types/jest": "29.4.0",
4040
"@types/oauth": "0.9.1",
41-
"@typescript-eslint/eslint-plugin": "5.36.1",
42-
"@typescript-eslint/parser": "5.36.1",
43-
"eslint": "8.23.0",
44-
"eslint-config-prettier": "8.5.0",
45-
"eslint-config-typed-fp": "3.3.0",
46-
"eslint-plugin-functional": "4.2.2",
47-
"eslint-plugin-jest": "27.0.1",
41+
"@typescript-eslint/eslint-plugin": "5.54.1",
42+
"@typescript-eslint/parser": "5.54.1",
43+
"eslint": "8.35.0",
44+
"eslint-config-agile-digital": "^2.6.0",
45+
"eslint-config-prettier": "8.7.0",
46+
"eslint-config-typed-fp": "4.4.0",
47+
"eslint-plugin-functional": "5.0.5",
48+
"eslint-plugin-jest": "27.2.1",
4849
"eslint-plugin-prettier": "4.2.1",
49-
"eslint-plugin-sonarjs": "0.15.0",
50-
"eslint-plugin-total-functions": "6.0.0",
51-
"jest": "28.1.3",
52-
"prettier": "2.7.1",
50+
"eslint-plugin-sonarjs": "0.18.0",
51+
"eslint-plugin-total-functions": "6.3.0",
52+
"jest": "29.5.0",
53+
"prettier": "2.8.4",
5354
"rollup": "2.79.0",
5455
"rollup-plugin-cleanup": "3.2.1",
5556
"rollup-plugin-delete": "2.0.0",
5657
"rollup-plugin-typescript2": "0.33.0",
57-
"ts-jest": "28.0.8",
58+
"ts-jest": "29.0.5",
5859
"tsconfig-paths-webpack-plugin": "4.0.0",
59-
"type-coverage": "2.22.0",
60-
"typescript": "4.8.2"
60+
"type-coverage": "2.24.1",
61+
"typescript": "4.9.5"
6162
},
6263
"typeCoverage": {
6364
"atLeast": 100,

cli/src/index.ts

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
21
import { pipe, flow } from "fp-ts/lib/function";
32
import {
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
2525
export 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
3132
const 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+
);
4649
type CliConfig = T.TypeOf<typeof CliConfig>;
4750

4851
const 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

137139
type 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
*/
297299
const config: CliConfig | undefined = findConfig(process.cwd());
298300

301+
// eslint-disable-next-line functional/prefer-immutable-types
299302
export 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
329333
export 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
334339
export 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
405411
export 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 */
421427
auth(rootCommand);
422428
rate(rootCommand);
423429
search(rootCommand);
424430

425431
// eslint-disable-next-line @typescript-eslint/no-floating-promises
426432
rootCommand.demandCommand().strict().help().argv;
427-
/* eslint-enable functional/no-expression-statement */
433+
/* eslint-enable functional/no-expression-statements */

cli/src/scripts/auth.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ const auth = async (
2727
return secret;
2828
}
2929
);
30-
// eslint-disable-next-line functional/no-expression-statement
30+
// eslint-disable-next-line no-console
3131
console.log(`Access token: ${accessToken}`);
32-
// eslint-disable-next-line functional/no-expression-statement
32+
// eslint-disable-next-line no-console
3333
console.log(`Access secret: ${accessSecret}`);
3434

3535
const jiraClient = jiraClientWithOAuth(
@@ -43,24 +43,23 @@ const auth = async (
4343

4444
const user = await jiraClient.currentUser();
4545

46-
// eslint-disable-next-line functional/no-expression-statement
4746
isLeft(user)
4847
? console.error(`Failed to get current user after auth [${user.left}]`)
4948
: console.info(JSON.stringify(user.right, null, 2));
5049
};
5150

52-
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
51+
// eslint-disable-next-line functional/prefer-immutable-types
5352
export default ({ command }: RootCommand): Argv<unknown> =>
5453
command(
5554
"auth",
5655
// eslint-disable-next-line spellcheck/spell-checker
5756
"authorises the linter to call Jira APIs and outputs the access token and secret",
58-
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
57+
// eslint-disable-next-line functional/prefer-immutable-types
5958
(yargs) => withAuthenticationOptions(yargs),
60-
// eslint-disable-next-line functional/no-return-void, @typescript-eslint/prefer-readonly-parameter-types
59+
// eslint-disable-next-line functional/no-return-void, functional/prefer-immutable-types
6160
(args) => {
6261
const protocol = args["jira.protocol"];
63-
// eslint-disable-next-line functional/no-expression-statement
62+
// eslint-disable-next-line functional/no-expression-statements
6463
void auth(
6564
// yargs ensures that this is always 'http' or 'https'
6665
protocol === "http" || protocol === "https" ? protocol : "https",

cli/src/scripts/rate.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Argv } from "yargs";
33
import { RootCommand, withQualityFieldsOption } from "..";
44

55
const rate = async (
6-
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
76
jira: JiraClient,
87
key: string,
98
quality: string,
@@ -19,16 +18,16 @@ const rate = async (
1918
reasonFieldName
2019
);
2120

22-
// eslint-disable-next-line functional/no-expression-statement
21+
// eslint-disable-next-line no-console
2322
console.log(`Updated [${JSON.stringify(update, null, 2)}]`);
2423
};
2524

26-
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
25+
// eslint-disable-next-line functional/prefer-immutable-types
2726
export default ({ command }: RootCommand): Argv<unknown> =>
2827
command(
2928
"rate",
3029
"records the quality of a jira issue",
31-
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
30+
// eslint-disable-next-line functional/prefer-immutable-types
3231
(yargs) =>
3332
withQualityFieldsOption(yargs)
3433
.option("key", {
@@ -46,9 +45,9 @@ export default ({ command }: RootCommand): Argv<unknown> =>
4645
describe: "reason for assessment",
4746
})
4847
.demandOption(["key", "quality", "reason"]),
49-
// eslint-disable-next-line functional/no-return-void, @typescript-eslint/prefer-readonly-parameter-types
48+
// eslint-disable-next-line functional/prefer-immutable-types, functional/no-return-void
5049
(args) => {
51-
// eslint-disable-next-line functional/no-expression-statement
50+
// eslint-disable-next-line functional/no-expression-statements
5251
void rate(
5352
args.jira,
5453
args.key,

0 commit comments

Comments
 (0)