Skip to content

Commit

Permalink
fix(global): remove use of global variable __dirname
Browse files Browse the repository at this point in the history
  • Loading branch information
plusgut committed Jul 15, 2021
1 parent 9632353 commit 7ee69fc
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 66 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@plusnew/state",
"version": "0.15.1",
"version": "0.15.2",
"description": "library for doing complex statemanagement in plusnew",
"main": "src/index.tsx",
"module": "src/index.tsx",
Expand Down
20 changes: 11 additions & 9 deletions src/components/branchFactory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import type { entitiesContainerTemplate, entityEmpty } from "../../types";
import type { repositoryActions, repositoryState } from "../repositoryFactory";
import idSerializer from "../../util/idSerializer";

type changedAttributes<T extends entitiesContainerTemplate, U extends keyof T> =
{
type: "ATTRIBUTES_CHANGE";
model: U;
id: string;
payload: Partial<T[U]["item"]["attributes"]>;
};
type changedAttributes<
T extends entitiesContainerTemplate,
U extends keyof T
> = {
type: "ATTRIBUTES_CHANGE";
model: U;
id: string;
payload: Partial<T[U]["item"]["attributes"]>;
};

type changedRelationships<
T extends entitiesContainerTemplate,
Expand Down Expand Up @@ -85,8 +87,8 @@ export default <T extends entitiesContainerTemplate>(
repositoryContext: Context<repositoryState<T>, repositoryActions<T>>,
branchContext: Context<branchState<T>, branchActions<T>>
) =>
class Item extends Component<props> {
static displayName = __dirname;
class Branch extends Component<props> {
static displayName = "StateBranch";
render(
Props: Props<props>,
componentInstance: ComponentInstance<props, any, any>
Expand Down
2 changes: 1 addition & 1 deletion src/components/itemFactory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default <T extends entitiesContainerTemplate>(
U extends keyof T,
Id extends T[U]["item"]["id"] | null
> extends Component<props<T, U, Id>> {
static displayName = __dirname;
static displayName = "StateItem";
render(
Props: Props<props<T, U, Id>>,
componentInstance: ComponentInstance<any, any, any>
Expand Down
18 changes: 10 additions & 8 deletions src/components/listFactory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import type { entitiesContainerTemplate, entityEmpty } from "../../types";
import type { branchState, branchActions } from "../branchFactory";
import type { repositoryState, repositoryActions } from "../repositoryFactory";

type listRenderProps<T extends entitiesContainerTemplate, U extends keyof T> =
(value: {
isLoading: boolean;
items: entityEmpty<U, T[U]["item"]["id"]>[];
totalCount: number;
isEmpty: boolean;
}) => ApplicationElement;
type listRenderProps<
T extends entitiesContainerTemplate,
U extends keyof T
> = (value: {
isLoading: boolean;
items: entityEmpty<U, T[U]["item"]["id"]>[];
totalCount: number;
isEmpty: boolean;
}) => ApplicationElement;

type props<T extends entitiesContainerTemplate, U extends keyof T> = {
model: U;
Expand All @@ -27,7 +29,7 @@ export default <T extends entitiesContainerTemplate>(
branchContext: Context<branchState<T>, branchActions<T>>
) =>
class List<U extends keyof T> extends Component<props<T, U>> {
static displayName = __dirname;
static displayName = "StateList";
render(Props: Props<props<T, U>>) {
return (
<repositoryContext.Consumer>
Expand Down
4 changes: 2 additions & 2 deletions src/components/mergeFactory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ export default <T extends entitiesContainerTemplate>(
repositoryContext: Context<repositoryState<T>, repositoryActions<T>>,
branchContext: Context<branchState<T>, branchActions<T>>
) =>
class List extends Component<props<T>> {
static displayName = __dirname;
class Merge extends Component<props<T>> {
static displayName = "StateMerge";
render(
Props: Props<props<T>>,
componentInstance: ComponentInstance<any, any, any>
Expand Down
2 changes: 1 addition & 1 deletion src/components/reduceFactory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default <T extends entitiesContainerTemplate>(
branchContext: Context<branchState<T>, branchActions<T>>
) =>
class Reduce<U extends keyof T, A> extends Component<props<T, U, A>> {
static displayName = __dirname;
static displayName = "StateReduce";
render(Props: Props<props<T, U, A>>) {
return (
<repositoryContext.Consumer>
Expand Down
22 changes: 12 additions & 10 deletions src/components/repositoryFactory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,18 @@ type itemsInsertErrorAction<T extends entitiesContainerTemplate> = {
};
};

type listInsertAction<T extends entitiesContainerTemplate, U extends keyof T> =
{
type: "LIST_INSERT";
model: U;
query: string;
payload: {
items: T[U]["item"][] | entityEmpty<U, T[U]["item"]["id"]>[];
totalCount: number;
};
type listInsertAction<
T extends entitiesContainerTemplate,
U extends keyof T
> = {
type: "LIST_INSERT";
model: U;
query: string;
payload: {
items: T[U]["item"][] | entityEmpty<U, T[U]["item"]["id"]>[];
totalCount: number;
};
};

type listErrorAction<T extends entitiesContainerTemplate, U extends keyof T> = {
type: "LIST_ERROR";
Expand Down Expand Up @@ -306,7 +308,7 @@ export default <T extends entitiesContainerTemplate>(
);
}
return class Repository extends Component<props<T>> {
static displayName = __dirname;
static displayName = "StateRepository";
render(Props: Props<props<T>>) {
let loadingLists: [keyof T, string][] = [];
let loadingItems: [keyof T, number | string][] = [];
Expand Down
34 changes: 0 additions & 34 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -730,14 +730,6 @@
"@typescript-eslint/typescript-estree" "4.28.3"
debug "^4.3.1"

"@typescript-eslint/scope-manager@4.28.2":
version "4.28.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.28.2.tgz#451dce90303a3ce283750111495d34c9c204e510"
integrity sha512-MqbypNjIkJFEFuOwPWNDjq0nqXAKZvDNNs9yNseoGBB1wYfz1G0WHC2AVOy4XD7di3KCcW3+nhZyN6zruqmp2A==
dependencies:
"@typescript-eslint/types" "4.28.2"
"@typescript-eslint/visitor-keys" "4.28.2"

"@typescript-eslint/scope-manager@4.28.3":
version "4.28.3"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.28.3.tgz#c32ad4491b3726db1ba34030b59ea922c214e371"
Expand All @@ -746,29 +738,11 @@
"@typescript-eslint/types" "4.28.3"
"@typescript-eslint/visitor-keys" "4.28.3"

"@typescript-eslint/types@4.28.2":
version "4.28.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.28.2.tgz#e6b9e234e0e9a66c4d25bab881661e91478223b5"
integrity sha512-Gr15fuQVd93uD9zzxbApz3wf7ua3yk4ZujABZlZhaxxKY8ojo448u7XTm/+ETpy0V0dlMtj6t4VdDvdc0JmUhA==

"@typescript-eslint/types@4.28.3":
version "4.28.3"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.28.3.tgz#8fffd436a3bada422c2c1da56060a0566a9506c7"
integrity sha512-kQFaEsQBQVtA9VGVyciyTbIg7S3WoKHNuOp/UF5RG40900KtGqfoiETWD/v0lzRXc+euVE9NXmfer9dLkUJrkA==

"@typescript-eslint/typescript-estree@4.28.2":
version "4.28.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.28.2.tgz#680129b2a285289a15e7c6108c84739adf3a798c"
integrity sha512-86lLstLvK6QjNZjMoYUBMMsULFw0hPHJlk1fzhAVoNjDBuPVxiwvGuPQq3fsBMCxuDJwmX87tM/AXoadhHRljg==
dependencies:
"@typescript-eslint/types" "4.28.2"
"@typescript-eslint/visitor-keys" "4.28.2"
debug "^4.3.1"
globby "^11.0.3"
is-glob "^4.0.1"
semver "^7.3.5"
tsutils "^3.21.0"

"@typescript-eslint/typescript-estree@4.28.3":
version "4.28.3"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.28.3.tgz#253d7088100b2a38aefe3c8dd7bd1f8232ec46fb"
Expand All @@ -782,14 +756,6 @@
semver "^7.3.5"
tsutils "^3.21.0"

"@typescript-eslint/visitor-keys@4.28.2":
version "4.28.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.28.2.tgz#bf56a400857bb68b59b311e6d0a5fbef5c3b5130"
integrity sha512-aT2B4PLyyRDUVUafXzpZFoc0C9t0za4BJAKP5sgWIhG+jHECQZUEjuQSCIwZdiJJ4w4cgu5r3Kh20SOdtEBl0w==
dependencies:
"@typescript-eslint/types" "4.28.2"
eslint-visitor-keys "^2.0.0"

"@typescript-eslint/visitor-keys@4.28.3":
version "4.28.3"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.28.3.tgz#26ac91e84b23529968361045829da80a4e5251c4"
Expand Down

0 comments on commit 7ee69fc

Please sign in to comment.