Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#22 tslint eslint migration #36

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
ae66f81
build(root): update workflow and eslint
vitaliibendyk Jul 2, 2024
8bebbd9
feat(*): remove tslint, add .eslintrc.cjs files
vitaliibendyk Jul 8, 2024
ad6c76c
feat(*): replace tslint to eslint
vitaliibendyk Jul 29, 2024
94a6d6d
feat(root): migrate to npm
vitaliibendyk Aug 12, 2024
e6c4786
feat(root): tslint -> eslint and yarn -> npm migrations
vitaliibendyk Aug 13, 2024
7514442
Merge branch 'refs/heads/main' into #22-tslint-eslint-migration
vitaliibendyk Aug 13, 2024
ee1b124
Merge branch 'refs/heads/main' into #22-tslint-eslint-migration
vitaliibendyk Aug 26, 2024
8225692
Merge remote-tracking branch 'origin/#22-tslint-eslint-migration' int…
vitaliibendyk Aug 26, 2024
64c7e18
fix(*): update sc deps and lint scripts
vitaliibendyk Aug 26, 2024
197606f
fix(*): add essential ts-ignores
vitaliibendyk Aug 26, 2024
72cffab
build(release): next version [skip_build]
actions-user Aug 26, 2024
26d0f73
fix(*): revert version of --fix flag command and prettier scripts
vitaliibendyk Aug 26, 2024
0534f39
Merge remote-tracking branch 'origin/#22-tslint-eslint-migration' int…
vitaliibendyk Aug 26, 2024
b003303
fix(*): update lock file
vitaliibendyk Aug 26, 2024
b613172
build(release): next version [skip_build]
actions-user Aug 26, 2024
4867aeb
fix(aws): update ngx-core
vitaliibendyk Aug 26, 2024
d4eb564
Merge remote-tracking branch 'origin/#22-tslint-eslint-migration' int…
vitaliibendyk Aug 26, 2024
aa9741e
fix(aws): update ngx-core
vitaliibendyk Aug 26, 2024
458ceae
build(release): next version [skip_build]
actions-user Aug 26, 2024
803591d
fix(aws): update nx-components version
vitaliibendyk Aug 26, 2024
77ebfcd
Merge remote-tracking branch 'origin/#22-tslint-eslint-migration' int…
vitaliibendyk Aug 26, 2024
d065241
fix(root): update lock file
vitaliibendyk Aug 26, 2024
6d1ed18
build(release): next version [skip_build]
actions-user Aug 26, 2024
70d927c
fix(components): update ngx-core
vitaliibendyk Aug 27, 2024
48d2c6c
build(release): next version [skip_build]
actions-user Aug 27, 2024
9133304
refactor(*): fix lint:ci command in libs/core, remove ts-ignore comment
vitaliibendyk Aug 29, 2024
137eb85
build(release): next version [skip_build]
actions-user Aug 29, 2024
6834feb
refactor(*): solve review comments
vitaliibendyk Oct 21, 2024
871ec8f
fix(*): package-lock.json
vitaliibendyk Oct 21, 2024
504d32c
build(release): next version [skip_build]
actions-user Oct 21, 2024
5bec34b
feat(*): extend eslintrc files
vitaliibendyk Oct 24, 2024
69e49dc
Merge remote-tracking branch 'origin/#22-tslint-eslint-migration' int…
vitaliibendyk Oct 24, 2024
51bdf62
fix(*): update package-lock.json
vitaliibendyk Oct 24, 2024
02fe8af
build(release): next version [skip_build]
actions-user Oct 24, 2024
5423000
fix(*): remove unnecessary eslint rules
vitaliibendyk Nov 4, 2024
6b6310a
fix(*): up tp date package-lock.json
vitaliibendyk Nov 4, 2024
b488910
build(release): next version [skip_build]
actions-user Nov 4, 2024
1216b96
fix(libs): solve review comments
vitaliibendyk Dec 12, 2024
5e46d65
build(release): next version [skip_build]
actions-user Dec 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const typescriptEslint = require('@shiftcode/eslint-config-recommended')

