Skip to content

Commit 88b2fcf

Browse files
committed
Angular v14 update
1 parent 9621723 commit 88b2fcf

26 files changed

+438
-643
lines changed

packages/angular/.eslintrc.json

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"root": true,
3+
"reportUnusedDisableDirectives": true,
34
"ignorePatterns": [
45
"projects/**/*"
56
],
@@ -10,24 +11,57 @@
1011
],
1112
"parserOptions": {
1213
"project": [
13-
"tsconfig.json",
14-
"e2e/tsconfig.json"
14+
"tsconfig.json"
1515
],
16-
"createDefaultProgram": true
16+
"createDefaultProgram": true,
17+
"warnOnUnsupportedTypeScriptVersion": true
1718
},
19+
"plugins": [
20+
"eslint-plugin-import",
21+
"eslint-plugin-prefer-arrow",
22+
"eslint-plugin-promise",
23+
"eslint-plugin-rxjs",
24+
"eslint-plugin-rxjs-angular",
25+
"eslint-plugin-tsdoc",
26+
"eslint-plugin-unicorn"
27+
],
1828
"extends": [
19-
"plugin:@angular-eslint/ng-cli-compat",
20-
"plugin:@angular-eslint/ng-cli-compat--formatting-add-on",
29+
"plugin:@angular-eslint/recommended",
2130
"plugin:@angular-eslint/template/process-inline-templates",
22-
"airbnb-typescript/base"
31+
"plugin:@typescript-eslint/recommended",
32+
"plugin:import/recommended",
33+
"plugin:import/typescript",
34+
"plugin:promise/recommended",
35+
"plugin:rxjs/recommended",
36+
"plugin:unicorn/recommended"
2337
],
2438
"rules": {
25-
"import/export": 0,
26-
"import/prefer-default-export": 0,
27-
"import/no-extraneous-dependencies": 0,
28-
"@typescript-eslint/no-unused-vars": 0,
29-
"class-methods-use-this": 0,
30-
"@typescript-eslint/member-ordering": 0
39+
"@typescript-eslint/no-unused-vars": [
40+
"error",
41+
{
42+
"varsIgnorePattern": "^_",
43+
"argsIgnorePattern": "^_"
44+
}
45+
],
46+
"class-methods-use-this": "off",
47+
"import/no-extraneous-dependencies": [
48+
"error",
49+
{
50+
"devDependencies": ["**/*.spec.ts"],
51+
"packageDir": "./" // Needed for angular library support
52+
}
53+
],
54+
"tsdoc/syntax": "warn",
55+
"unicorn/filename-case": "off", // We are naming files with capitals
56+
// I think some of these are silly. `e` is bad, but `err` and `exc` are decent. `user of users` is confusing, `usr of users` is safer.
57+
"unicorn/prevent-abbreviations": "off"
58+
},
59+
"settings": {
60+
"import/resolver": {
61+
"typescript": {
62+
"alwaysTryTypes": true // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
63+
}
64+
}
3165
}
3266
},
3367
{

packages/angular/angular.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
"production": {
2020
"tsConfig": "projects/tx-native-angular-sdk/tsconfig.lib.prod.json"
2121
},
22-
"development": {}
22+
"development": {}
2323
},
24-
"defaultConfiguration": "production"
24+
"defaultConfiguration": "production"
2525
},
2626
"test": {
2727
"builder": "@angular-devkit/build-angular:karma",

packages/angular/package.json

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,63 +12,72 @@
1212
"translation",
1313
"angular"
1414
],
15-
"author": "Transifex",
1615
"homepage": "https://github.com/transifex/transifex-javascript/tree/master/packages/angular",
17-
"repository": "git://github.com/transifex/transifex-javascript.git",
16+
"bugs": {
17+
"url": "https://github.com/transifex/transifex-javascript/issues"
18+
},
19+
"repository": {
20+
"type": "git",
21+
"url": "git+https://github.com/transifex/transifex-javascript.git"
22+
},
1823
"license": "Apache-2.0",
24+
"author": "Transifex",
1925
"scripts": {
20-
"ng": "ng",
21-
"start": "ng serve",
2226
"build": "ng build --configuration production",
23-
"test": "ng test",
2427
"lint": "ng lint",
25-
"publish-npm": "cd dist/tx-native-angular-sdk && npm publish"
28+
"ng": "ng",
29+
"publish-npm": "cd dist/tx-native-angular-sdk && npm publish",
30+
"start": "ng serve",
31+
"test": "ng test"
2632
},
2733
"private": true,
2834
"dependencies": {
29-
"@angular/animations": "~13.0.2",
30-
"@angular/common": "~13.0.2",
31-
"@angular/compiler": "~13.0.2",
32-
"@angular/core": "~13.0.2",
33-
"@angular/forms": "~13.0.2",
34-
"@angular/platform-browser": "~13.0.2",
35-
"@angular/platform-browser-dynamic": "~13.0.2",
36-
"@angular/router": "~13.0.2",
35+
"@angular/animations": "~14.3.0",
36+
"@angular/common": "~14.3.0",
37+
"@angular/compiler": "~14.3.0",
38+
"@angular/core": "~14.3.0",
39+
"@angular/forms": "~14.3.0",
40+
"@angular/platform-browser": "^14.3.0",
41+
"@angular/platform-browser-dynamic": "^14.3.0",
42+
"@angular/router": "~14.3.0",
3743
"@transifex/native": "^5.4.0",
3844
"rxjs": "~6.6.0",
3945
"tslib": "^2.0.0",
4046
"zone.js": "~0.11.4"
4147
},
4248
"devDependencies": {
43-
"@angular-devkit/architect": "^0.1300.3",
44-
"@angular-devkit/build-angular": "~13.0.3",
45-
"@angular-eslint/builder": "^13.0.1",
46-
"@angular-eslint/eslint-plugin": "^13.0.1",
47-
"@angular-eslint/eslint-plugin-template": "^13.0.1",
48-
"@angular-eslint/schematics": "13.0.1",
49-
"@angular-eslint/template-parser": "^13.0.1",
50-
"@angular/cli": "~13.0.3",
51-
"@angular/compiler-cli": "~13.0.2",
52-
"@types/jasmine": "^3.10.2",
53-
"@types/node": "^12.20.6",
54-
"@typescript-eslint/eslint-plugin": "^5.4.0",
55-
"@typescript-eslint/parser": "^5.4.0",
56-
"codelyzer": "^6.0.0",
57-
"eslint": "^8.2.0",
49+
"@angular-devkit/architect": "^0.1402.11",
50+
"@angular-devkit/build-angular": "^14.2.11",
51+
"@angular-eslint/builder": "^14.4.0",
52+
"@angular-eslint/eslint-plugin": "^14.4.0",
53+
"@angular-eslint/eslint-plugin-template": "^14.4.0",
54+
"@angular-eslint/schematics": "14.4.0",
55+
"@angular-eslint/template-parser": "^14.4.0",
56+
"@angular/cli": "^14.2.11",
57+
"@angular/compiler-cli": "^14.3.0",
58+
"@types/jasmine": "~4.0.0",
59+
"@types/node": "^16.18.23",
60+
"@typescript-eslint/eslint-plugin": "^5.36.2",
61+
"@typescript-eslint/parser": "^5.36.2",
62+
"eslint": "^8.23.0",
5863
"eslint-config-airbnb-typescript": "^16.0.0",
64+
"eslint-import-resolver-typescript": "^3.5.5",
5965
"eslint-plugin-import": "^2.25.3",
60-
"eslint-plugin-jsdoc": "^37.0.3",
6166
"eslint-plugin-prefer-arrow": "^1.2.3",
62-
"jasmine-core": "^3.10.1",
67+
"eslint-plugin-promise": "^6.1.1",
68+
"eslint-plugin-rxjs": "^5.0.3",
69+
"eslint-plugin-rxjs-angular": "^2.0.0",
70+
"eslint-plugin-tsdoc": "^0.2.17",
71+
"eslint-plugin-unicorn": "^46.0.0",
72+
"jasmine-core": "~4.3.0",
6373
"jasmine-spec-reporter": "^7.0.0",
64-
"karma": "~6.3.9",
65-
"karma-chrome-launcher": "~3.1.0",
66-
"karma-coverage": "~2.0.3",
67-
"karma-jasmine": "~4.0.0",
68-
"ng-packagr": "^13.0.6",
69-
"protractor": "~7.0.0",
74+
"karma": "~6.4.1",
75+
"karma-chrome-launcher": "~3.1.1",
76+
"karma-coverage": "~2.2.0",
77+
"karma-jasmine": "~5.1.0",
78+
"karma-jasmine-html-reporter": "^2.1.0",
79+
"ng-packagr": "^14.2.2",
7080
"ts-node": "~8.3.0",
71-
"tslint": "~6.1.0",
72-
"typescript": "~4.4.4"
81+
"typescript": "~4.6.4"
7382
}
7483
}

