Skip to content

Commit 39501b3

Browse files
refactor: refactor the code base and update linting rules
1 parent ea28256 commit 39501b3

32 files changed

+1391
-922
lines changed

.eslintrc.json

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"@typescript-eslint/no-unsafe-member-access": "off",
4040
"@typescript-eslint/no-unsafe-return": "off",
4141
"import/no-relative-parent-imports": "error",
42+
"functional/prefer-readonly-type": "off",
4243
"node/no-unsupported-features/es-builtins": "off",
4344
"node/no-unsupported-features/es-syntax": "off",
4445
"promise/prefer-await-to-callbacks": "off",
@@ -57,7 +58,37 @@
5758
{
5859
"files": ["./src/**/*"],
5960
"extends": ["plugin:eslint-plugin/recommended"],
60-
"rules": {}
61+
"rules": {
62+
"functional/no-expression-statement": "error"
63+
}
64+
},
65+
// Rule util file.
66+
{
67+
"files": ["./src/util/rule.ts"],
68+
"rules": {
69+
"@typescript-eslint/prefer-readonly-parameter-types": "warn"
70+
}
71+
},
72+
// Typeguard files.
73+
{
74+
"files": ["./src/util/typeguard.ts"],
75+
"rules": {
76+
"jsdoc/require-jsdoc": "off"
77+
}
78+
},
79+
// Test files.
80+
{
81+
"files": ["./tests/**/*"],
82+
"rules": {
83+
"jsdoc/require-jsdoc": "off"
84+
}
85+
},
86+
// CZ Adapter files.
87+
{
88+
"files": ["./cz-adapter/**/*"],
89+
"rules": {
90+
"jsdoc/require-jsdoc": "off"
91+
}
6192
},
6293
// FIXME: This override is defined in the upsteam; it shouldn't need to be redefined here. Why?
6394
{

cz-adapter/engine.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ import { rules } from "~/rules";
55

66
import type { Options } from "./options";
77

8-
type Answers = {
9-
readonly type: string;
10-
readonly scope?: string;
11-
readonly scopeRules?: string;
12-
readonly subject: string;
13-
readonly body?: string;
14-
readonly isBreaking: boolean;
15-
readonly isIssueAffected: boolean;
16-
readonly issues?: string;
17-
};
8+
type Answers = Readonly<{
9+
type: string;
10+
scope?: string;
11+
scopeRules?: string;
12+
subject: string;
13+
body?: string;
14+
isBreaking: boolean;
15+
isIssueAffected: boolean;
16+
issues?: string;
17+
}>;
1818

1919
type CZ = any;
2020

cz-adapter/options.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { types as conventionalCommitTypes } from "conventional-commit-types";
2+
import type { ReadonlyDeep } from "type-fest";
23

34
// Override the descriptions of some of the types.
45
const types = {
@@ -48,13 +49,13 @@ const types = {
4849
},
4950
};
5051

51-
const defaults: {
52-
readonly defaultType: string | undefined;
53-
readonly defaultScope: string | undefined;
54-
readonly defaultSubject: string | undefined;
55-
readonly defaultBody: string | undefined;
56-
readonly defaultIssues: string | undefined;
57-
} = {
52+
const defaults: Readonly<{
53+
defaultType: string | undefined;
54+
defaultScope: string | undefined;
55+
defaultSubject: string | undefined;
56+
defaultBody: string | undefined;
57+
defaultIssues: string | undefined;
58+
}> = {
5859
defaultType: process.env.CZ_TYPE,
5960
defaultScope: process.env.CZ_SCOPE,
6061
defaultSubject: process.env.CZ_SUBJECT,
@@ -71,6 +72,6 @@ const options = {
7172
maxLineWidth: 100,
7273
};
7374

74-
export type Options = typeof options;
75+
export type Options = ReadonlyDeep<typeof options>;
7576

7677
export default options;

docs/rules/functional-parameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Any function that take takes multiple parameter can be rewritten as a higher-ord
112112

113113
Example:
114114

115-
<!-- eslint-disable no-redeclare -->
115+
<!-- eslint-disable @typescript-eslint/no-redeclare -->
116116

117117
```js
118118
// This function

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"verify": "yarn build && yarn lint && yarn build-tests && yarn test-compiled && rimraf build"
6363
},
6464
"dependencies": {
65-
"@typescript-eslint/experimental-utils": "^5.0.0",
65+
"@typescript-eslint/utils": "^5.10.0",
6666
"deepmerge-ts": "^2.0.1",
6767
"escape-string-regexp": "^4.0.0"
6868
},
@@ -71,7 +71,7 @@
7171
"@commitlint/config-conventional": "^14.1.0",
7272
"@google/semantic-release-replace-plugin": "^1.1.0",
7373
"@istanbuljs/nyc-config-typescript": "^1.0.1",
74-
"@rebeccastevens/eslint-config": "^1.1.5",
74+
"@rebeccastevens/eslint-config": "^1.2.1",
7575
"@rollup/plugin-commonjs": "^21.0.0",
7676
"@rollup/plugin-json": "^4.1.0",
7777
"@rollup/plugin-node-resolve": "^13.0.5",
@@ -87,8 +87,8 @@
8787
"@types/estree": "^0.0.50",
8888
"@types/node": "16.11.0",
8989
"@types/rollup-plugin-auto-external": "^2.0.2",
90-
"@typescript-eslint/eslint-plugin": "^5.0.0",
91-
"@typescript-eslint/parser": "^5.0.0",
90+
"@typescript-eslint/eslint-plugin": "^5.10.0",
91+
"@typescript-eslint/parser": "^5.10.0",
9292
"ava": "^3.15.0",
9393
"babel-eslint": "^10.1.0",
9494
"chalk": "^4.1.2",
@@ -131,6 +131,7 @@
131131
"tsconfig-paths": "^3.10.1",
132132
"tslib": "^2.0.3",
133133
"tsutils": "^3.21.0",
134+
"type-fest": "^2.9.0",
134135
"typescript": "^4.4.4",
135136
"word-wrap": "^1.2.3"
136137
},

0 commit comments

Comments
 (0)