Skip to content

Commit

Permalink
refactor: refactor the code base and update linting rules
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaStevens committed Jan 18, 2022
1 parent ea28256 commit 39501b3
Show file tree
Hide file tree
Showing 32 changed files with 1,391 additions and 922 deletions.
33 changes: 32 additions & 1 deletion .eslintrc.json
Expand Up @@ -39,6 +39,7 @@
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"import/no-relative-parent-imports": "error",
"functional/prefer-readonly-type": "off",
"node/no-unsupported-features/es-builtins": "off",
"node/no-unsupported-features/es-syntax": "off",
"promise/prefer-await-to-callbacks": "off",
Expand All @@ -57,7 +58,37 @@
{
"files": ["./src/**/*"],
"extends": ["plugin:eslint-plugin/recommended"],
"rules": {}
"rules": {
"functional/no-expression-statement": "error"
}
},
// Rule util file.
{
"files": ["./src/util/rule.ts"],
"rules": {
"@typescript-eslint/prefer-readonly-parameter-types": "warn"
}
},
// Typeguard files.
{
"files": ["./src/util/typeguard.ts"],
"rules": {
"jsdoc/require-jsdoc": "off"
}
},
// Test files.
{
"files": ["./tests/**/*"],
"rules": {
"jsdoc/require-jsdoc": "off"
}
},
// CZ Adapter files.
{
"files": ["./cz-adapter/**/*"],
"rules": {
"jsdoc/require-jsdoc": "off"
}
},
// FIXME: This override is defined in the upsteam; it shouldn't need to be redefined here. Why?
{
Expand Down
20 changes: 10 additions & 10 deletions cz-adapter/engine.ts
Expand Up @@ -5,16 +5,16 @@ import { rules } from "~/rules";

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

type Answers = {
readonly type: string;
readonly scope?: string;
readonly scopeRules?: string;
readonly subject: string;
readonly body?: string;
readonly isBreaking: boolean;
readonly isIssueAffected: boolean;
readonly issues?: string;
};
type Answers = Readonly<{
type: string;
scope?: string;
scopeRules?: string;
subject: string;
body?: string;
isBreaking: boolean;
isIssueAffected: boolean;
issues?: string;
}>;

type CZ = any;

Expand Down
17 changes: 9 additions & 8 deletions cz-adapter/options.ts
@@ -1,4 +1,5 @@
import { types as conventionalCommitTypes } from "conventional-commit-types";
import type { ReadonlyDeep } from "type-fest";

// Override the descriptions of some of the types.
const types = {
Expand Down Expand Up @@ -48,13 +49,13 @@ const types = {
},
};

const defaults: {
readonly defaultType: string | undefined;
readonly defaultScope: string | undefined;
readonly defaultSubject: string | undefined;
readonly defaultBody: string | undefined;
readonly defaultIssues: string | undefined;
} = {
const defaults: Readonly<{
defaultType: string | undefined;
defaultScope: string | undefined;
defaultSubject: string | undefined;
defaultBody: string | undefined;
defaultIssues: string | undefined;
}> = {
defaultType: process.env.CZ_TYPE,
defaultScope: process.env.CZ_SCOPE,
defaultSubject: process.env.CZ_SUBJECT,
Expand All @@ -71,6 +72,6 @@ const options = {
maxLineWidth: 100,
};

export type Options = typeof options;
export type Options = ReadonlyDeep<typeof options>;

export default options;
2 changes: 1 addition & 1 deletion docs/rules/functional-parameters.md
Expand Up @@ -112,7 +112,7 @@ Any function that take takes multiple parameter can be rewritten as a higher-ord

Example:

<!-- eslint-disable no-redeclare -->
<!-- eslint-disable @typescript-eslint/no-redeclare -->

```js
// This function
Expand Down
9 changes: 5 additions & 4 deletions package.json
Expand Up @@ -62,7 +62,7 @@
"verify": "yarn build && yarn lint && yarn build-tests && yarn test-compiled && rimraf build"
},
"dependencies": {
"@typescript-eslint/experimental-utils": "^5.0.0",
"@typescript-eslint/utils": "^5.10.0",
"deepmerge-ts": "^2.0.1",
"escape-string-regexp": "^4.0.0"
},
Expand All @@ -71,7 +71,7 @@
"@commitlint/config-conventional": "^14.1.0",
"@google/semantic-release-replace-plugin": "^1.1.0",
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@rebeccastevens/eslint-config": "^1.1.5",
"@rebeccastevens/eslint-config": "^1.2.1",
"@rollup/plugin-commonjs": "^21.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.5",
Expand All @@ -87,8 +87,8 @@
"@types/estree": "^0.0.50",
"@types/node": "16.11.0",
"@types/rollup-plugin-auto-external": "^2.0.2",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"@typescript-eslint/eslint-plugin": "^5.10.0",
"@typescript-eslint/parser": "^5.10.0",
"ava": "^3.15.0",
"babel-eslint": "^10.1.0",
"chalk": "^4.1.2",
Expand Down Expand Up @@ -131,6 +131,7 @@
"tsconfig-paths": "^3.10.1",
"tslib": "^2.0.3",
"tsutils": "^3.21.0",
"type-fest": "^2.9.0",
"typescript": "^4.4.4",
"word-wrap": "^1.2.3"
},
Expand Down

0 comments on commit 39501b3

Please sign in to comment.