Skip to content

Commit

Permalink
chore: update deps and use flat-config of ESLint
Browse files Browse the repository at this point in the history
  • Loading branch information
condorheroblog committed Aug 16, 2024
1 parent 7856f24 commit 90326a7
Show file tree
Hide file tree
Showing 54 changed files with 5,201 additions and 4,921 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches:
- main
paths:
- "packages/playground/react-sample/src/**"
- 'packages/playground/react-sample/src/**'

jobs:
build-and-deploy:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ permissions:
on:
push:
tags:
- "v*"
- 'v*'

jobs:
release:
Expand Down
38 changes: 18 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default defineFakeRoute([
id: "@guid",
username: "@first",
email: "@email",
avatar: '@image("200x200")',
avatar: "@image(\"200x200\")",
role: "admin",
});
},
Expand Down Expand Up @@ -95,14 +95,14 @@ The defineFakeRoute function parameters require the user to enter the route type

```ts
export interface FakeRoute {
url: string;
method?: HttpMethodType;
timeout?: number;
statusCode?: number;
statusText?: string;
headers?: OutgoingHttpHeaders;
response?: (processedRequest: ProcessedRequest, req: IncomingMessage, res: ServerResponse) => any;
rawResponse?: (req: IncomingMessage, res: ServerResponse) => void;
url: string
method?: HttpMethodType
timeout?: number
statusCode?: number
statusText?: string
headers?: OutgoingHttpHeaders
response?: (processedRequest: ProcessedRequest, req: IncomingMessage, res: ServerResponse) => any
rawResponse?: (req: IncomingMessage, res: ServerResponse) => void
}

export function defineFakeRoute(config: FakeRoute | FakeRoute[]) {
Expand Down Expand Up @@ -215,13 +215,13 @@ Compared with the development environment, the API interface defined in the prod

```ts
export interface FakeRoute {
url: string;
method?: HttpMethodType;
timeout?: number;
statusCode?: number;
statusText?: string;
headers?: OutgoingHttpHeaders;
response?: (processedRequest: ProcessedRequest) => any;
url: string
method?: HttpMethodType
timeout?: number
statusCode?: number
statusText?: string
headers?: OutgoingHttpHeaders
response?: (processedRequest: ProcessedRequest) => any
}
```

Expand All @@ -246,13 +246,13 @@ interface ServerBuildOptions {
* @description Server port
* @default 8888
*/
port?: number;
port?: number
/**
* Directory relative from `root` where build output will be placed. If the
* directory exists, it will be removed before the build.
* @default "fakeServer"
*/
outDir?: string;
outDir?: string
}
```

