Skip to content

Commit b0841ad

Browse files
committed
style: only lint staged files
1 parent 4e319c7 commit b0841ad

25 files changed

+533
-195
lines changed

.prettierignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.prettierrc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
{
22
"singleQuote": true,
3-
"useTabs": false,
4-
"tabWidth": 2,
53
"semi": true,
6-
"bracketSpacing": true,
4+
"trailingComma": "all",
75
"overrides": [
86
{
9-
"files": "src/**/*.scss",
7+
"files": "src/**/*.{scss,css}",
108
"options": {
119
"singleQuote": false
1210
}

.stylelintrc

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
2-
"extends": ["stylelint-config-standard", "stylelint-config-recommended-scss"],
2+
"extends": [
3+
"stylelint-config-standard",
4+
"stylelint-config-recommended-scss",
5+
"stylelint-config-prettier"
6+
],
7+
"plugins": ["stylelint-order"],
38
"rules": {
4-
"order/order": [
5-
"custom-properties",
6-
"declarations"
7-
],
9+
"order/order": ["custom-properties", "declarations"],
810
"order/properties-alphabetical-order": true,
9-
"no-empty-source": null,
1011
"selector-type-no-unknown": [
1112
true,
1213
{
@@ -18,12 +19,6 @@
1819
{
1920
"ignorePseudoElements": ["ng-deep"]
2021
}
21-
],
22-
"declaration-colon-newline-after": null,
23-
"at-rule-empty-line-before": null,
24-
"block-closing-brace-newline-after": null
25-
},
26-
"plugins": [
27-
"stylelint-order"
28-
]
22+
]
23+
}
2924
}

package.json

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,16 @@
3636
"start": "ng serve",
3737
"build": "ng build",
3838
"test": "ng test",
39-
"lint": "npm run format:check && npm run lint:ts && npm run lint:scss",
4039
"e2e": "ng e2e",
40+
"lint": "npm run stylelint && npm run nglint && npm run prettier",
41+
"lint:fix": "npm run stylelint -- --fix && npm run nglint -- --fix && npm run prettier -- --write",
42+
"nglint": "ng lint",
43+
"stylelint": "stylelint --syntax scss \"src/**/*.{css,scss}\"",
44+
"prettier": "prettier --config .prettierrc -l \"src/**/*.{ts,js,json,css,scss}\"",
4145
"coverage": "coveralls < coverage/lcov.info",
4246
"packagr": "ng-packagr -p package.json",
4347
"release": "standard-version",
44-
"postrelease": "npm run packagr",
45-
"lint:ts": "ng lint",
46-
"lint:ts:fix": "ng lint angular-image-loader --fix && ng lint angular-image-loader-e2e --fix",
47-
"lint:scss": "stylelint --syntax scss \"src/**/*.scss\"",
48-
"format:check": "prettier --config ./.prettierrc -l \"{src/{app,environments,assets}/**/*.{ts,json,css,scss},./*.{ts,js,json,css,scss}}\"",
49-
"format:fix:staged": "pretty-quick --staged",
50-
"format:fix:all": "npm run format:check -- --write && npm run lint:scss -- --fix && npm run lint:ts:fix",
51-
"precommit": "npm run format:fix:staged && npm run lint"
48+
"postrelease": "npm run packagr"
5249
},
5350
"private": false,
5451
"dependencies": {},
@@ -97,15 +94,17 @@
9794
"tslint": "~5.7.0",
9895
"typescript": "~2.7.2",
9996
"zone.js": "^0.8.26",
100-
"husky": "^0.14.3",
101-
"prettier": "^1.11.1",
102-
"pretty-quick": "^1.4.1",
103-
"stylelint": "^9.2.0",
104-
"stylelint-order": "^0.8.1",
97+
"husky": "^1.1.0",
98+
"prettier": "^1.14.3",
99+
"stylelint": "^9.6.0",
100+
"stylelint-order": "^1.0.0",
105101
"stylelint-config-recommended-scss": "^3.2.0",
106102
"stylelint-config-standard": "^18.2.0",
107-
"stylelint-scss": "^3.0.0",
108-
"karma-mocha-reporter": "^2.2.5"
103+
"stylelint-scss": "^3.3.1",
104+
"karma-mocha-reporter": "^2.2.5",
105+
"lint-staged": "^7.3.0",
106+
"stylelint-config-prettier": "^4.0.0",
107+
"tslint-config-prettier": "^1.15.0"
109108
},
110109
"config": {
111110
"commitizen": {
@@ -120,5 +119,24 @@
120119
"@thisissoon/angular-inviewport": "angularInViewport"
121120
}
122121
}
122+
},
123+
"husky": {
124+
"hooks": {
125+
"pre-commit": "lint-staged"
126+
}
127+
},
128+
"lint-staged": {
129+
"src/**/*.ts": [
130+
"tslint --fix",
131+
"git add"
132+
],
133+
"src/**/*.{css,scss}": [
134+
"stylelint --syntax scss --fix",
135+
"git add"
136+
],
137+
"src/**/*.{ts,js,json,css,scss}": [
138+
"prettier --config .prettierrc --write",
139+
"git add"
140+
]
123141
}
124142
}