module.exports = {
...typescriptEslint,
root: true,
}
1 change: 0 additions & 1 deletion apps/styleguide/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ bootstrapApplication(AppComponent, {
provideSgConfig(),
],
})
// tslint:disable-next-line:no-console
.catch((err) => console.error(err))
16 changes: 0 additions & 16 deletions apps/styleguide/tslint.yml

This file was deleted.

1 change: 1 addition & 0 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"libs/*"
],
"version": "independent",
"npmClient": "npm",
vitaliibendyk marked this conversation as resolved.
Show resolved Hide resolved
"command": {
"version": {
"allowBranch": "*",
Expand Down
26 changes: 26 additions & 0 deletions libs/aws/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
// automatically extends root eslint-config (which extends @shiftcode/eslint-config-recommended for TS)
extends: ['@shiftcode/eslint-config-recommended/ng-config'],
overrides: [
{
files: ['*.ts'],
rules: {
'import/no-internal-modules': ['error', { allow: ['aws-cdk-lib/*', '@shiftcode/iac-helper/*', 'rxjs/operators'] }],
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'property',
format: ['camelCase', 'UPPER_CASE'],
},
],
},
},
],

parserOptions: {
project: [
"./tsconfig.lib.json",
"./tsconfig.spec.json"
]
}
}
2 changes: 1 addition & 1 deletion libs/aws/.lintstagedrc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# we use tslint instead of ng lint, because we can't use --project (tsconfig specifying files with include, exclude )
# we use eslint instead of ng lint, because we can't use --project (tsconfig specifying files with include, exclude )
# and --files argument pointing to other files
src/{**/,}!(*.+(spec|test)).ts:
- npm run prettier:staged
Expand Down
12 changes: 6 additions & 6 deletions libs/aws/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "@shiftcode/ngx-aws",
"version": "6.0.0",
"version": "6.1.0-pr22.8",
"repository": "https://github.com/shiftcode/sc-ng-commons-public",
"license": "MIT",
"author": "shiftcode GmbH <[email protected]>",
"sideEffects": false,
"scripts": {
"lint": "npm run lint:lib -- --fix && npm run lint:test -- --fix",
"lint:ci": "npm run lint:lib && npm run lint:test",
"lint:lib": "tslint --format codeFrame --project ./tsconfig.lib.json",
"lint:test": "tslint --format codeFrame --project ./tsconfig.spec.json",
"lint": "eslint ./src -- --fix --cache",
"lint:ci": "npm run lint:lib",
"lint:lib": "eslint ./src",
"lint:staged": "eslint ./src -- --fix --cache",
"prettier": "prettier --write --config ../../.prettierrc.yml 'src/**/*.ts'",
"prettier:staged": "prettier --write --config ../../.prettierrc.yml"
},
Expand All @@ -21,7 +21,7 @@
"@angular/core": "^18.0.0",
"@aws-sdk/client-cloudwatch-logs": "^3.27.0",
"@aws-sdk/types": "^3.0.0",
"@shiftcode/ngx-core": "^6.0.0 || ^6.0.0-pr28",
"@shiftcode/ngx-core": "^6.0.0 || ^6.1.0-pr22.1",
"@shiftcode/utilities": "^3.0.0",
"rxjs": "^6.5.3 || ^7.4.0"
}
Expand Down
2 changes: 1 addition & 1 deletion libs/aws/src/lib/cloudwatch-logger/cloud-watch.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tslint:disable:no-console
/* eslint-disable no-console */
import { Inject, Injectable, Optional } from '@angular/core'
import {
CloudWatchLogsClient,
Expand Down
1 change: 1 addition & 0 deletions libs/aws/src/lib/cloudwatch-logger/is-error.function.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DataAlreadyAcceptedException, InvalidSequenceTokenException } from '@aws-sdk/client-cloudwatch-logs'
import { SmithyException } from '@aws-sdk/types/dist/types/shapes'

// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
export function isError(value: any | unknown): value is { name: string; message: string } {
vitaliibendyk marked this conversation as resolved.
Show resolved Hide resolved
return (
value instanceof Error || (typeof value === 'object' && value !== null && 'name' in value && 'message' in value)
Expand Down
7 changes: 0 additions & 7 deletions libs/aws/tslint.yml

This file was deleted.

64 changes: 64 additions & 0 deletions libs/components/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
module.exports = {
vitaliibendyk marked this conversation as resolved.
Show resolved Hide resolved
// automatically extends root eslint-config (which extends @shiftcode/eslint-config-recommended for TS)
extends: ['@shiftcode/eslint-config-recommended/ng-config'],
overrides: [
{
plugins: ['@shiftcode/rules'],
files: ['*.ts'],
rules: {
'import/no-internal-modules': ['error', { allow: ['rxjs/operators', '@angular/**/*'] }],
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'property',
format: ['camelCase', 'UPPER_CASE'],
leadingUnderscore: 'allow'
},
{
selector: "objectLiteralProperty",
format: null,
filter: {
regex: '^(\\[.*\\]|\\(.*\\)|aria-.*)$',
match: true
}
},
],
'@shiftcode/rules/import-denylist': [
'error', {
patterns: [
/\.\/(models|static|core|shared)\/.*/,
/src\/.*/
],
},
],
},
},
{
files: ['*.html'],
rules: {
'@angular-eslint/template/no-negated-async': 'off',
},
},
{
files: ['*.js', '*.mjs', '*.cjs'],
rules: {
'no-undef': 'off',
},
},
],

parserOptions: {
project: [
"./tsconfig.lib.json",
"./tsconfig.spec.json"
],
tsconfigRootDir: __dirname,
ecmaVersion: 'latest',
sourceType: 'module',
env: {
browser: true,
node: true,
es6: true,
},
},
}
6 changes: 3 additions & 3 deletions libs/components/.lintstagedrc.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# we use tslint instead of ng lint, because we can't use --project (tsconfig specifying files with include, exclude )
# we use eslint instead of ng lint, because we can't use --project (tsconfig specifying files with include, exclude )
# and --files argument pointing to other files
src/{**/,}!(*.+(spec|test)).ts:
- npm run prettier:staged
- npm run lint:lib -- --fix
- npm run lint:src -- --fix
# test folder and specs
test/{**/,}*.ts,src/{**/,}*.+(spec|test).ts:
- npm run prettier:staged
- npm run lint:test -- --fix
- npm run lint:test
# all html files
src/**/*.html:
- npm run prettier:staged
Expand Down
12 changes: 6 additions & 6 deletions libs/components/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "@shiftcode/ngx-components",
"version": "6.1.0",
"version": "6.1.0-pr22.7",
"repository": "https://github.com/shiftcode/sc-ng-commons-public",
"license": "MIT",
"author": "shiftcode GmbH <[email protected]>",
"sideEffects": false,
"scripts": {
"lint": "npm run lint:lib -- --fix && npm run lint:test -- --fix",
"lint:ci": "npm run lint:lib && npm run lint:test",
"lint:lib": "tslint --format codeFrame --project ./tsconfig.lib.json",
"lint:test": "tslint --format codeFrame --project ./tsconfig.spec.json",
"lint:ci": "npm run lint:lib",
"lint:lib": "eslint ./src",
"lint:src": "eslint ./src --fix --cache",
"lint:test": "eslint ./test",
"prettier": "prettier --write --config ../../.prettierrc.yml 'src/**/*.ts'",
"prettier:staged": "prettier --write --config ../../.prettierrc.yml"
},
Expand All @@ -23,7 +23,7 @@
"@angular/core": "^18.0.0",
"@angular/forms": "^18.0.0",
"@angular/router": "^18.0.0",
"@shiftcode/ngx-core": "^6.0.0 || ^6.0.0-pr28",
"@shiftcode/ngx-core": "^6.0.0 || ^6.1.0-pr22.5",
"rxjs": "^6.5.3 || ^7.4.0"
}
}
1 change: 0 additions & 1 deletion libs/components/src/lib/button/button.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// tslint:disable:no-host-metadata-property
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is eslint not complaining about that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import { Component, EventEmitter, HostListener, Output } from '@angular/core'