packages/angular/projects/tx-native-angular-sdk/.eslintrc.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,19 @@
1717
},
1818
"rules": {
1919
"@angular-eslint/component-selector": [
20+
"off", // We are not following the angular styleguide to match other implementations
21+
{
22+
"prefix": "tx",
23+
"style": "kebab-case",
24+
"type": "element"
25+
}
26+
],
27+
"@angular-eslint/directive-selector": [
2028
"error",
2129
{
22-
"type": "element",
23-
"prefix": "tx"
30+
"prefix": "tx",
31+
"style": "camelCase",
32+
"type": "attribute"
2433
}
2534
]
2635
}

packages/angular/projects/tx-native-angular-sdk/karma.conf.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,45 @@ module.exports = function (config) {
99
require('karma-jasmine'),
1010
require('karma-chrome-launcher'),
1111
require('karma-coverage'),
12+
require('karma-jasmine-html-reporter'),
1213
require('@angular-devkit/build-angular/plugins/karma')
1314
],
1415
client: {
1516
jasmine: {
16-
// you can add configuration options for Jasmine here
17-
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
18-
// for example, you can disable the random execution with `random: false`
19-
// or set a specific seed with `seed: 4321`
17+
failSpecWithNoExpectations: true,
2018
},
21-
clearContext: false // leave Jasmine Spec Runner output visible in browser
19+
clearContext: false
2220
},
2321
jasmineHtmlReporter: {
24-
suppressAll: true // removes the duplicated traces
22+
suppressAll: true
2523
},
2624
coverageReporter: {
2725
dir: require('path').join(__dirname, '../../coverage/tx-native-angular-sdk'),
2826
subdir: '.',
2927
reporters: [
3028
{ type: 'html' },
29+
{ type: 'lcovonly' },
3130
{ type: 'text-summary' }
3231
]
3332
},
34-
reporters: ['progress'],
33+
reporters: ['progress', 'kjhtml'],
3534
port: 9876,
3635
colors: true,
3736
logLevel: config.LOG_INFO,
3837
autoWatch: true,
3938
browsers: ['ChromeHeadlessNoSandbox'],
39+
reportSlowerThan: 250,
4040
customLaunchers: {
41+
AutomatedChrome: {
42+
base: 'Chrome',
43+
flags: ['--enable-automation'],
44+
},
4145
ChromeHeadlessNoSandbox: {
4246
base: 'ChromeHeadless',
43-
flags: [
44-
'--no-sandbox'
45-
],
47+
flags: ['--no-sandbox'],
4648
},
4749
},
48-
// Continuous Integration mode
49-
// if true, Karma captures browsers, runs the tests and exits
50-
singleRun: true,
51-
restartOnFileChange: true
50+
singleRun: true, // Moved this property outside the customLaunchers object
51+
restartOnFileChange: true, // Moved this property outside the customLaunchers object
5252
});
5353
};

