Skip to content

Commit f7efb1a

Browse files
authored
chore: add prettier to workspace (#26)
Add prettier to workspace and enable the precommit hook and linter closes #3
1 parent 5ceeb7f commit f7efb1a

File tree

123 files changed

+13512
-2136
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+13512
-2136
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules
22
dist
33
lerna-debug.log
4-
yarn-debug.log
4+
yarn-debug.log
5+
yarn-error.log

.prettierignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
coverage

.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all"
4+
}

.yarnrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
--install.exact true
1+
--add.exact true

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ This repo utilizes [Yarn Workspaces](https://yarnpkg.com/lang/en/docs/workspaces
66

77
## Commit Message Guidelines
88

9-
We follow the [Conventional Commits](https://conventionalcommits.org/) guidelines. These are enforced through the use of [commitlint](http://marionebl.github.io/commitlint). If you would like a more interactive way of formatting your commit messages, run `yarn commit` once your changes are staged.
9+
We follow the [Conventional Commits](https://conventionalcommits.org/) guidelines. These are enforced through the use of [commitlint](http://marionebl.github.io/commitlint). If you would like a more interactive way of formatting your commit messages, run `yarn commit` once your changes are staged.

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# @angular-redux
2+
23
[![CircleCI](https://circleci.com/gh/angular-redux/platform/tree/master.svg?style=svg)](https://circleci.com/gh/angular-redux/platform/tree/master)
34

45
[Redux](https://redux.js.org/) bindings for [Angular](https://angular.io/) applications.

package.json

+16-6
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,23 @@
77
"build": "lerna run build",
88
"lint": "lerna run lint",
99
"commit": "commit",
10-
"commitmsg": "commitlint -E GIT_PARAMS"
10+
"prettier": "prettier --write \"**/*.*(ts|js|css|scss|json|md)\"",
11+
"pre-commit": "lint-staged",
12+
"commit-msg": "commitlint -E GIT_PARAMS"
13+
},
14+
"lint-staged": {
15+
"*.{ts,js,css,scss,json,md}": [
16+
"prettier --write",
17+
"git add"
18+
]
1119
},
1220
"devDependencies": {
13-
"@commitlint/cli": "^7.0.0",
14-
"@commitlint/config-conventional": "^7.0.1",
15-
"@commitlint/prompt-cli": "^7.0.0",
16-
"husky": "^0.14.3",
17-
"lerna": "2.11.0"
21+
"@commitlint/cli": "7.0.0",
22+
"@commitlint/config-conventional": "7.0.1",
23+
"@commitlint/prompt-cli": "7.0.0",
24+
"husky": "0.14.3",
25+
"lerna": "2.11.0",
26+
"lint-staged": "7.2.0",
27+
"prettier": "1.13.7"
1828
}
1929
}

packages/example-app/.angular-cli.json

+2-7
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,15 @@
77
{
88
"root": "src",
99
"outDir": "dist",
10-
"assets": [
11-
"assets",
12-
"favicon.ico"
13-
],
10+
"assets": ["assets", "favicon.ico"],
1411
"index": "index.html",
1512
"main": "main.ts",
1613
"polyfills": "polyfills.ts",
1714
"test": "test.ts",
1815
"tsconfig": "tsconfig.app.json",
1916
"testTsconfig": "tsconfig.spec.json",
2017
"prefix": "zoo",
21-
"styles": [
22-
"styles.css"
23-
],
18+
"styles": ["styles.css"],
2419
"scripts": [],
2520
"environmentSource": "environments/environment.ts",
2621
"environments": {

packages/example-app/README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
This is a sample project showing how the following packages work together to make a simple
66
application.
77

8-
* [redux](https://github.com/reactjs/redux) Predictable state container for Javascript.
9-
* [redux-observable](https://github.com/redux-observable/redux-observable) Side-effect handling with Observables
10-
* [@angular-redux/store](https://github.com/angular-redux/store) Redux + Angular bindings
11-
* [@angular-redux/router](https://github.com/angular-redux/router) Time travel with the Angular router
12-
* [@angular-redux/form](https://github.com/angular-redux/form) Time travel with Angular forms
13-
* [Redux DevTools Chrome Extension](https://github.com/zalmoxisus/redux-devtools-extension)
8+
- [redux](https://github.com/reactjs/redux) Predictable state container for Javascript.
9+
- [redux-observable](https://github.com/redux-observable/redux-observable) Side-effect handling with Observables
10+
- [@angular-redux/store](https://github.com/angular-redux/store) Redux + Angular bindings
11+
- [@angular-redux/router](https://github.com/angular-redux/router) Time travel with the Angular router
12+
- [@angular-redux/form](https://github.com/angular-redux/form) Time travel with Angular forms
13+
- [Redux DevTools Chrome Extension](https://github.com/zalmoxisus/redux-devtools-extension)
1414

1515
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.0.0-rc.0.
1616

1717
## Development server
18+
1819
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
1920

2021
## Code scaffolding

packages/example-app/karma.conf.js

+15-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Karma configuration file, see link for more information
22
// https://karma-runner.github.io/0.13/config/configuration-file.html
33

4-
module.exports = function (config) {
4+
module.exports = function(config) {
55
config.set({
66
basePath: '',
77
frameworks: ['jasmine', '@angular/cli'],
@@ -10,35 +10,34 @@ module.exports = function (config) {
1010
require('karma-chrome-launcher'),
1111
require('karma-jasmine-html-reporter'),
1212
require('karma-coverage-istanbul-reporter'),
13-
require('@angular/cli/plugins/karma')
13+
require('@angular/cli/plugins/karma'),
1414
],
15-
client:{
16-
clearContext: false // leave Jasmine Spec Runner output visible in browser
15+
client: {
16+
clearContext: false, // leave Jasmine Spec Runner output visible in browser
1717
},
18-
files: [
19-
{ pattern: './src/test.ts', watched: false }
20-
],
18+
files: [{ pattern: './src/test.ts', watched: false }],
2119
preprocessors: {
22-
'./src/test.ts': ['@angular/cli']
20+
'./src/test.ts': ['@angular/cli'],
2321
},
2422
mime: {
25-
'text/x-typescript': ['ts','tsx']
23+
'text/x-typescript': ['ts', 'tsx'],
2624
},
2725
coverageIstanbulReporter: {
28-
reports: [ 'html', 'lcovonly' ],
29-
fixWebpackSourcePaths: true
26+
reports: ['html', 'lcovonly'],
27+
fixWebpackSourcePaths: true,
3028
},
3129
angularCli: {
32-
environment: 'dev'
30+
environment: 'dev',
3331
},
34-
reporters: config.angularCli && config.angularCli.codeCoverage
35-
? ['progress', 'coverage-istanbul']
36-
: ['progress', 'kjhtml'],
32+
reporters:
33+
config.angularCli && config.angularCli.codeCoverage
34+
? ['progress', 'coverage-istanbul']
35+
: ['progress', 'kjhtml'],
3736
port: 9876,
3837
colors: true,
3938
logLevel: config.LOG_INFO,
4039
autoWatch: true,
4140
browsers: ['Chrome'],
42-
singleRun: false
41+
singleRun: false,
4342
});
4443
};

packages/example-app/protractor.conf.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@ const { SpecReporter } = require('jasmine-spec-reporter');
55

66
exports.config = {
77
allScriptsTimeout: 11000,
8-
specs: [
9-
'./e2e/**/*.e2e-spec.ts'
10-
],
8+
specs: ['./e2e/**/*.e2e-spec.ts'],
119
capabilities: {
12-
'browserName': 'chrome'
10+
browserName: 'chrome',
1311
},
1412
directConnect: true,
1513
baseUrl: 'http://localhost:4200/',
1614
framework: 'jasmine',
1715
jasmineNodeOpts: {
1816
showColors: true,
1917
defaultTimeoutInterval: 30000,
20-
print: function() {}
18+
print: function() {},
2119
},
2220
beforeLaunch: function() {
2321
require('ts-node').register({
24-
project: 'e2e/tsconfig.e2e.json'
22+
project: 'e2e/tsconfig.e2e.json',
2523
});
2624
},
2725
onPrepare() {
28-
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
29-
}
26+
jasmine
27+
.getEnv()
28+
.addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
29+
},
3030
};
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
.header { display: flex; }
2-
.header-cell { flex-basis: 25%; font-weight: bold; }
1+
.header {
2+
display: flex;
3+
}
4+
.header-cell {
5+
flex-basis: 25%;
6+
font-weight: bold;
7+
}

packages/example-app/src/app/animals/animal-list/component.spec.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { AnimalType } from '../model';
88

99
@Component({ selector: 'zoo-animal', template: '' })
1010
class MockAnimalComponent {
11-
@Input() key: string
12-
@Input() animalType: AnimalType
11+
@Input() key: string;
12+
@Input() animalType: AnimalType;
1313
}
1414

1515
describe('AnimalListComponent', () => {
@@ -29,6 +29,8 @@ describe('AnimalListComponent', () => {
2929
fixture.detectChanges();
3030

3131
const titleElement = fixture.debugElement.query(By.css('h2'));
32-
expect(titleElement.nativeElement.textContent).toContain('We have Wallabies');
32+
expect(titleElement.nativeElement.textContent).toContain(
33+
'We have Wallabies',
34+
);
3335
}));
3436
});
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
:host { display: flex; }
2-
div { flex-basis: 25%; }
1+
:host {
2+
display: flex;
3+
}
4+
div {
5+
flex-basis: 25%;
6+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { async, TestBed } from '@angular/core/testing';
2-
import { NgReduxTestingModule, MockNgRedux } from '@angular-redux/store/testing';
2+
import {
3+
NgReduxTestingModule,
4+
MockNgRedux,
5+
} from '@angular-redux/store/testing';
36
import { AnimalComponent } from './component';
47
import { CoreModule } from '../../core/module';
58
import 'rxjs/add/operator/toArray';
@@ -10,8 +13,10 @@ describe('AnimalComponent', () => {
1013
let spyConfigureSubStore;
1114

1215
beforeEach(async(() => {
13-
spyConfigureSubStore = spyOn(MockNgRedux.mockInstance, 'configureSubStore')
14-
.and.callThrough();
16+
spyConfigureSubStore = spyOn(
17+
MockNgRedux.mockInstance,
18+
'configureSubStore',
19+
).and.callThrough();
1520

1621
MockNgRedux.reset();
1722
TestBed.configureTestingModule({
@@ -31,62 +36,57 @@ describe('AnimalComponent', () => {
3136
it('should use the key to create a subStore', () =>
3237
expect(spyConfigureSubStore).toHaveBeenCalledWith(
3338
['WALLABIES', 'items', 'id1'],
34-
jasmine.any(Function)));
39+
jasmine.any(Function),
40+
));
3541

3642
it('select name data from the substore', async(() => {
37-
const mockSubStore = MockNgRedux.getSubStore(
38-
['WALLABIES', 'items', 'id1']);
43+
const mockSubStore = MockNgRedux.getSubStore(['WALLABIES', 'items', 'id1']);
3944

4045
const selectorStub = mockSubStore.getSelectorStub('name');
4146
selectorStub.next('Wilbert');
4247
selectorStub.complete();
4348

44-
animalComponent.name$
45-
.subscribe(
46-
name => expect(name).toEqual('Wilbert'));
49+
animalComponent.name$.subscribe(name => expect(name).toEqual('Wilbert'));
4750
}));
4851

4952
it('select ticket price data from the substore', async(() => {
50-
const mockSubStore = MockNgRedux.getSubStore(
51-
['WALLABIES', 'items', 'id1']);
53+
const mockSubStore = MockNgRedux.getSubStore(['WALLABIES', 'items', 'id1']);
5254

5355
const selectorStub = mockSubStore.getSelectorStub('ticketPrice');
5456
selectorStub.next(2);
5557
selectorStub.complete();
5658

57-
animalComponent.ticketPrice$
58-
.subscribe(
59-
ticketPrice => expect(ticketPrice).toEqual(2));
59+
animalComponent.ticketPrice$.subscribe(ticketPrice =>
60+
expect(ticketPrice).toEqual(2),
61+
);
6062
}));
6163

6264
it('select ticket quantity data from the substore', async(() => {
63-
const mockSubStore = MockNgRedux.getSubStore(
64-
['WALLABIES', 'items', 'id1']);
65+
const mockSubStore = MockNgRedux.getSubStore(['WALLABIES', 'items', 'id1']);
6566

6667
const selectorStub = mockSubStore.getSelectorStub('tickets');
6768
selectorStub.next(4);
6869
selectorStub.complete();
6970

70-
animalComponent.numTickets$
71-
.subscribe(
72-
numTickets => expect(numTickets).toEqual(4));
71+
animalComponent.numTickets$.subscribe(numTickets =>
72+
expect(numTickets).toEqual(4),
73+
);
7374
}));
7475

7576
it('should use reasonable defaults if ticket price is missing', async(() => {
76-
animalComponent.ticketPrice$
77-
.subscribe(
78-
ticketPrice => expect(ticketPrice).toEqual(0));
77+
animalComponent.ticketPrice$.subscribe(ticketPrice =>
78+
expect(ticketPrice).toEqual(0),
79+
);
7980
}));
8081

8182
it('should use reasonable defaults if ticket quantity is missing', async(() => {
82-
animalComponent.numTickets$
83-
.subscribe(
84-
numTickets => expect(numTickets).toEqual(0));
83+
animalComponent.numTickets$.subscribe(numTickets =>
84+
expect(numTickets).toEqual(0),
85+
);
8586
}));
8687

8788
it('should compute the subtotal as the ticket quantity changes', async(() => {
88-
const mockSubStore = MockNgRedux.getSubStore(
89-
['WALLABIES', 'items', 'id1']);
89+
const mockSubStore = MockNgRedux.getSubStore(['WALLABIES', 'items', 'id1']);
9090

9191
const priceStub = mockSubStore.getSelectorStub('ticketPrice');
9292
priceStub.next(1);
@@ -100,7 +100,6 @@ describe('AnimalComponent', () => {
100100

101101
animalComponent.subTotal$
102102
.toArray()
103-
.subscribe(
104-
subTotals => expect(subTotals).toEqual([5, 10, 15]));
103+
.subscribe(subTotals => expect(subTotals).toEqual([5, 10, 15]));
105104
}));
106105
});

packages/example-app/src/app/animals/animal/component.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@ export class AnimalComponent {
2828
@Input() key: string;
2929
@Input() animalType: string;
3030

31-
@select() readonly name$: Observable<string>;
32-
@select('tickets') readonly numTickets$: Observable<number>;
33-
@select('ticketPrice') readonly ticketPrice$: Observable<number>;
34-
@select$(null, toSubTotal) readonly subTotal$: Observable<number>;
31+
@select() readonly name$: Observable<string>;
32+
@select('tickets') readonly numTickets$: Observable<number>;
33+
@select('ticketPrice') readonly ticketPrice$: Observable<number>;
34+
@select$(null, toSubTotal)
35+
readonly subTotal$: Observable<number>;
3536

36-
getBasePath = () => this.key ?
37-
[ this.animalType, 'items', this.key ] :
38-
null;
37+
getBasePath = () => (this.key ? [this.animalType, 'items', this.key] : null);
3938

4039
@dispatch() addTicket = () => ({ type: 'ADD_TICKET' });
4140
@dispatch() removeTicket = () => ({ type: 'REMOVE_TICKET' });

0 commit comments

Comments
 (0)