src/app/app-data.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ export const image: ResponsiveImage = {
99
{
1010
size: 'xs',
1111
x1: 'http://via.placeholder.com/400x400?text=xs+1x',
12-
x2: 'http://via.placeholder.com/800x800?text=xs+2x'
12+
x2: 'http://via.placeholder.com/800x800?text=xs+2x',
1313
},
1414
{
1515
size: 'md',
1616
x1: 'http://via.placeholder.com/768x400?text=md+1x',
17-
x2: 'http://via.placeholder.com/1536x800?text=md+2x'
17+
x2: 'http://via.placeholder.com/1536x800?text=md+2x',
1818
},
1919
{
2020
size: 'lg',
2121
x1: 'http://via.placeholder.com/1024x400?text=lg+1x',
22-
x2: 'http://via.placeholder.com/2048x800?text=lg+2x'
23-
}
24-
]
22+
x2: 'http://via.placeholder.com/2048x800?text=lg+2x',
23+
},
24+
],
2525
};
2626

2727
export const video: ResponsiveVideo = {
@@ -30,18 +30,18 @@ export const video: ResponsiveVideo = {
3030
{
3131
size: 'xs',
3232
url:
33-
'http://res.cloudinary.com/thisissoon/video/upload/ac_none,c_fill,h_568,q_80,w_320/v1517616795/demos/jellyfish-25-mbps-hd-hevc.mp4'
33+
'http://res.cloudinary.com/thisissoon/video/upload/ac_none,c_fill,h_568,q_80,w_320/v1517616795/demos/jellyfish-25-mbps-hd-hevc.mp4',
3434
},
3535
{
3636
size: 'md',
3737
url:
38-
'http://res.cloudinary.com/thisissoon/video/upload/ac_none,c_fill,h_1024,q_80,w_768/v1517616795/demos/jellyfish-25-mbps-hd-hevc.mp4'
38+
'http://res.cloudinary.com/thisissoon/video/upload/ac_none,c_fill,h_1024,q_80,w_768/v1517616795/demos/jellyfish-25-mbps-hd-hevc.mp4',
3939
},
4040
{
4141
size: 'lg',
4242
url:
43-
'http://res.cloudinary.com/thisissoon/video/upload/ac_none,c_fill,h_720,q_80,w_1280/v1517616795/demos/jellyfish-25-mbps-hd-hevc.mp4'
44-
}
43+
'http://res.cloudinary.com/thisissoon/video/upload/ac_none,c_fill,h_720,q_80,w_1280/v1517616795/demos/jellyfish-25-mbps-hd-hevc.mp4',
44+
},
4545
],
4646
poster: {
4747
placeholder:
@@ -54,29 +54,29 @@ export const video: ResponsiveVideo = {
5454
x1:
5555
'http://res.cloudinary.com/thisissoon/image/upload/c_fill,h_568,q_80,w_320/v1517616811/demos/jellyfish-25-mbps-hd-hevc_lpnffm.jpg',
5656
x2:
57-
'http://res.cloudinary.com/thisissoon/image/upload/c_fill,h_1136,q_80,w_640/v1517616811/demos/jellyfish-25-mbps-hd-hevc_lpnffm.jpg'
57+
'http://res.cloudinary.com/thisissoon/image/upload/c_fill,h_1136,q_80,w_640/v1517616811/demos/jellyfish-25-mbps-hd-hevc_lpnffm.jpg',
5858
},
5959
{
6060
size: 'md',
6161
x1:
6262
'http://res.cloudinary.com/thisissoon/image/upload/c_fill,h_768,q_80,w_1024/v1517616811/demos/jellyfish-25-mbps-hd-hevc_lpnffm.jpg',
6363
x2:
64-
'http://res.cloudinary.com/thisissoon/image/upload/c_fill,h_1536,q_80,w_2048/v1517616811/demos/jellyfish-25-mbps-hd-hevc_lpnffm.jpg'
64+
'http://res.cloudinary.com/thisissoon/image/upload/c_fill,h_1536,q_80,w_2048/v1517616811/demos/jellyfish-25-mbps-hd-hevc_lpnffm.jpg',
6565
},
6666
{
6767
size: 'lg',
6868
x1:
6969
'http://res.cloudinary.com/thisissoon/image/upload/c_fill,h_768,q_80,w_1280/v1517616811/demos/jellyfish-25-mbps-hd-hevc_lpnffm.jpg',
7070
x2:
71-
'http://res.cloudinary.com/thisissoon/image/upload/c_fill,h_1536,q_80,w_2560/v1517616811/demos/jellyfish-25-mbps-hd-hevc_lpnffm.jpg'
72-
}
73-
]
74-
}
71+
'http://res.cloudinary.com/thisissoon/image/upload/c_fill,h_1536,q_80,w_2560/v1517616811/demos/jellyfish-25-mbps-hd-hevc_lpnffm.jpg',
72+
},
73+
],
74+
},
7575
};
7676
// tslint:enable:max-line-length
7777