Expand All @@ -279,7 +279,6 @@ interface ServerBuildOptions {
# packages/vite-plugin-fake-server
npm run build:watch
# packages/playground/react-sample
npm run dev
```
Expand All @@ -290,7 +289,6 @@ npm run dev
# packages/vite-plugin-fake-server
npm run build:watch
# packages/playground/react-sample
npm run build
npm run preview
Expand Down
106 changes: 12 additions & 94 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,95 +1,13 @@
import js from "@eslint/js";
import pluginTypeScript from "@typescript-eslint/eslint-plugin";
import parserTypeScript from "@typescript-eslint/parser";
import configPrettier from "eslint-config-prettier";
import { defineFlatConfig } from "eslint-define-config";
import * as pluginImport from "eslint-plugin-import";
import pluginNodeImport from "eslint-plugin-node-import";
import pluginPrettier from "eslint-plugin-prettier";
import antfu from "@antfu/eslint-config";

export default defineFlatConfig([
{
linterOptions: {
reportUnusedDisableDirectives: true,
},
},
{
...js.configs.recommended,
plugins: {
prettier: pluginPrettier,
},
rules: {
...configPrettier.rules,
...pluginPrettier.configs.recommended.rules,
},
},
{
plugins: {
import: pluginImport,
},
rules: {
// https://github.com/import-js/eslint-plugin-import/issues/2556
// ...pluginImport.configs.recommended.rules,
"import/first": "error",
"import/no-duplicates": "error",
"import/no-mutable-exports": "error",
"import/no-named-default": "error",
"import/no-self-import": "error",
"import/no-webpack-loader-syntax": "error",
"import/order": ["error", { "newlines-between": "always" }],
"import/newline-after-import": "error",
},
},
{
plugins: {
"node-import": pluginNodeImport,
},
rules: {
"node-import/prefer-node-protocol": 2,
},
},
{
files: ["**/*.?([cm])ts", "**/*.?([cm])tsx"],
languageOptions: {
parser: parserTypeScript,
},
plugins: {
"@typescript-eslint": pluginTypeScript,
},
rules: {
...pluginTypeScript.configs.strict.rules,
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-non-null-assertion": "off",
},
},
{
ignores: [
"*.min.*",
"*.d.ts",
"CHANGELOG.md",
"dist",
"build",
"LICENSE*",
"output",
"out",
"coverage",
"public",
"temp",
"package-lock.json",
"pnpm-lock.yaml",
"yarn.lock",
"__snapshots__",
"*.css",
"*.png",
"*.ico",
"*.toml",
"*.patch",
"*.txt",
"*.crt",
"*.key",
"Dockerfile",
"!.github",
"!.vscode",
],
},
]);
export default antfu({
rules: {
"style/quotes": ["error", "double"],
"style/semi": ["error", "always"],
"style/indent": ["error", "tab"],
"jsonc/indent": ["error", "tab"],
"style/no-tabs": "off",
"style/jsx-indent-props": ["error", "tab"],
"style/no-mixed-spaces-and-tabs": ["error", "smart-tabs"],
},
});
65 changes: 24 additions & 41 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,73 +1,56 @@
{
"name": "@condorhero/monorepo",
"type": "module",
"version": "2.1.1",
"private": true,
"type": "module",
"license": "MIT",
"packageManager": "[email protected]",
"author": "Condor Hero",
"packageManager": "[email protected]",
"description": "A fake server plugin for Vite.",
"author": "Condor Hero",
"license": "MIT",
"homepage": "https://github.com/condorheroblog/vite-plugin-fake-server/blob/main/README.md",
"repository": {
"type": "git",
"url": "git+https://github.com/condorheroblog/vite-plugin-fake-server.git"
},
"bugs": {
"url": "https://github.com/condorheroblog/vite-plugin-fake-server/issues"
},
"homepage": "https://github.com/condorheroblog/vite-plugin-fake-server/blob/main/README.md",
"scripts": {
"postinstall": "simple-git-hooks",
"prepublishOnly": "nr build",
"dev": "esno index.ts",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"format": "prettier --write .",
"test": "vitest",
"build": "nr -r build",
"build:watch": "nr -r build:watch",
"typecheck": "tsc --noEmit",
"release": "bumpp -r && pnpm -r publish --access public"
},
"devDependencies": {
"@antfu/eslint-config": "^2.25.2",
"@rollup/plugin-json": "^6.1.0",
"@types/node": "^22.3.0",
"bumpp": "^9.5.1",
"esbuild": "^0.23.0",
"eslint": "^9.9.0",
"esno": "^4.7.0",
"lint-staged": "^15.2.9",
"rimraf": "^5.0.10",
"rollup": "^4.20.0",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-esbuild": "^6.1.1",
"rollup-plugin-node-externals": "^7.1.2",
"simple-git-hooks": "^2.11.1",
"typescript": "^5.5.4",
"vitest": "^2.0.5"
},
"simple-git-hooks": {
"pre-commit": "npx lint-staged"
},
"lint-staged": {
"*.{ts,js,mjs,cjs,cts,mts,json}": [
"eslint --fix",
"prettier --write"
],
"*.md": [
"*.{ts,js,mjs,cjs,cts,mts,json,md}": [
"eslint --fix"
],
"*.vue": [
"prettier --write"
]
},
"devDependencies": {
"@eslint/js": "^8.56.0",
"@rollup/plugin-json": "^6.1.0",
"@types/node": "^20.11.0",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser": "^6.18.1",
"bumpp": "^9.2.1",
"esbuild": "^0.19.11",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-define-config": "^2.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-mdx": "^3.1.5",
"eslint-plugin-node-import": "^1.0.4",
"eslint-plugin-prettier": "^5.1.3",
"esno": "^4.0.0",
"lint-staged": "^15.2.0",
"prettier": "^3.2.2",
"rimraf": "^5.0.5",
"rollup": "^4.9.5",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-esbuild": "^6.1.0",
"rollup-plugin-node-externals": "^6.1.2",
"simple-git-hooks": "^2.9.0",
"typescript": "^5.3.3",
"vitest": "^1.2.0"
}
}
16 changes: 8 additions & 8 deletions packages/playground/http2-sample/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"name": "http2-sample",
"private": true,
"version": "2.1.1",
"type": "module",
"version": "2.1.1",
"private": true,
"scripts": {
"dev": "vite",
"build": "vue-tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.4.13"
"vue": "^3.4.38"
},
"devDependencies": {
"@vitejs/plugin-basic-ssl": "^1.0.2",
"@vitejs/plugin-vue": "^5.0.3",
"typescript": "^5.3.3",
"vite": "^5.0.11",
"@vitejs/plugin-basic-ssl": "^1.1.0",
"@vitejs/plugin-vue": "^5.1.2",
"typescript": "^5.5.4",
"vite": "^5.4.1",
"vite-plugin-fake-server": "workspace:^",
"vue-tsc": "^1.8.27"
"vue-tsc": "^2.0.29"
}
}
20 changes: 10 additions & 10 deletions packages/playground/http2-sample/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"compilerOptions": {
"target": "ES2020",
"jsx": "preserve",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
"paths": {
"@/*": ["./fake/*"]
},
"resolveJsonModule": true,
"allowImportingTsExtensions": true,

/* Linting */
"strict": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
"noEmit": true,
"isolatedModules": true,
"skipLibCheck": true
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
"references": [{ "path": "./tsconfig.node.json" }],
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
}
4 changes: 2 additions & 2 deletions packages/playground/http2-sample/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
},
"include": ["vite.config.ts"]
}
Loading

0 comments on commit 90326a7

Please sign in to comment.