Skip to content

Commit

Permalink
fix: fix eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianiy committed Sep 28, 2021
1 parent 3cbefb3 commit ab4d1d3
Show file tree
Hide file tree
Showing 56 changed files with 3,005 additions and 2,633 deletions.
41 changes: 41 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
env:
es6: true
node: true
browser: true
jest: true
plugins:
- '@typescript-eslint'
- 'eslint-plugin-prettier'
parser:
'@typescript-eslint/parser'
ignorePatterns:
- '**/docs/**'
parserOptions:
ecmaVersion: 2018
sourceType: module
rules:
curly:
- error
- all
object-curly-spacing:
- error
- always
array-bracket-spacing:
- error
- always
no-console:
- error
- { allow: ["warn", "error"] }
indent:
- error
- 4
- { SwitchCase: 1 }
linebreak-style:
- error
- unix
quotes:
- error
- single
semi:
- error
- always
31 changes: 0 additions & 31 deletions .github/workflows/publish-workflow.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/relese-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: actions/checkout@v2
with:
submodules: recursive
token: ${{ secrets.GH_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Use Node.js 14.x
uses: actions/setup-node@v2
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Create release version
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN
Expand Down
4 changes: 0 additions & 4 deletions .prettierrc

This file was deleted.

13 changes: 13 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"arrowParens": "avoid",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"quoteProps": "consistent",
"printWidth": 120,
"semi": true,
"singleQuote": true,
"tabWidth": 4,
"trailingComma": "all",
"useTabs": false
}
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
"clean:coverage": "rimraf coverage",
"clean:dist": "rimraf packages/*/dist",
"docs": "docsify serve ./docs",
"lint": "npm-run-all -p lint:*",
"lint:packages": "tslint -p tsconfig.json",
"lint:prettier": "prettier -l \"**/*.*(ts|js|css|scss|json|md)\"",
"lint": "eslint packages/**/*.{js,ts} --fix",
"test": "jest --coverage",
"test:ci": "jest --coverage --ci --maxWorkers=2",
"test:watch": "jest --watch",
Expand Down Expand Up @@ -60,9 +58,14 @@
"@semantic-release/npm": "^7.0.5",
"@semantic-release/release-notes-generator": "^9.0.1",
"@types/jest": "23.3.13",
"@typescript-eslint/eslint-plugin": "4.22.0",
"@typescript-eslint/eslint-plugin-tslint": "4.22.0",
"@typescript-eslint/parser": "4.22.0",
"babel-jest": "23.6.0",
"codelyzer": "4.5.0",
"docsify-cli": "4.3.0",
"eslint": "^7.22.0",
"eslint-plugin-prettier": "^3.3.1",
"husky": "1.3.1",
"jest": "23.6.0",
"jest-junit": "6.0.1",
Expand Down
138 changes: 69 additions & 69 deletions packages/form/src/compose-reducers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,85 +3,85 @@ import { fromJS, List, Map, Set } from 'immutable';
import { composeReducers } from './compose-reducers';

xdescribe('composeReducers', () => {
const compose = (s1: any, s2: any, s3: any) => {
const r1 = (state = s1) => state;
const r2 = (state = s2) => state;
const r3 = (state = s3) => state;
const compose = (s1: any, s2: any, s3: any) => {
const r1 = (state = s1) => state;
const r2 = (state = s2) => state;
const r3 = (state = s3) => state;

const reducer = composeReducers(r1, r2, r3);
const reducer = composeReducers(r1, r2, r3);

return reducer(undefined, { type: '' });
};
return reducer(undefined, { type: '' });
};

it('can compose plain-object initial states', () => {
const state = compose(
{ a: 1 },
{ b: 1 },
{ c: 1 },
);
expect(state).toBeDefined();
expect(state).toEqual({ a: 1, b: 1, c: 1 });
});
it('can compose plain-object initial states', () => {
const state = compose(
{ a: 1 },
{ b: 1 },
{ c: 1 },
);
expect(state).toBeDefined();
expect(state).toEqual({ a: 1, b: 1, c: 1 });
});

it('can compose array states', () => {
const state = compose(
[1],
[2],
[3],
);
expect(state).toBeDefined();
expect(state).toEqual([1, 2, 3]);
});
it('can compose array states', () => {
const state = compose(
[ 1 ],
[ 2 ],
[ 3 ],
);
expect(state).toBeDefined();
expect(state).toEqual([ 1, 2, 3 ]);
});

it('can compose Immutable::Map initial states', () => {
const state = compose(
fromJS({ a: 1 }),
fromJS({ b: 1 }),
fromJS({ c: 1 }),
);
expect(Map.isMap(state)).toEqual(true);
it('can compose Immutable::Map initial states', () => {
const state = compose(
fromJS({ a: 1 }),
fromJS({ b: 1 }),
fromJS({ c: 1 }),
);
expect(Map.isMap(state)).toEqual(true);

const plain = state.toJS();
expect(plain).not.toBeNull();
expect(plain).toEqual({ a: 1, b: 1, c: 1 });
});
const plain = state.toJS();
expect(plain).not.toBeNull();
expect(plain).toEqual({ a: 1, b: 1, c: 1 });
});

it('can compose Immutable::Set initial states', () => {
const state = compose(
Set.of(1, 2, 3),
Set.of(4, 5, 6),
Set.of(),
);
expect(Set.isSet(state)).toEqual(true);
it('can compose Immutable::Set initial states', () => {
const state = compose(
Set.of(1, 2, 3),
Set.of(4, 5, 6),
Set.of(),
);
expect(Set.isSet(state)).toEqual(true);

const plain = state.toJS();
expect(plain).not.toBeNull();
expect(plain).toEqual([1, 2, 3, 4, 5, 6]);
});
const plain = state.toJS();
expect(plain).not.toBeNull();
expect(plain).toEqual([ 1, 2, 3, 4, 5, 6 ]);
});

it('can compose Immutable::OrderedSet initial states', () => {
const state = compose(
Set.of(3, 2, 1),
Set.of(4, 6, 5),
Set.of(),
);
expect(Set.isSet(state)).toEqual(true);
it('can compose Immutable::OrderedSet initial states', () => {
const state = compose(
Set.of(3, 2, 1),
Set.of(4, 6, 5),
Set.of(),
);
expect(Set.isSet(state)).toEqual(true);

const plain = state.toJS();
expect(plain).not.toBeNull();
expect(plain).toEqual([3, 2, 1, 4, 6, 5]);
});
const plain = state.toJS();
expect(plain).not.toBeNull();
expect(plain).toEqual([ 3, 2, 1, 4, 6, 5 ]);
});

it('can compose Immutable::List initial states', () => {
const state = compose(
List.of('a', 'b'),
List.of('c', 'd'),
List.of(),
);
expect(List.isList(state)).toEqual(true);
it('can compose Immutable::List initial states', () => {
const state = compose(
List.of('a', 'b'),
List.of('c', 'd'),
List.of(),
);
expect(List.isList(state)).toEqual(true);

const plain = state.toJS();
expect(plain).not.toBeNull();
expect(plain).toEqual(['a', 'b', 'c', 'd']);
});
const plain = state.toJS();
expect(plain).not.toBeNull();
expect(plain).toEqual([ 'a', 'b', 'c', 'd' ]);
});
});
4 changes: 2 additions & 2 deletions packages/form/src/compose-reducers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AnyAction, Reducer } from 'redux';

