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

[All] Migrate ESLint configs to flat config #58

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
73 changes: 0 additions & 73 deletions .eslintrc.js

This file was deleted.

4 changes: 3 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"Vue.vscode-typescript-vue-plugin"
"Vue.volar",
"EditorConfig.EditorConfig",
"Orta.vscode-jest"
],
"unwantedRecommendations": [
"svelte.svelte-vscode"
Expand Down
14 changes: 14 additions & 0 deletions MyBoothManager.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"name": "[packages] Common UI",
"path": "packages/CommonUI"
},
{
"name": "[packages] Dev Shared",
"path": "packages/DevShared"
},
{
"name": "[packages] I18n",
"path": "packages/I18n"
Expand All @@ -34,6 +38,16 @@
{ "pattern": "./packages/*/" },
{ "pattern": "./projects/*/" }
],
"eslint.useFlatConfig": true,
"eslint.validate": [
"javascript",
"typescript",
"vue",
"html"
],
"eslint.lintTask.enable": true,
"eslint.run": "onType",
"eslint.packageManager": "pnpm",
"typescript.tsdk": "node_modules/typescript/lib"
}
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ This is an in-development project for **managing booths and goods**, recording o
$ pnpm all:version minor # or major, patch
```

### Misc
* In [root `package.json`](package.json), [`@myboothmanager/dev-shared`](packages/DevShared/) is registered as dev dependency. <br />
This is intended, and is mandatory to make VSCode ESLint plugin work properly in sub-projects which extends the shared ESLint config.

## Copyright & License
Copyright © 2023- **[somni](https://github.com/somnisomni)**, All rights reserved.

Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@
"test:cov": "pnpm jest --coverage"
},
"devDependencies": {
"@myboothmanager/dev-shared": "workspace:^",
"@types/node": "^20.14.2",
"@typescript-eslint/parser": "^7.12.0",
"concurrently": "^8.2.2",
"eslint": "^8",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"jest": "^29.7.0",
"ts-jest": "^29.1.4",
"typescript": "^5.4.5"
Expand Down
32 changes: 0 additions & 32 deletions packages/Common/.eslintrc.cjs

This file was deleted.

5 changes: 5 additions & 0 deletions packages/Common/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { eslintConfigs } from "@myboothmanager/dev-shared";

export default [
...eslintConfigs.typescript,
];
1 change: 1 addition & 0 deletions packages/Common/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/no-var-requires */

const { JestConfigWithTsJest, pathsToModuleNameMapper } = require("ts-jest");
const { compilerOptions } = require("./tsconfig.json");

Expand Down
9 changes: 3 additions & 6 deletions packages/Common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,19 @@
"build:esm": "tsc -p tsconfig.build.esm.json && tsc-alias -p tsconfig.build.esm.json",
"build:cjs": "tsc -p tsconfig.build.cjs.json && tsc-alias -p tsconfig.build.cjs.json",
"clean": "rimraf ./dist",
"lint": "eslint",
"lint": "eslint .",
"test": "jest"
},
"files": [
"./dist"
],
"devDependencies": {
"@myboothmanager/dev-shared": "workspace:^",
"@rushstack/eslint-patch": "^1.10.3",
"@tsconfig/node20": "^20.1.4",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.2",
"@typescript-eslint/eslint-plugin": "^7.12.0",
"@typescript-eslint/parser": "^7.12.0",
"eslint": "^8",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint": "^9.4.0",
"execa": "^9.2.0",
"jest": "^29.7.0",
"rimraf": "^5.0.7",
Expand Down
2 changes: 0 additions & 2 deletions packages/Common/src/interfaces/goods-combination.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable import/exports-last */

import { GoodsStockVisibility, IGoodsCommon, IGoodsFrontendCommon, IGoodsStock } from "./goods";

/* === Common === */
Expand Down
2 changes: 0 additions & 2 deletions packages/Common/src/interfaces/goods.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable import/exports-last */

import { IImageUploadInfo } from "./base";

/* === Common === */
Expand Down
6 changes: 2 additions & 4 deletions packages/Common/src/utils/functions.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

export function emptyObject(target: Record<any, any>): void {
export function emptyObject(target: Record<string, unknown>): void {
Object.keys(target).forEach((key) => delete target[key]);
}

export function emptyNumberKeyObject(target: Record<number, any>): void {
export function emptyNumberKeyObject(target: Record<number, unknown>): void {
Object.keys(target).forEach((key) => delete target[parseInt(key)]);
}

Expand Down
9 changes: 5 additions & 4 deletions packages/Common/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export type MutualExclusive<TInterface,
TKey1 extends keyof TInterface,
TKey2 extends keyof TInterface>
= (({ [key in TKey1]: TInterface[key] } & { [key in TKey2]?: never })
export type MutualExclusive<
TInterface,
TKey1 extends keyof TInterface,
TKey2 extends keyof TInterface,
> = (({ [key in TKey1]: TInterface[key] } & { [key in TKey2]?: never })
| ({ [key in TKey2]: TInterface[key] } & { [key in TKey1]?: never }))
& Omit<TInterface, TKey1 | TKey2>;

Expand Down
2 changes: 1 addition & 1 deletion packages/Common/tsconfig.build.cjs.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "./tsconfig.json",
"exclude": ["./dist", "node_modules", "**/__tests__/**"],
"exclude": ["./dist", "./node_modules", "**/__tests__/**"],
"compilerOptions": {
"outDir": "./dist/cjs",
"module": "CommonJS",
Expand Down
2 changes: 1 addition & 1 deletion packages/Common/tsconfig.build.esm.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "./tsconfig.json",
"exclude": ["./dist", "node_modules", "**/__tests__/**"],
"exclude": ["./dist", "./node_modules", "**/__tests__/**"],
"compilerOptions": {
"outDir": "./dist/esm",
"module": "ESNext",
Expand Down
12 changes: 0 additions & 12 deletions packages/CommonUI/.eslintrc.cjs

This file was deleted.

5 changes: 5 additions & 0 deletions packages/CommonUI/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { eslintConfigs } from "@myboothmanager/dev-shared";

export default [
...eslintConfigs.vue,
];
6 changes: 3 additions & 3 deletions packages/CommonUI/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"clean": "rimraf ./dist",
"build-only": "vite build && vue-tsc -p tsconfig.app.json --emitDeclarationOnly",
"type-check": "vue-tsc --noEmit -p tsconfig.app.json --composite false",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
"lint": "eslint ."
},
"files": [
"./dist"
Expand All @@ -20,15 +20,15 @@
"module": "./dist/common-ui.js",
"devDependencies": {
"@mdi/font": "^7.4.47",
"@myboothmanager/dev-shared": "workspace:^",
"@myboothmanager/common": "workspace:^",
"@rushstack/eslint-patch": "^1.10.3",
"@tsconfig/node20": "^20.1.4",
"@types/clone-deep": "^4.0.4",
"@types/node": "^20.14.2",
"@vitejs/plugin-vue": "^5.0.5",
"@vue/eslint-config-typescript": "^13.0.0",
"@vue/tsconfig": "^0.5.1",
"eslint": "^8",
"eslint": "^9.4.0",
"eslint-plugin-vue": "^9.26.0",
"npm-run-all2": "^6.2.0",
"rimraf": "^5.0.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { useDisplay } from "vuetify";
export default class BoothMemberItem extends Vue {
@Prop({ type: Object, required: true }) readonly memberData!: IBoothMember;
@Prop({ type: Boolean, default: false }) readonly editable!: boolean;
@Prop({ type: Function, default: (s: any) => s }) readonly imageUrlResolver!: (rawImageUrl?: string | null) => string | null | undefined;
@Prop({ type: Function, default: (s: string) => s }) readonly imageUrlResolver!: (rawImageUrl?: string | null) => string | null | undefined;

@Setup(() => useDisplay().smAndUp)
declare smAndUp: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class CommonErrorDialog extends Vue {
@Prop({ type: String, default: "green" }) accentColor!: string;
@Prop({ type: Boolean, default: true }) showReloadButton!: boolean;
@Prop({ type: Boolean, default: true }) showContacts!: boolean;
@Prop({ type: Boolean, default: true }) closeable!: Boolean;
@Prop({ type: Boolean, default: true }) closeable!: boolean;

get developerTwitterHandle(): string {
return `@${DEVELOPER_TWITTER_HANDLE}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
</template>

