Skip to content

Commit d283371

Browse files
authored
chore: add prettier (#91)
Co-authored-by: Daniel Kimmich <[email protected]>
1 parent 1512637 commit d283371

File tree

79 files changed

+1389
-723
lines changed

Some content is hidden

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

79 files changed

+1389
-723
lines changed

.eslintrc.json

+3-9
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,13 @@
2121
"no-unused-vars": "off",
2222
"@typescript-eslint/no-unused-vars": "error",
2323
"@typescript-eslint/prefer-literal-enum-member": "off",
24-
"comma-dangle": [
25-
"error",
26-
"always-multiline"
27-
]
24+
"comma-dangle": ["error", "always-multiline"]
2825
}
2926
},
3027
{
3128
"files": "*.html",
32-
"extends": [
33-
"plugin:@angular-eslint/template/recommended"
34-
],
35-
"rules": {
36-
}
29+
"extends": ["plugin:@angular-eslint/template/recommended"],
30+
"rules": {}
3731
}
3832
]
3933
}

.github/ISSUE_TEMPLATE/bug_report.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
22
name: Bug report
33
about: Create a report to help us improve
4-
title: ''
4+
title: ""
55
labels: bug
66
assignees: json-derulo
7-
87
---
98

109
**Describe the bug**
1110
A clear and concise description of what the bug is.
1211

1312
**To Reproduce**
1413
Steps to reproduce the behavior:
14+
1515
1. Go to '...'
1616
2. Click on '....'
1717
3. Scroll down to '....'
@@ -21,9 +21,10 @@ Steps to reproduce the behavior:
2121
A clear and concise description of what you expected to happen.
2222

2323
**Versions**
24-
- OS: [e.g. iOS]
25-
- Browser [e.g. chrome, safari]
26-
- Version [e.g. 1.0.0]
24+
25+
- OS: [e.g. iOS]
26+
- Browser [e.g. chrome, safari]
27+
- Version [e.g. 1.0.0]
2728

2829
**Additional context**
2930
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/feature_request.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
---
22
name: Feature request
33
about: Suggest an idea for this project
4-
title: ''
5-
labels: ''
6-
assignees: ''
7-
4+
title: ""
5+
labels: ""
6+
assignees: ""
87
---
98

109
**Description**

.github/workflows/verify-build.yml

+15-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Verify build
22

33
on:
44
pull_request_target:
5-
types: [ opened, synchronize, reopened ]
5+
types: [opened, synchronize, reopened]
66

77
jobs:
88
build:
@@ -46,3 +46,17 @@ jobs:
4646

4747
- name: test
4848
run: npm run test -- --watch=false --browsers=ChromeHeadless
49+
50+
prettier:
51+
runs-on: ubuntu-20.04
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@v3
55+
with:
56+
ref: ${{ github.event.pull_request.head.sha }}
57+
58+
- name: install
59+
run: npm ci
60+
61+
- name: prettier
62+
run: npx prettier . --check

.vscode/extensions.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
22
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
3-
"recommendations": [
4-
"angular.ng-template"
5-
]
3+
"recommendations": ["angular.ng-template"]
64
}

README.md

+83-87
Large diffs are not rendered by default.

angular.json

+2-7
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@
2828
"builder": "@angular-devkit/build-angular:karma",
2929
"options": {
3030
"tsConfig": "projects/angular-ecmascript-intl/tsconfig.spec.json",
31-
"polyfills": [
32-
"zone.js",
33-
"zone.js/testing"
34-
]
31+
"polyfills": ["zone.js", "zone.js/testing"]
3532
}
3633
}
3734
}
@@ -53,9 +50,7 @@
5350
"outputPath": "dist/angular-intl-demo",
5451
"index": "projects/angular-intl-demo/src/index.html",
5552
"main": "projects/angular-intl-demo/src/main.ts",
56-
"polyfills": [
57-
"zone.js"
58-
],
53+
"polyfills": ["zone.js"],
5954
"tsConfig": "projects/angular-intl-demo/tsconfig.app.json",
6055
"inlineStyleLanguage": "scss",
6156
"assets": [

package-lock.json

+25-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"watch": "ng build --watch --configuration development",
1111
"test": "ng test --code-coverage=true",
1212
"lint": "eslint --ignore-path=.gitignore .",
13-
"release": "release-it"
13+
"release": "release-it",
14+
"prettier": "prettier . --write"
1415
},
1516
"private": true,
1617
"dependencies": {
@@ -54,6 +55,7 @@
5455
"karma-jasmine": "~5.1.0",
5556
"karma-jasmine-html-reporter": "~2.1.0",
5657
"ng-packagr": "~16.1.0",
58+
"prettier": "~3.0.0",
5759
"typescript": "~5.1.0"
5860
}
5961
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import {InjectionToken} from "@angular/core";
2-
import {IntlCountryPipeOptions} from "./intl-country.pipe";
1+
import { InjectionToken } from '@angular/core';
2+
import { IntlCountryPipeOptions } from './intl-country.pipe';
33

4-
export const INTL_COUNTRY_PIPE_DEFAULT_OPTIONS = new InjectionToken<Omit<IntlCountryPipeOptions, 'locale'>>('IntlCountryPipeDefaultOptions');
4+
export const INTL_COUNTRY_PIPE_DEFAULT_OPTIONS = new InjectionToken<
5+
Omit<IntlCountryPipeOptions, 'locale'>
6+
>('IntlCountryPipeDefaultOptions');

