Skip to content

Commit

Permalink
eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
tse018 committed Sep 22, 2023
1 parent 930138e commit c2371e9
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 75 deletions.
58 changes: 46 additions & 12 deletions packages/angular/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"root": true,
"reportUnusedDisableDirectives": true,
"ignorePatterns": [
"projects/**/*"
],
Expand All @@ -10,24 +11,57 @@
],
"parserOptions": {
"project": [
"tsconfig.json",
"e2e/tsconfig.json"
"tsconfig.json"
],
"createDefaultProgram": true
"createDefaultProgram": true,
"warnOnUnsupportedTypeScriptVersion": true
},
"plugins": [
"eslint-plugin-import",
"eslint-plugin-prefer-arrow",
"eslint-plugin-promise",
"eslint-plugin-rxjs",
"eslint-plugin-rxjs-angular",
"eslint-plugin-tsdoc",
"eslint-plugin-unicorn"
],
"extends": [
"plugin:@angular-eslint/ng-cli-compat",
"plugin:@angular-eslint/ng-cli-compat--formatting-add-on",
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates",
"airbnb-typescript/base"
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:promise/recommended",
"plugin:rxjs/recommended",
"plugin:unicorn/recommended"
],
"rules": {
"import/export": 0,
"import/prefer-default-export": 0,
"import/no-extraneous-dependencies": 0,
"@typescript-eslint/no-unused-vars": 0,
"class-methods-use-this": 0,
"@typescript-eslint/member-ordering": 0
"@typescript-eslint/no-unused-vars": [
"error",
{
"varsIgnorePattern": "^_",
"argsIgnorePattern": "^_"
}
],
"class-methods-use-this": "off",
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": ["**/*.spec.ts"],
"packageDir": "./" // Needed for angular library support
}
],
"tsdoc/syntax": "warn",
"unicorn/filename-case": "off", // We are naming files with capitals
// 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.
"unicorn/prevent-abbreviations": "off"
},
"settings": {
"import/resolver": {
"typescript": {
"alwaysTryTypes": true // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
}
}
}
},
{
Expand Down
1 change: 1 addition & 0 deletions packages/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"eslint": "^8.23.0",
"eslint-config-airbnb-typescript": "^16.0.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-prefer-arrow": "^1.2.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,6 @@ import { TranslationService } from './translation.service';
styles: [],
})

/**
* A translation component
*
* @param {string} str
* @param {string=} key
* @param {string=} context
* @param {string=} comment
* @param {number=} charlimit
* @param {string=} tags
* @param {boolean=} escapeVars
* @param {boolean=} inline
* @param {boolean=} sanitize
* @param {Object=} vars
*/
export class TComponent implements OnInit, OnDestroy, OnChanges {
@Input()
str = '';
Expand Down Expand Up @@ -91,12 +77,6 @@ export class TComponent implements OnInit, OnDestroy, OnChanges {

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

/**
* Constructor
*
* @param translationService
* @param instance
*/
constructor(protected translationService: TranslationService,
protected instance: TXInstanceComponent) {
this.onLocaleChange = this.localeChanged.subscribe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,7 @@ import { TranslationService } from './translation.service';
encapsulation: ViewEncapsulation.None,
})

/**
* A translation component with escaped variables
*
* @param {string} str
* @param {string=} key
* @param {string=} context
* @param {string=} comment
* @param {number=} charlimit
* @param {string=} tags
* @param {boolean=} escapeVars
* @param {boolean=} inline
* @param {Object=} vars
*/
export class UTComponent extends TComponent {
/**
* Constructor
*
* @param translationService
* @param instance
*/
constructor(
translationService: TranslationService,
protected override instance: TXInstanceComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-useless-constructor */
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Observable, ReplaySubject } from 'rxjs';

Expand All @@ -12,14 +11,6 @@ import {TxNative} from "@transifex/native";
`,
})

/**
* A TX Native instance selector component
*
* @param {string} alias
* @param {string} token
* @param {boolean} controlled
* @param {EventEmitter} instanceReady
*/
export class TXInstanceComponent implements OnInit {
@Input() alias = '';

Expand All @@ -39,11 +30,6 @@ export class TXInstanceComponent implements OnInit {
// The instance
private instance?: TxNative;

/**
* Constructor
*
* @param translationService
*/
constructor(private translationService: TranslationService) {}

async ngOnInit(): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable prefer-arrow/prefer-arrow-functions */
import { Component } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { tx } from '@transifex/native';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnDestroy } from '@angular/core';
import {Component, DebugElement } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { ReplaySubject } from 'rxjs';
Expand All @@ -12,18 +12,14 @@ describe('LoadTranslationsDirective', () => {
<div [txLoadTranslations]="'tag1'"></div>
`,
})
class TestComponent implements OnDestroy {
ngOnDestroy() {}
}
class TestComponent {}

let localeChangedSubject: ReplaySubject<string>;

let directives: any;
let directives: DebugElement[];
let fixture: ComponentFixture<TestComponent>;
let service: TranslationService;



beforeEach(() => {
fixture = TestBed.configureTestingModule({
declarations: [LoadTranslationsDirective, TestComponent],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"target": "es2015",
"target": "es2020",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"types": [ "node" ],
"typeRoots": [ "../node_modules/@types" ],
"lib": [
"dom",
"es2018"
"es2020"
]
},
"angularCompilerOptions": {
Expand Down

0 comments on commit c2371e9

Please sign in to comment.