Skip to content

Commit

Permalink
all: WIP migrate ESLint legacy configs to flat config
Browse files Browse the repository at this point in the history
Need keep testing that it's working

VSCode ESLint extension should be updated to latest insider version I guess,
and the extension seems stop working sometimes...
Don't restart ESLint server in VSCode, or it will stop working after that until restart VSCode..?
  • Loading branch information
somnisomni committed Jun 10, 2024
1 parent 8c77a20 commit f25c367
Show file tree
Hide file tree
Showing 38 changed files with 628 additions and 414 deletions.
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
13 changes: 13 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,15 @@
{ "pattern": "./packages/*/" },
{ "pattern": "./projects/*/" }
],
"eslint.useFlatConfig": true,
"eslint.validate": [
"javascript",
"typescript",
"vue",
"html"
],
"eslint.lintTask.enable": true,
"eslint.run": "onType",
"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,
];
2 changes: 0 additions & 2 deletions packages/Common/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* 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
2 changes: 0 additions & 2 deletions packages/Common/src/utils/functions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

export function emptyObject(target: Record<any, any>): void {
Object.keys(target).forEach((key) => delete target[key]);
}
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 @@ -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
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,
];
13 changes: 13 additions & 0 deletions packages/DevShared/eslint/additional.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @type {import("eslint").Linter.FlatConfig} */
export default {
name: "@myboothmanager/dev-shared eslint - additional rules",
rules: {
"eqeqeq": ["error", "always", { null: "ignore" }],
"quote-props": ["error", "consistent-as-needed"],
"arrow-body-style": ["error", "as-needed"],
"semi-spacing": ["error", {
before: false,
after: true,
}],
}
};
37 changes: 37 additions & 0 deletions packages/DevShared/eslint/import.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import importPlugin from "eslint-plugin-import";
import { fixupPluginRules } from "@eslint/compat";
import { parser as tsParser } from "typescript-eslint";

/** @type {import("eslint").Linter.FlatConfig} */
export default {
files: ["**/*.(m|c)?(t|j)s", "**/*.vue"],
plugins: {
import: fixupPluginRules(importPlugin),
},
settings: {
...importPlugin.configs.typescript.settings,
"import/resolver": {
typescript: true,
node: true,
},
},
languageOptions: {
parserOptions: {
parser: tsParser,
ecmaVersion: "latest",
sourceType: "module",
},
},
rules: {
// Import plugin rules
...importPlugin.configs.recommended.rules,
...importPlugin.configs.typescript.rules,
"import/namespace": "off",
"import/order": [ "error", {
groups: ["type", "builtin", "external", "internal", "parent", "sibling", "index", "object"],
}],
"import/first": "error",
"import/newline-after-import": "error",
"import/exports-last": "error",
},
};
Loading

0 comments on commit f25c367

Please sign in to comment.