packages/angular/projects/tx-native-angular-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
"peerDependencies": {
2020
"@angular/common": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
2121
"@angular/core": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
22-
"@transifex/native": "^5.0.0"
22+
"@transifex/native": "^5.4.0"
2323
}
2424
}

packages/angular/projects/tx-native-angular-sdk/src/lib/T.component.ts

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
1+
import { Component, Input, OnChanges, OnDestroy, OnInit } from '@angular/core';
22
import { Observable, Subscription } from 'rxjs';
33

44
import { TXInstanceComponent } from './instance.component';
55
import { ITranslateParams } from './interfaces';
66
import { TranslationService } from './translation.service';
77

8+
/**
9+
* A translation component
10+
**/
811
@Component({
912
selector: 'T',
1013
template: `
@@ -14,20 +17,7 @@ import { TranslationService } from './translation.service';
1417
styles: [],
1518
})
1619

17-
/**
18-
* A translation component
19-
*
20-
* @param {string} str
21-
* @param {string=} key
22-
* @param {string=} context
23-
* @param {string=} comment
24-
* @param {number=} charlimit
25-
* @param {string=} tags
26-
* @param {boolean=} escapeVars
27-
* @param {boolean=} inline
28-
* @param {boolean=} sanitize
29-
* @param {Object=} vars
30-
*/
20+
3121
export class TComponent implements OnInit, OnDestroy, OnChanges {
3222
@Input()
3323
str = '';
@@ -91,12 +81,6 @@ export class TComponent implements OnInit, OnDestroy, OnChanges {
9181

9282
private actualVars: Record<string, unknown> = {};
9383

94-
/**
95-
* Constructor
96-
*
97-
* @param translationService
98-
* @param instance
99-
*/
10084
constructor(protected translationService: TranslationService,
10185
protected instance: TXInstanceComponent) {
10286
this.onLocaleChange = this.localeChanged.subscribe(
@@ -123,22 +107,21 @@ export class TComponent implements OnInit, OnDestroy, OnChanges {
123107
* Component destruction
124108
*/
125109
ngOnDestroy() {
126-
if (typeof this.onLocaleChange !== 'undefined') {
110+
if (this.onLocaleChange !== undefined) {
127111
this.onLocaleChange.unsubscribe();
128112
this.onLocaleChange = undefined;
129113
}
130-
if (typeof this.onTranslationsFetch !== 'undefined') {
114+
115+
if (this.onTranslationsFetch !== undefined) {
131116
this.onTranslationsFetch.unsubscribe();
132117
this.onTranslationsFetch = undefined;
133118
}
134119
}
135120

136121
/**
137122
* Input parameters change detector
138-
*
139-
* @param changes
140123
*/
141-
ngOnChanges(changes: SimpleChanges) {
124+
ngOnChanges() {
142125
this.translate();
143126
}
144127

0 commit comments

Comments
 (0)