feat(tooling): add lint-staged with Prettier + ESLint on pre-commit
- Install prettier, lint-staged, eslint-config-prettier - Configure lint-staged in package.json: Prettier write on staged files, ESLint check on .ts/.html - Add eslint-config-prettier to .eslintrc.json extends to disable formatting rules that conflict with Prettier - Configure no-unused-vars to allow _ prefix (intentional destructuring pattern) - Replace manual prettier/git update-index lines in pre-commit hook with npx lint-staged - Fix pre-existing ESLint errors: remove unused imports in herowars-guildraid, fix useless escapes in middleware.ts, fix eslint-disable comment in utilityTypes.ts
This commit is contained in:
+12
-15
@@ -1,19 +1,21 @@
|
|||||||
{
|
{
|
||||||
"root": true,
|
"root": true,
|
||||||
"ignorePatterns": [
|
"ignorePatterns": ["projects/**/*"],
|
||||||
"projects/**/*"
|
"overrides": [
|
||||||
],
|
{
|
||||||
"overrides": [{
|
"files": ["*.ts"],
|
||||||
"files": [
|
|
||||||
"*.ts"
|
|
||||||
],
|
|
||||||
"extends": [
|
"extends": [
|
||||||
"eslint:recommended",
|
"eslint:recommended",
|
||||||
"plugin:@typescript-eslint/recommended",
|
"plugin:@typescript-eslint/recommended",
|
||||||
"plugin:@angular-eslint/recommended",
|
"plugin:@angular-eslint/recommended",
|
||||||
"plugin:@angular-eslint/template/process-inline-templates"
|
"plugin:@angular-eslint/template/process-inline-templates",
|
||||||
|
"prettier"
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
|
"@typescript-eslint/no-unused-vars": [
|
||||||
|
"error",
|
||||||
|
{ "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }
|
||||||
|
],
|
||||||
"@angular-eslint/directive-selector": [
|
"@angular-eslint/directive-selector": [
|
||||||
"error",
|
"error",
|
||||||
{
|
{
|
||||||
@@ -33,13 +35,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"files": [
|
"files": ["*.html"],
|
||||||
"*.html"
|
"extends": ["plugin:@angular-eslint/template/recommended", "plugin:@angular-eslint/template/accessibility"],
|
||||||
],
|
|
||||||
"extends": [
|
|
||||||
"plugin:@angular-eslint/template/recommended",
|
|
||||||
"plugin:@angular-eslint/template/accessibility"
|
|
||||||
],
|
|
||||||
"rules": {}
|
"rules": {}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
+1
-2
@@ -1,3 +1,2 @@
|
|||||||
npm test -- --watch=false
|
npm test -- --watch=false
|
||||||
#prettier $(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g') --write --ignore-unknown
|
npx lint-staged
|
||||||
#git update-index --again
|
|
||||||
Generated
+15233
-14981
File diff suppressed because it is too large
Load Diff
+79
-65
@@ -1,67 +1,81 @@
|
|||||||
{
|
{
|
||||||
"name": "adastra-app",
|
"name": "adastra-app",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"author": "Solide Apps <admin@unespace.com>",
|
"author": "Solide Apps <admin@unespace.com>",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"Julien Gautier <julien.gautier@unespace.com>"
|
"Julien Gautier <julien.gautier@unespace.com>"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "ng serve",
|
"start": "ng serve",
|
||||||
"build": "ng build",
|
"build": "ng build",
|
||||||
"watch": "ng build --watch --configuration development",
|
"watch": "ng build --watch --configuration development",
|
||||||
"serve": "ng serve --configuration local --port 4201",
|
"serve": "ng serve --configuration local --port 4201",
|
||||||
"dev": "APP_ENV=development ng serve --port 4300 --configuration development",
|
"dev": "APP_ENV=development ng serve --port 4300 --configuration development",
|
||||||
"local": "APP_ENV=local ng serve --port 4400 --configuration local",
|
"local": "APP_ENV=local ng serve --port 4400 --configuration local",
|
||||||
"lint": "ng lint",
|
"lint": "ng lint",
|
||||||
"test": "ng test"
|
"test": "ng test"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^18.19.1 || ^20.11.1"
|
"node": "^18.19.1 || ^20.11.1"
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "^18.2.14",
|
"@angular/animations": "^18.2.14",
|
||||||
"@angular/cdk": "^18.2.14",
|
"@angular/cdk": "^18.2.14",
|
||||||
"@angular/common": "^18.2.14",
|
"@angular/common": "^18.2.14",
|
||||||
"@angular/compiler": "^18.2.14",
|
"@angular/compiler": "^18.2.14",
|
||||||
"@angular/core": "^18.2.14",
|
"@angular/core": "^18.2.14",
|
||||||
"@angular/forms": "^18.2.14",
|
"@angular/forms": "^18.2.14",
|
||||||
"@angular/google-maps": "^17.3.8",
|
"@angular/google-maps": "^17.3.8",
|
||||||
"@angular/localize": "^18.2.14",
|
"@angular/localize": "^18.2.14",
|
||||||
"@angular/material": "^18.2.14",
|
"@angular/material": "^18.2.14",
|
||||||
"@angular/platform-browser": "^18.2.14",
|
"@angular/platform-browser": "^18.2.14",
|
||||||
"@angular/platform-browser-dynamic": "^18.2.14",
|
"@angular/platform-browser-dynamic": "^18.2.14",
|
||||||
"@angular/router": "^18.2.14",
|
"@angular/router": "^18.2.14",
|
||||||
"bootstrap": "^5.3.7",
|
"bootstrap": "^5.3.7",
|
||||||
"chart.js": "^4.4.2",
|
"chart.js": "^4.4.2",
|
||||||
"chartist": "^1.3.0",
|
"chartist": "^1.3.0",
|
||||||
"ng-chartist": "^8.2.0",
|
"ng-chartist": "^8.2.0",
|
||||||
"ng2-charts": "^6.0.1",
|
"ng2-charts": "^6.0.1",
|
||||||
"ngx-skeleton-loader": "^9.0.0",
|
"ngx-skeleton-loader": "^9.0.0",
|
||||||
"rxjs": "~7.8.0",
|
"rxjs": "~7.8.0",
|
||||||
"tslib": "^2.3.0",
|
"tslib": "^2.3.0",
|
||||||
"zone.js": "^0.14.10"
|
"zone.js": "^0.14.10"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-devkit/build-angular": "^18.2.21",
|
"@angular-devkit/build-angular": "^18.2.21",
|
||||||
"@angular-eslint/builder": "18.4.3",
|
"@angular-eslint/builder": "18.4.3",
|
||||||
"@angular-eslint/eslint-plugin": "18.4.3",
|
"@angular-eslint/eslint-plugin": "18.4.3",
|
||||||
"@angular-eslint/eslint-plugin-template": "18.4.3",
|
"@angular-eslint/eslint-plugin-template": "18.4.3",
|
||||||
"@angular-eslint/schematics": "18.4.3",
|
"@angular-eslint/schematics": "18.4.3",
|
||||||
"@angular-eslint/template-parser": "18.4.3",
|
"@angular-eslint/template-parser": "18.4.3",
|
||||||
"@angular/cli": "^18.2.21",
|
"@angular/cli": "^18.2.21",
|
||||||
"@angular/compiler-cli": "^18.2.14",
|
"@angular/compiler-cli": "^18.2.14",
|
||||||
"@types/jasmine": "~5.1.0",
|
"@types/jasmine": "~5.1.0",
|
||||||
"@typescript-eslint/eslint-plugin": "7.2.0",
|
"@typescript-eslint/eslint-plugin": "7.2.0",
|
||||||
"@typescript-eslint/parser": "7.2.0",
|
"@typescript-eslint/parser": "7.2.0",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"jasmine-core": "~5.1.0",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"karma": "~6.4.0",
|
"jasmine-core": "~5.1.0",
|
||||||
"karma-chrome-launcher": "~3.2.0",
|
"karma": "~6.4.0",
|
||||||
"karma-coverage": "~2.2.0",
|
"karma-chrome-launcher": "~3.2.0",
|
||||||
"karma-jasmine": "~5.1.0",
|
"karma-coverage": "~2.2.0",
|
||||||
"karma-jasmine-html-reporter": "~2.1.0",
|
"karma-jasmine": "~5.1.0",
|
||||||
"typescript": "~5.5.4"
|
"karma-jasmine-html-reporter": "~2.1.0",
|
||||||
}
|
"lint-staged": "^16.4.0",
|
||||||
|
"prettier": "^3.8.3",
|
||||||
|
"typescript": "~5.5.4"
|
||||||
|
},
|
||||||
|
"lint-staged": {
|
||||||
|
"*.{ts,html,scss,json,md}": [
|
||||||
|
"prettier --write"
|
||||||
|
],
|
||||||
|
"*.ts": [
|
||||||
|
"eslint --max-warnings=0"
|
||||||
|
],
|
||||||
|
"*.html": [
|
||||||
|
"eslint --max-warnings=0"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,7 @@ import { MatStepperIntl, MatStepperModule } from '@angular/material/stepper';
|
|||||||
|
|
||||||
import { ListErrorsComponent } from '@components/shared';
|
import { ListErrorsComponent } from '@components/shared';
|
||||||
import { Errors } from '@models';
|
import { Errors } from '@models';
|
||||||
import { HWGuildRaid, HWGuildRaidAttacker, HWGuildRaidAttackers, HWGuildRaidStage, HWMember } from '@models/herowars';
|
import { HWGuildRaid, HWGuildRaidStage, HWMember } from '@models/herowars';
|
||||||
|
|
||||||
import guildRaids from 'src/files-data/hw-guild-raids.json'; // page Asgard -> Guild Raid -> Log
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class GuildRaidStepperIntl extends MatStepperIntl {
|
export class GuildRaidStepperIntl extends MatStepperIntl {
|
||||||
@@ -33,25 +31,26 @@ export class GuildRaidStepperIntl extends MatStepperIntl {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
DatePipe, FormsModule, ListErrorsComponent,
|
DatePipe,
|
||||||
MatButtonModule, MatCardModule, MatDividerModule, MatFormFieldModule,
|
FormsModule,
|
||||||
MatIconModule, MatInputModule, MatStepperModule
|
ListErrorsComponent,
|
||||||
|
MatButtonModule,
|
||||||
|
MatCardModule,
|
||||||
|
MatDividerModule,
|
||||||
|
MatFormFieldModule,
|
||||||
|
MatIconModule,
|
||||||
|
MatInputModule,
|
||||||
|
MatStepperModule,
|
||||||
],
|
],
|
||||||
templateUrl: './herowars-guildraid.component.html',
|
templateUrl: './herowars-guildraid.component.html',
|
||||||
styleUrl: './herowars-guildraid.component.scss',
|
styleUrl: './herowars-guildraid.component.scss',
|
||||||
animations: [
|
animations: [
|
||||||
trigger('flyInOut', [
|
trigger('flyInOut', [
|
||||||
state('in', style({ transform: 'translateY(0)' })),
|
state('in', style({ transform: 'translateY(0)' })),
|
||||||
transition('void => *', [
|
transition('void => *', [style({ transform: 'translateY(-100%)' }), animate(200)]),
|
||||||
style({ transform: 'translateY(-100%)' }),
|
transition('* => void', [style({ transform: 'translateY(100%)' }), animate(200)]),
|
||||||
animate(200)
|
]),
|
||||||
]),
|
],
|
||||||
transition('* => void', [
|
|
||||||
style({ transform: 'translateY(100%)' }),
|
|
||||||
animate(200)
|
|
||||||
])
|
|
||||||
])
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
export class HerowarsGuildraidComponent implements OnInit {
|
export class HerowarsGuildraidComponent implements OnInit {
|
||||||
public title = 'Guild Raids';
|
public title = 'Guild Raids';
|
||||||
@@ -68,12 +67,10 @@ export class HerowarsGuildraidComponent implements OnInit {
|
|||||||
private _raidStages: HWGuildRaidStage[] = [
|
private _raidStages: HWGuildRaidStage[] = [
|
||||||
{ num: 1, name: 'Stage 1', maxPower: 320000, duration: 8, startTime: 0, endTime: 0 },
|
{ num: 1, name: 'Stage 1', maxPower: 320000, duration: 8, startTime: 0, endTime: 0 },
|
||||||
{ num: 2, name: 'Stage 2', maxPower: 500000, duration: 8, startTime: 0, endTime: 0 },
|
{ num: 2, name: 'Stage 2', maxPower: 500000, duration: 8, startTime: 0, endTime: 0 },
|
||||||
{ num: 3, name: 'Stage 3', maxPower: 0, duration: 0, startTime: 0, endTime: 0 }
|
{ num: 3, name: 'Stage 3', maxPower: 0, duration: 0, startTime: 0, endTime: 0 },
|
||||||
];
|
];
|
||||||
|
|
||||||
constructor(
|
constructor(private _titleService: Title) {}
|
||||||
private _titleService: Title
|
|
||||||
) { }
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this._titleService.setTitle(this.title);
|
this._titleService.setTitle(this.title);
|
||||||
@@ -81,7 +78,7 @@ export class HerowarsGuildraidComponent implements OnInit {
|
|||||||
data.raids = [];
|
data.raids = [];
|
||||||
data.raidsInfo = {
|
data.raidsInfo = {
|
||||||
variationAvg: 0,
|
variationAvg: 0,
|
||||||
variationSum: 0
|
variationSum: 0,
|
||||||
};
|
};
|
||||||
return data;
|
return data;
|
||||||
});
|
});
|
||||||
@@ -90,5 +87,4 @@ export class HerowarsGuildraidComponent implements OnInit {
|
|||||||
getMembers(): HWMember[] {
|
getMembers(): HWMember[] {
|
||||||
return this._guildMembers;
|
return this._guildMembers;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-16
@@ -1,34 +1,34 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from 'next/server';
|
||||||
import { getSession } from "./utils/auth/session";
|
import { getSession } from './utils/auth/session';
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
matcher: ["/((?!api|_next/static|_next/image|.*\\.png$).*)"],
|
matcher: ['/((?!api|_next/static|_next/image|.*\\.png$).*)'],
|
||||||
};
|
};
|
||||||
|
|
||||||
const publicRoutes = [
|
const publicRoutes = [
|
||||||
/^\/article\/[^\/]+?\/?$/, // /article/sample-slug
|
/^\/article\/[^/]+?\/?$/, // /article/sample-slug
|
||||||
/^\/login\/?$/,
|
/^\/login\/?$/,
|
||||||
/^\/profile\/[^\/]+?\/?$/, // /profile/sample-username
|
/^\/profile\/[^/]+?\/?$/, // /profile/sample-username
|
||||||
/^\/profile\/[^\/]+?\/favorites\/?$/, // /profile/sample-username/favorites
|
/^\/profile\/[^/]+?\/favorites\/?$/, // /profile/sample-username/favorites
|
||||||
/^\/register\/?$/,
|
/^\/register\/?$/,
|
||||||
/^\/$/,
|
/^\/$/,
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
const isPublicRoutes = (pathname: string) => {
|
const isPublicRoutes = (pathname: string) => {
|
||||||
return publicRoutes.some((route) => route.test(pathname));
|
return publicRoutes.some((route) => route.test(pathname));
|
||||||
};
|
};
|
||||||
|
|
||||||
const isPrivateRoutes = (pathname: string) => {
|
const isPrivateRoutes = (pathname: string) => {
|
||||||
return !isPublicRoutes(pathname);
|
return !isPublicRoutes(pathname);
|
||||||
};
|
};
|
||||||
|
|
||||||
const middleware = async (req: NextRequest) => {
|
const middleware = async (req: NextRequest) => {
|
||||||
const session = await getSession();
|
const session = await getSession();
|
||||||
if (isPrivateRoutes(req.nextUrl.pathname) && session == null) {
|
if (isPrivateRoutes(req.nextUrl.pathname) && session == null) {
|
||||||
return NextResponse.redirect(new URL("/login", req.nextUrl));
|
return NextResponse.redirect(new URL('/login', req.nextUrl));
|
||||||
}
|
}
|
||||||
|
|
||||||
return NextResponse.next();
|
return NextResponse.next();
|
||||||
};
|
};
|
||||||
|
|
||||||
export default middleware;
|
export default middleware;
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
/* eslint @typescript-eslint/no-empty-object-type: off */
|
/* eslint-disable @typescript-eslint/ban-types */
|
||||||
export type FilterRequired<T extends Record<PropertyKey, unknown>> = {
|
export type FilterRequired<T extends Record<PropertyKey, unknown>> = {
|
||||||
[P in keyof T as {} extends Pick<T, P> ? never : P]: T[P];
|
[P in keyof T as {} extends Pick<T, P> ? never : P]: T[P];
|
||||||
};
|
};
|
||||||
|
/* eslint-enable @typescript-eslint/ban-types */
|
||||||
|
|
||||||
export type OptionalUndefined<T> = Omit<
|
export type OptionalUndefined<T> = Omit<
|
||||||
{
|
{
|
||||||
[P in keyof T as undefined extends T[P] ? never : P]: T[P];
|
[P in keyof T as undefined extends T[P] ? never : P]: T[P];
|
||||||
} & {
|
} & {
|
||||||
[P in keyof T]?: T[P];
|
[P in keyof T]?: T[P];
|
||||||
},
|
},
|
||||||
never
|
never
|
||||||
>;
|
>;
|
||||||
|
|
||||||
// export type OptionalEmptyObject<T extends Record<PropertyKey, U>, U> = Omit<
|
// export type OptionalEmptyObject<T extends Record<PropertyKey, U>, U> = Omit<
|
||||||
@@ -27,12 +28,12 @@ export type OptionalUndefined<T> = Omit<
|
|||||||
// >;
|
// >;
|
||||||
|
|
||||||
export type GetValueRecursive<T extends object, K extends PropertyKey[]> = K extends [
|
export type GetValueRecursive<T extends object, K extends PropertyKey[]> = K extends [
|
||||||
infer First,
|
infer First,
|
||||||
...infer Rest extends PropertyKey[],
|
...infer Rest extends PropertyKey[],
|
||||||
]
|
]
|
||||||
? First extends keyof T
|
? First extends keyof T
|
||||||
? T[First] extends object
|
? T[First] extends object
|
||||||
? GetValueRecursive<T[First], Rest>
|
? GetValueRecursive<T[First], Rest>
|
||||||
: T[First]
|
: T[First]
|
||||||
: never
|
: never
|
||||||
: T;
|
: T;
|
||||||
|
|||||||
Reference in New Issue
Block a user