Skip to content

Commit 3760bae

Browse files
authored
build(deps): bump eslint v9 and use new eslint config js file (#12)
* chore: remove eslint * feat: add angular eslint * feat: add angular eslint into application/library
1 parent fda32ae commit 3760bae

19 files changed

+687
-402
lines changed

.eslintrc.json

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

angular.json

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"lintFilePatterns": [
4141
"packages/angular-toaster/**/*.ts",
4242
"packages/angular-toaster/**/*.html"
43-
]
43+
],
44+
"eslintConfig": "packages/angular-toaster/eslint.config.js"
4445
}
4546
}
4647
}
@@ -142,22 +143,23 @@
142143
"scripts": []
143144
}
144145
},
145-
"lint": {
146-
"builder": "@angular-eslint/builder:lint",
147-
"options": {
148-
"lintFilePatterns": [
149-
"packages/dev-app/**/*.ts",
150-
"packages/dev-app/**/*.html"
151-
]
152-
}
153-
},
154146
"deploy": {
155147
"builder": "angular-cli-ghpages:deploy",
156148
"options": {
157149
"baseHref": "https://damingerdai.github.io/angular-toaster/",
158150
"name": "angular toaster dev app",
159151
"email": "[email protected]"
160152
}
153+
},
154+
"lint": {
155+
"builder": "@angular-eslint/builder:lint",
156+
"options": {
157+
"lintFilePatterns": [
158+
"packages/dev-app/**/*.ts",
159+
"packages/dev-app/**/*.html"
160+
],
161+
"eslintConfig": "packages/dev-app/eslint.config.js"
162+
}
161163
}
162164
}
163165
},
@@ -274,7 +276,8 @@
274276
"lintFilePatterns": [
275277
"packages/dev-module-app/**/*.ts",
276278
"packages/dev-module-app/**/*.html"
277-
]
279+
],
280+
"eslintConfig": "packages/dev-module-app/eslint.config.js"
278281
}
279282
}
280283
}

eslint.config.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// @ts-check
2+
const eslint = require("@eslint/js");
3+
const tseslint = require("typescript-eslint");
4+
const angular = require("angular-eslint");
5+
6+
module.exports = tseslint.config(
7+
{
8+
files: ["**/*.ts"],
9+
extends: [
10+
eslint.configs.recommended,
11+
...tseslint.configs.recommended,
12+
...tseslint.configs.stylistic,
13+
...angular.configs.tsRecommended,
14+
],
15+
processor: angular.processInlineTemplates,
16+
rules: {
17+
"@angular-eslint/directive-selector": [
18+
"error",
19+
{
20+
type: "attribute",
21+
prefix: "lib",
22+
style: "camelCase",
23+
},
24+
],
25+
"@angular-eslint/component-selector": [
26+
"error",
27+
{
28+
type: "element",
29+
prefix: "lib",
30+
style: "kebab-case",
31+
},
32+
],
33+
},
34+
},
35+
{
36+
files: ["**/*.html"],
37+
extends: [
38+
...angular.configs.templateRecommended,
39+
...angular.configs.templateAccessibility,
40+
],
41+
rules: {},
42+
}
43+
);

package.json

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,29 +61,23 @@
6161
},
6262
"devDependencies": {
6363
"@angular-devkit/build-angular": "^19.2.10",
64-
"@angular-eslint/builder": "19.3.0",
65-
"@angular-eslint/eslint-plugin": "19.3.0",
66-
"@angular-eslint/eslint-plugin-template": "19.3.0",
67-
"@angular-eslint/schematics": "19.3.0",
68-
"@angular-eslint/template-parser": "19.3.0",
6964
"@angular/cli": "^19.2.10",
7065
"@angular/compiler-cli": "^19.2.9",
7166
"@changesets/cli": "^2.24.0",
7267
"@schematics/angular": "^19.2.10",
7368
"@types/express": "^4.17.17",
7469
"@types/jasmine": "~5.1.0",
7570
"@types/node": "^18.18.0",
76-
"@typescript-eslint/eslint-plugin": "^7.2.0",
77-
"@typescript-eslint/parser": "^7.2.0",
7871
"angular-cli-ghpages": "2.0.0-beta.2",
72+
"angular-eslint": "19.3.0",
7973
"colors": "^1.4.0",
8074
"conventional-changelog-cli": "^2.2.2",
8175
"copyfiles": "^2.4.1",
8276
"coveralls": "3.1.0",
8377
"cpx": "^1.5.0",
8478
"enquirer": "^2.3.6",
8579
"esbuild": "0.14.22",
86-
"eslint": "^8.57.0",
80+
"eslint": "^9.23.0",
8781
"fs-extra": "^10.1.0",
8882
"husky": "^9.0.10",
8983
"jasmine": "~5.1.0",
@@ -100,6 +94,7 @@
10094
"semver": "^7.3.7",
10195
"shelljs": "^0.8.5",
10296
"ts-node": "10.7.0",
103-
"typescript": "~5.5.4"
97+
"typescript": "~5.5.4",
98+
"typescript-eslint": "8.27.0"
10499
}
105-
}
100+
}