/**
Expand Down
15 changes: 2 additions & 13 deletions libs/components/src/lib/click-outside/click-outside.directive.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
import {
Directive,
ElementRef,
EventEmitter,
inject,
Input,
OnChanges,
OnDestroy,
Output,
SimpleChanges,
} from '@angular/core'
import { Directive, ElementRef, EventEmitter, inject, Input, OnChanges, OnDestroy, Output } from '@angular/core'
import { UIEventService } from '@shiftcode/ngx-core'
import { Subscription } from 'rxjs'

Expand All @@ -17,7 +7,6 @@ import { Subscription } from 'rxjs'
*/
@Directive({ selector: '[scClickOutside]', standalone: true })
export class ClickOutsideDirective implements OnDestroy, OnChanges {
// tslint:disable-next-line:no-input-rename
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is eslint not complaining about that, compared to tslint?

Copy link
Collaborator Author

@vitaliibendyk vitaliibendyk Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaelwittwer
Since we don't change the name, that existing input name if I change it to something else we get an error
Screenshot 2024-12-12 at 15 28 23

@Input('scClickOutsideDisabled') disabled = false

@Output() readonly scClickOutside = new EventEmitter<Event>()
Expand All @@ -27,7 +16,7 @@ export class ClickOutsideDirective implements OnDestroy, OnChanges {

constructor(private uiEventService: UIEventService) {}

ngOnChanges(changes: SimpleChanges): void {
ngOnChanges(): void {
// as there is only one input, ngOnChanges is only called when `isActive` changes
this.subscription?.unsubscribe()
if (!this.disabled) {
Expand Down
2 changes: 1 addition & 1 deletion libs/components/src/lib/rx/rx-if.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class RxIfDirective<T> extends BaseRxDirective<T | null | undefined, RxIf
this._elseRenderSubscription?.unsubscribe()
this._elseRenderSubscription = null

if (!!value) {
if (value) {
this.renderDataView({ scRxIf: value })
} else {
this.renderElseOrClear()
Expand Down
6 changes: 3 additions & 3 deletions libs/components/src/lib/svg-animate/svg-animate.directive.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BooleanInput, coerceBooleanProperty } from '@angular/cdk/coercion'
import { AfterViewInit, Directive, ElementRef, Input, OnChanges, SimpleChanges } from '@angular/core'
import { AfterViewInit, Directive, ElementRef, Input, OnChanges, OnInit } from '@angular/core'

/**
* Standalone Directive to animate SVG parts by calling beginElement method
Expand All @@ -18,7 +18,7 @@ import { AfterViewInit, Directive, ElementRef, Input, OnChanges, SimpleChanges }
* ```
*/
@Directive({ selector: '[scSvgAnimate]', standalone: true })
export class SvgAnimateDirective implements OnChanges, AfterViewInit {
export class SvgAnimateDirective implements OnChanges, AfterViewInit, OnInit {
/**
* state input in form {selector:state} - will be animated when state === true
*/
Expand Down Expand Up @@ -54,7 +54,7 @@ export class SvgAnimateDirective implements OnChanges, AfterViewInit {
}
}

ngOnChanges(changes: SimpleChanges) {
ngOnChanges() {
this.apply()
}

Expand Down
4 changes: 2 additions & 2 deletions libs/components/src/lib/svg/svg.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ export class SvgComponent implements OnChanges {

@Input() attrs?: Record<string, string>

private readonly logger: Logger = inject(LoggerService).getInstance('SvgComponent')

protected readonly elRef: ElementRef<HTMLElement> = inject(ElementRef)
protected readonly renderer = inject(Renderer2)
protected readonly svgRegistry = inject(SvgRegistry)

private readonly logger: Logger = inject(LoggerService).getInstance('SvgComponent')

ngOnChanges(changes: { [propertyName: string]: SimpleChange }) {
// Only update the inline SVG icon if the inputs changed, to avoid unnecessary DOM operations.
if ('attrs' in changes || 'url' in changes) {
Expand Down
Loading