projects/angular-ecmascript-intl/src/lib/country/intl-country.pipe.spec.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {IntlCountryPipe} from './intl-country.pipe';
2-
import {TestBed} from "@angular/core/testing";
3-
import {INTL_LOCALES} from "../locale";
4-
import {INTL_COUNTRY_PIPE_DEFAULT_OPTIONS} from "./intl-country-pipe-default-options";
1+
import { IntlCountryPipe } from './intl-country.pipe';
2+
import { TestBed } from '@angular/core/testing';
3+
import { INTL_LOCALES } from '../locale';
4+
import { INTL_COUNTRY_PIPE_DEFAULT_OPTIONS } from './intl-country-pipe-default-options';
55

66
describe('IntlCountryPipe', () => {
77
let testUnit: IntlCountryPipe;
@@ -58,7 +58,7 @@ describe('IntlCountryPipe', () => {
5858
});
5959

6060
it('should fall back to the browser default locale', () => {
61-
TestBed.configureTestingModule({providers: [IntlCountryPipe]});
61+
TestBed.configureTestingModule({ providers: [IntlCountryPipe] });
6262

6363
const result1 = TestBed.inject(IntlCountryPipe).transform('US');
6464
const result2 = new IntlCountryPipe(navigator.language).transform('US');
@@ -86,7 +86,9 @@ describe('IntlCountryPipe', () => {
8686
});
8787
testUnit = TestBed.inject(IntlCountryPipe);
8888

89-
expect(testUnit.transform('DE', {type: 'language'})).toEqual('Deutschland');
89+
expect(testUnit.transform('DE', { type: 'language' })).toEqual(
90+
'Deutschland',
91+
);
9092
});
9193
});
9294

@@ -102,6 +104,8 @@ describe('IntlCountryPipe', () => {
102104
});
103105
testUnit = TestBed.inject(IntlCountryPipe);
104106

105-
expect(testUnit.transform('US', {locale: 'de-DE'})).toEqual('Vereinigte Staaten');
107+
expect(testUnit.transform('US', { locale: 'de-DE' })).toEqual(
108+
'Vereinigte Staaten',
109+
);
106110
});
107111
});
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,49 @@
1-
import {Inject, Optional, Pipe, PipeTransform} from '@angular/core';
2-
import {INTL_LOCALES} from "../locale";
3-
import {INTL_COUNTRY_PIPE_DEFAULT_OPTIONS} from "./intl-country-pipe-default-options";
4-
import {IntlPipeOptions} from "../intl-pipe-options";
1+
import { Inject, Optional, Pipe, PipeTransform } from '@angular/core';
2+
import { INTL_LOCALES } from '../locale';
3+
import { INTL_COUNTRY_PIPE_DEFAULT_OPTIONS } from './intl-country-pipe-default-options';
4+
import { IntlPipeOptions } from '../intl-pipe-options';
55

6-
export type IntlCountryPipeOptions = Omit<Partial<Intl.DisplayNamesOptions>, 'languageDisplay'> & IntlPipeOptions;
6+
export type IntlCountryPipeOptions = Omit<
7+
Partial<Intl.DisplayNamesOptions>,
8+
'languageDisplay'
9+
> &
10+
IntlPipeOptions;
711

812
@Pipe({
913
name: 'intlCountry',
1014
standalone: true,
1115
})
1216
export class IntlCountryPipe implements PipeTransform {
17+
constructor(
18+
@Optional()
19+
@Inject(INTL_LOCALES)
20+
readonly locale?: string | string[] | null,
21+
@Optional()
22+
@Inject(INTL_COUNTRY_PIPE_DEFAULT_OPTIONS)
23+
readonly defaultOptions?: Omit<IntlCountryPipeOptions, 'locale'> | null,
24+
) {}
1325

14-
constructor(@Optional() @Inject(INTL_LOCALES) readonly locale?: string | string[] | null,
15-
@Optional() @Inject(INTL_COUNTRY_PIPE_DEFAULT_OPTIONS) readonly defaultOptions?: Omit<IntlCountryPipeOptions, 'locale'> | null) {
16-
}
17-
18-
transform(value: string | null | undefined, options?: IntlCountryPipeOptions): string | null {
26+
transform(
27+
value: string | null | undefined,
28+
options?: IntlCountryPipeOptions,
29+
): string | null {
1930
if (!value) {
2031
return null;
2132
}
2233

23-
const {locale, ...intlOptions} = options ?? {};
34+
const { locale, ...intlOptions } = options ?? {};
2435

2536
try {
26-
return new Intl.DisplayNames(locale ?? this.locale ?? undefined, {
27-
...this.defaultOptions, ...intlOptions,
28-
type: 'region',
29-
}).of(value) ?? null;
37+
return (
38+
new Intl.DisplayNames(locale ?? this.locale ?? undefined, {
39+
...this.defaultOptions,
40+
...intlOptions,
41+
type: 'region',
42+
}).of(value) ?? null
43+
);
3044
} catch (e) {
3145
console.error('Error while transforming the country', e);
3246
return null;
3347
}
3448
}
35-
3649
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import {InjectionToken} from "@angular/core";
2-
import {IntlCurrencyPipeOptions} from "./intl-currency.pipe";
1+
import { InjectionToken } from '@angular/core';
2+
import { IntlCurrencyPipeOptions } from './intl-currency.pipe';
33

4-
export const INTL_CURRENCY_PIPE_DEFAULT_OPTIONS = new InjectionToken<Omit<IntlCurrencyPipeOptions, 'locale'>>('IntlCurrencyPipeDefaultOptions');
4+
export const INTL_CURRENCY_PIPE_DEFAULT_OPTIONS = new InjectionToken<
5+
Omit<IntlCurrencyPipeOptions, 'locale'>
6+
>('IntlCurrencyPipeDefaultOptions');

0 commit comments

Comments
 (0)