packages/angular-toaster/.eslintrc.json

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// @ts-check
2+
const tseslint = require("typescript-eslint");
3+
const rootConfig = require("../../eslint.config.js");
4+
5+
module.exports = tseslint.config(
6+
...rootConfig,
7+
{
8+
files: ["**/*.ts"],
9+
rules: {
10+
"@angular-eslint/directive-selector": [
11+
"error",
12+
{
13+
type: "attribute",
14+
prefix: "lib",
15+
style: "camelCase",
16+
},
17+
],
18+
"@angular-eslint/component-selector": [
19+
"error",
20+
{
21+
type: "element",
22+
prefix: "lib",
23+
style: "kebab-case",
24+
},
25+
],
26+
},
27+
},
28+
{
29+
files: ["**/*.html"],
30+
rules: {},
31+
}
32+
);

packages/angular-toaster/schematics/ng-add/theming/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { getProjectFromWorkspace, getProjectTargetOptions } from '../../utils/pr
77
export function addThemeToAppStyles(options: Schema): Rule {
88
const themePath = './node_modules/angular-toaster/toaster.css';
99

10-
// eslint-disable-next-line no-unused-vars
10+
1111
return (_host: Tree, _context: SchematicContext) => {
1212
return chain([
1313
addThemeStyleToTarget(options.project, 'build', themePath),
@@ -31,7 +31,7 @@ function addThemeStyleToTarget(projectName: string, targetName: 'test' | 'build'
3131

3232
const existingStyles = styles.map(s => (typeof s === 'string' ? s : s.input));
3333

34-
for (let [, stylePath] of existingStyles.entries()) {
34+
for (const [, stylePath] of existingStyles.entries()) {
3535
if (stylePath === assetPath)
3636
return;
3737
}

packages/angular-toaster/schematics/utils/ng-module-imports.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function hasNgModuleImport(tree: Tree, modulePath: string, className: str
3131
throw new SchematicsException(`Could not find NgModule declaration inside: "${modulePath}"`);
3232
}
3333

34-
for (let property of ngModuleMetadata!.properties) {
34+
for (const property of ngModuleMetadata!.properties) {
3535
if (
3636
!ts.isPropertyAssignment(property) ||
3737
property.name.getText() !== 'imports' ||

packages/angular-toaster/schematics/utils/project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function getProjectTestTargets(
4444
/** Gets all targets from the given project that pass a predicate check. */
4545
function getTargetsByBuilderName(
4646
project: ProjectDefinition,
47-
// eslint-disable-next-line no-unused-vars
47+
4848
predicate: (_name: string | undefined) => boolean
4949
): TargetDefinition[] {
5050
return Array.from(project.targets.keys())

packages/angular-toaster/src/angular-toaster-config.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable no-unused-vars */
1+
22
import { InjectionToken } from "@angular/core";
33

44
export type ToastType = 'success' | 'info' | 'warning' | 'wait' | 'error';
@@ -34,15 +34,15 @@ export interface Toast {
3434
progressBarDirection?: ProgressBarDirection
3535
}
3636

37-
export const DefaultTypeClasses : { [key in ToastType]? : string } = {
37+
export const DefaultTypeClasses : Partial<Record<ToastType, string>> = {
3838
error: 'angular-toast-error',
3939
info: 'angular-toast-info',
4040
wait: 'angular-toast-wait',
4141
success: 'angular-toast-success',
4242
warning: 'angular-toast-warning'
4343
};
4444

45-
export const DefaultIconClasses : { [key in ToastType]? : string } = {
45+
export const DefaultIconClasses : Partial<Record<ToastType, string>> = {
4646
error: 'icon-error',
4747
info: 'icon-info',
4848
wait: 'icon-wait',
@@ -53,12 +53,12 @@ export const DefaultIconClasses : { [key in ToastType]? : string } = {
5353
export interface IToasterConfig {
5454
limit?: number|null;
5555
tapToDismiss?: boolean;
56-
showCloseButton?: boolean|{ [key in ToastType]?: boolean};
56+
showCloseButton?: boolean|Partial<Record<ToastType, boolean>>;
5757
closeHtml?: string;
5858
newestOnTop?: boolean;
59-
timeout?: number|{ [key in ToastType]?: number };
60-
typeClasses?: { [key in ToastType]?: string };
61-
iconClasses?: { [key in ToastType]?: string };
59+
timeout?: number|Partial<Record<ToastType, number>>;
60+
typeClasses?: Partial<Record<ToastType, string>>;
61+
iconClasses?: Partial<Record<ToastType, string>>;
6262
bodyOutputType?: BodyOutputType;
6363
bodyTemplate?: string;
6464
defaultToastType?: ToastType;
@@ -101,12 +101,12 @@ export const ToasterConfigInjectionToken: InjectionToken<IToasterConfig> = new I
101101
export class ToasterConfig implements IToasterConfig {
102102
limit?: number|null;
103103
tapToDismiss: boolean;
104-
showCloseButton: boolean|{ [key in ToastType]?: boolean };
104+
showCloseButton: boolean|Partial<Record<ToastType, boolean>>;
105105
closeHtml: string;
106106
newestOnTop: boolean;
107-
timeout: number|{ [key in ToastType]?: number };
108-
typeClasses: { [key in ToastType]?: string };
109-
iconClasses: { [key in ToastType]?: string };
107+
timeout: number|Partial<Record<ToastType, number>>;
108+
typeClasses: Partial<Record<ToastType, string>>;
109+
iconClasses: Partial<Record<ToastType, string>>;
110110
bodyOutputType: BodyOutputType;
111111
bodyTemplate: string;
112112
defaultToastType: ToastType;

packages/angular-toaster/src/angular-toaster-container.component.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ describe("ToasterContainerComponent with sync ToasterService", () => {
263263
it("addToast should use defaultTypeClass if type is empty string", () => {
264264
toasterContainer.ngOnInit();
265265

266-
toasterService.pop(<ExtendedToastType>"", "", "");
266+
toasterService.pop(("" as ExtendedToastType), "", "");
267267

268268
expect(toasterContainer.toasterconfig.defaultToastType).toBe("info");
269269
expect(toasterContainer.toasts.length).toBe(1);
@@ -339,7 +339,7 @@ describe("ToasterContainerComponent with sync ToasterService", () => {
339339
toasterContainer.toasterconfig = new ToasterConfig({
340340
showCloseButton: false,
341341
});
342-
(<any>toasterContainer.toasterconfig.showCloseButton) = "";
342+
(toasterContainer.toasterconfig.showCloseButton as any) = "";
343343
toasterContainer.ngOnInit();
344344
const toast: Toast = { type: "info" };
345345

@@ -564,21 +564,21 @@ describe("ToasterContainerComponent with sync ToasterService", () => {
564564
});
565565

566566
it("toastIdOrDefault should return empty string if toast.toastId is null", () => {
567-
let toast: Toast = { type: "info", toastId: undefined };
567+
const toast: Toast = { type: "info", toastId: undefined };
568568
const toastId = toasterContainer["toastIdOrDefault"](toast);
569569

570570
expect(toastId).toBe("");
571571
});
572572

573573
it("toastIdOrDefault should return empty string if toast.toastId is undefined", () => {
574-
let toast: Toast = { type: "info", toastId: undefined };
574+
const toast: Toast = { type: "info", toastId: undefined };
575575
const toastId = toasterContainer["toastIdOrDefault"](toast);
576576

577577
expect(toastId).toBe("");
578578
});
579579

580580
it("toastIdOrDefault should return empty string if toast.toastId is empty string", () => {
581-
let toast: Toast = { type: "info", toastId: "" };
581+
const toast: Toast = { type: "info", toastId: "" };
582582
const toastId = toasterContainer["toastIdOrDefault"](toast);
583583

584584
expect(toastId).toBe("");
@@ -587,7 +587,7 @@ describe("ToasterContainerComponent with sync ToasterService", () => {
587587
it("should use toast.toastId parameter if passed", () => {
588588
toasterContainer.ngOnInit();
589589

590-
let toast: Toast = {
590+
const toast: Toast = {
591591
type: "success",
592592
title: "",
593593
body: "",

packages/angular-toaster/src/angular-toaster-container.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class ToasterContainerComponent implements OnInit, OnDestroy {
3939
private clearToastsSubscriber!: Subscription;
4040

4141
constructor(
42-
// eslint-disable-next-line no-unused-vars
42+
4343
@Optional() @Inject(ToasterConfigInjectionToken) private _defaultToasterConfig: IToasterConfig
4444
) {
4545
this._toasterconfig = (this._defaultToasterConfig ? { ...defaultToasterConfig, ...this._defaultToasterConfig } : defaultToasterConfig) as Required<IToasterConfig>;

0 commit comments

Comments
 (0)