export const composeReducers = <State>(
...reducers: Reducer<State, AnyAction>[]
...reducers: Reducer<State, AnyAction>[]
): Reducer<State, AnyAction> => (s: any, action: AnyAction) =>
reducers.reduce((st, reducer) => reducer(st, action), s);
reducers.reduce((st, reducer) => reducer(st, action), s);
18 changes: 9 additions & 9 deletions packages/form/src/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ import { AbstractStore, FormStore } from './form-store';
/// This will allow you to provide a preexisting store that you have already
/// configured, rather than letting ngredux-core create one for you.
export const provideReduxForms = <T>(store: Store<T> | any) => {
const abstractStore = wrap(store);
const abstractStore = wrap(store);

return [
{ provide: FormStore, useValue: new FormStore(abstractStore as any) },
];
return [
{ provide: FormStore, useValue: new FormStore(abstractStore as any) },
];
};

const wrap = <T>(store: Store<T> | any): AbstractStore<T> => {
const dispatch = (action: Action) => store.dispatch(action);
const dispatch = (action: Action) => store.dispatch(action);

const getState = () => store.getState() as T;
const getState = () => store.getState() as T;

const subscribe = (fn: (state: T) => void) =>
store.subscribe(() => fn(store.getState()));
const subscribe = (fn: (state: T) => void) =>
store.subscribe(() => fn(store.getState()));

return { dispatch, getState, subscribe };
return { dispatch, getState, subscribe };
};
2 changes: 1 addition & 1 deletion packages/form/src/connect-array/connect-array-template.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export class ConnectArrayTemplate {
constructor(public $implicit: any, public index: number, public item: any) {}
constructor(public $implicit: any, public index: number, public item: any) {}
}
6 changes: 3 additions & 3 deletions packages/form/src/connect-array/connect-array.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { NgModule } from '@angular/core';

import { ConnectArrayDirective } from './connect-array.directive';

const declarations = [ConnectArrayDirective];
const declarations = [ ConnectArrayDirective ];

@NgModule({
declarations: [...declarations],
exports: [...declarations],
declarations: [ ...declarations ],
exports: [ ...declarations ],
})
export class NgReduxFormConnectArrayModule {}
Loading

0 comments on commit ab4d1d3

Please sign in to comment.