7878
export const sizes: Breakpoint[] = [
7979
{ size: 'xs', width: 0 },
8080
{ size: 'md', width: 768 },
81-
{ size: 'lg', width: 992 }
81+
{ size: 'lg', width: 992 },
8282
];

src/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { video, image, sizes } from './app-data';
99
@Component({
1010
selector: 'sn-root',
1111
templateUrl: './app.component.html',
12-
styleUrls: ['./app.component.scss']
12+
styleUrls: ['./app.component.scss'],
1313
})
1414
export class AppComponent {
1515
sizes: Breakpoint[] = sizes;

src/app/app.module.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { AppComponent } from './app.component';
88

99
export const getWindow = () => window;
1010
export const providers: Provider[] = [
11-
{ provide: WindowRef, useFactory: getWindow }
11+
{ provide: WindowRef, useFactory: getWindow },
1212
];
1313

1414
@NgModule({
@@ -17,9 +17,9 @@ export const providers: Provider[] = [
1717
BrowserModule,
1818
InViewportModule.forRoot(providers),
1919
ImageLoaderModule,
20-
VideoLoaderModule
20+
VideoLoaderModule,
2121
],
2222
providers: [],
23-
bootstrap: [AppComponent]
23+
bootstrap: [AppComponent],
2424
})
2525
export class AppModule {}

src/app/image-loader/image-loader.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ import { ImageLoaderComponent } from './image-loader/image-loader.component';
1414
@NgModule({
1515
imports: [CommonModule, InViewportModule],
1616
declarations: [ImageLoaderComponent],
17-
exports: [ImageLoaderComponent]
17+
exports: [ImageLoaderComponent],
1818
})
1919
export class ImageLoaderModule {}

src/app/image-loader/image-loader/image-loader.component.spec.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('ImageLoaderComponent', () => {
1515
const sizes: Breakpoint[] = [
1616
{ size: 'xs', width: 0 },
1717
{ size: 'md', width: 768 },
18-
{ size: 'lg', width: 992 }
18+
{ size: 'lg', width: 992 },
1919
];
2020
let testBed;
2121

@@ -26,26 +26,26 @@ describe('ImageLoaderComponent', () => {
2626
{
2727
size: 'xs',
2828
x1: 'http://via.placeholder.com/150x350?text=xs+1x',
29-
x2: 'http://via.placeholder.com/300x700?text=xs+2x'
29+
x2: 'http://via.placeholder.com/300x700?text=xs+2x',
3030
},
3131
{
3232
size: 'md',
3333
x1: 'http://via.placeholder.com/350x250?text=md+1x',
34-
x2: 'http://via.placeholder.com/700x500?text=md+2x'
34+
x2: 'http://via.placeholder.com/700x500?text=md+2x',
3535
},
3636
{
3737
size: 'lg',
3838
x1: 'http://via.placeholder.com/700x400?text=lg+1x',
39-
x2: 'http://via.placeholder.com/1400x800?text=lg+2x'
40-
}
41-
]
39+
x2: 'http://via.placeholder.com/1400x800?text=lg+2x',
40+
},
41+
],
4242
};
4343

4444
beforeEach(async(() => {
4545
testBed = TestBed.configureTestingModule({
4646
schemas: [NO_ERRORS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA],
4747
declarations: [ImageLoaderComponent],
48-
imports: [InViewportModule.forRoot()]
48+
imports: [InViewportModule.forRoot()],
4949
});
5050

5151
testBed.compileComponents();
@@ -134,13 +134,13 @@ describe('ImageLoaderComponent', () => {
134134
component.img.nativeElement = { src: null };
135135
component.preloadImage();
136136
expect(component.preloadSrc).toEqual(
137-
'http://via.placeholder.com/150x350?text=xs+1x'
137+
'http://via.placeholder.com/150x350?text=xs+1x',
138138
);
139139

140140
component.supportsSrcSet = true;
141141
component.preloadImage();
142142
expect(component.preloadSrcset).toEqual(
143-
'http://via.placeholder.com/150x350?text=xs+1x 1x, http://via.placeholder.com/300x700?text=xs+2x 2x'
143+
'http://via.placeholder.com/150x350?text=xs+1x 1x, http://via.placeholder.com/300x700?text=xs+2x 2x',
144144
);
145145
});
146146

@@ -152,24 +152,24 @@ describe('ImageLoaderComponent', () => {
152152
component.img.nativeElement = { src: null };
153153
component.preloadImage();
154154
expect(component.preloadSrc).toEqual(
155-
'http://via.placeholder.com/150x350?text=xs+1x'
155+
'http://via.placeholder.com/150x350?text=xs+1x',
156156
);
157157

158158
component.onImagePreload();
159159
expect(component.src).toEqual(
160-
'http://via.placeholder.com/150x350?text=xs+1x'
160+
'http://via.placeholder.com/150x350?text=xs+1x',
161161
);
162162

163163
component.supportsSrcSet = true;
164164
component.loaded = false;
165165
component.preloadImage();
166166
expect(component.preloadSrcset).toEqual(
167-
'http://via.placeholder.com/150x350?text=xs+1x 1x, http://via.placeholder.com/300x700?text=xs+2x 2x'
167+
'http://via.placeholder.com/150x350?text=xs+1x 1x, http://via.placeholder.com/300x700?text=xs+2x 2x',
168168
);
169169

170170
component.onImagePreload();
171171
expect(component.srcset).toEqual(
172-
'http://via.placeholder.com/150x350?text=xs+1x 1x, http://via.placeholder.com/300x700?text=xs+2x 2x'
172+
'http://via.placeholder.com/150x350?text=xs+1x 1x, http://via.placeholder.com/300x700?text=xs+2x 2x',
173173
);
174174
});
175175

@@ -184,7 +184,7 @@ describe('ImageLoaderComponent', () => {
184184
expect(spy).toHaveBeenCalledWith({
185185
$event: event,
186186
src: component.src,
187-
srcset: component.srcset
187+
srcset: component.srcset,
188188
});
189189
});
190190

0 commit comments

Comments
 (0)