<script lang="ts">
import type { ISnackbarContext } from "@/entities";
import type { VSnackbar } from "vuetify/components";
import type { ISnackbarContext } from "@/entities";
import { Component, Model, Ref, Vue, Watch } from "vue-facing-decorator";

@Component({})
Expand Down Expand Up @@ -104,7 +104,7 @@ export default class GlobalSnackbarStack extends Vue {
}

getNormalizedProps(context: ISnackbarContext) {
let props: ISnackbarContext | Record<string, any> = {
let props: ISnackbarContext | Record<string, any> = { // eslint-disable-line @typescript-eslint/no-explicit-any
/* Defaults */
location: "top right",
timeout: 5000,
Expand Down
2 changes: 1 addition & 1 deletion packages/CommonUI/src/components/goods/GoodsListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default class GoodsListView extends Vue {
@Prop({ type: Boolean, default: false }) readonly omitEmptyGoodsCategory!: boolean;
@Prop({ type: String, required: true }) readonly currencySymbol!: string;
@Prop({ type: Boolean, default: false }) readonly categoryEditable!: boolean;
@Prop({ type: Function, default: (s: any) => s }) readonly goodsImageUrlResolver!: (rawGoodsImageUrl?: string) => string | null | undefined;
@Prop({ type: Function, default: (s: string) => s }) readonly goodsImageUrlResolver!: (rawGoodsImageUrl?: string) => string | null | undefined;

get goodsListAdjusted(): Array<Goods> {
if(!this.goodsList) {
Expand Down
8 changes: 4 additions & 4 deletions packages/CommonUI/src/entities/ui-context/snackbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { ref, type Ref } from "vue";
/* Part of https://github.com/vuetifyjs/vuetify/blob/master/packages/vuetify/src/util/anchor.ts#L8-L14 */
const block = ["top", "bottom"] as const;
const inline = ["start", "end", "left", "right"] as const;
type Tblock = typeof block[number]
type Tinline = typeof inline[number]
type Tblock = typeof block[number];
type Tinline = typeof inline[number];
type VuetifyAnchor =
| Tblock
| Tinline
| "center"
| "center center"
| `${Tblock} ${Tinline | "center"}`
| `${Tinline} ${Tblock | "center"}`
| `${Tinline} ${Tblock | "center"}`;

export interface ISnackbarContext {
id: string;
Expand All @@ -32,7 +32,7 @@ export interface ISnackbarContext {
}

export class SnackbarContextWrapper {
private _contexts: Array<ISnackbarContext> = new Array();
private _contexts: Array<ISnackbarContext> = [];

get contexts(): Ref<Array<ISnackbarContext>> {
return ref(this._contexts);
Expand Down
5 changes: 5 additions & 0 deletions packages/DevShared/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { eslintConfigs } from "./eslint/index.mjs";

export default [
...eslintConfigs.typescript,
];
Loading