From 27e42e590dc7aaf5dfb4e44d93634258470507f1 Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Tue, 3 Sep 2024 15:39:37 +0900 Subject: [PATCH] chore: add extensions for import --- eslint.config.mjs | 25 +- package.json | 5 +- packages/jsx-compiler/src/compile.test.ts | 4 +- packages/jsx-compiler/src/compile.ts | 12 +- packages/jsx-compiler/src/index.ts | 12 +- packages/jsx-compiler/src/ir/component.ts | 6 +- packages/jsx-compiler/src/ir/index.ts | 6 +- packages/jsx-compiler/src/ir/jsx.ts | 14 +- packages/jsx-compiler/src/ir/nodes.ts | 3 +- packages/jsx-compiler/src/transform.test.ts | 8 +- packages/jsx-compiler/src/transform.ts | 10 +- .../jsx-compiler/src/transforms/_utils.ts | 12 +- .../jsx-compiler/src/transforms/context.ts | 20 +- packages/jsx-compiler/src/transforms/index.ts | 16 +- .../src/transforms/transformChildren.test.ts | 10 +- .../src/transforms/transformChildren.ts | 12 +- .../src/transforms/transformComment.test.ts | 12 +- .../src/transforms/transformComment.ts | 2 +- .../src/transforms/transformElement.test.ts | 14 +- .../src/transforms/transformElement.ts | 20 +- .../src/transforms/transformText.test.ts | 12 +- .../src/transforms/transformText.ts | 20 +- packages/jsx-compiler/src/transforms/types.ts | 8 +- packages/jsx-compiler/src/transforms/utils.ts | 27 +- .../jsx-compiler/src/transforms/vBind.test.ts | 16 +- packages/jsx-compiler/src/transforms/vBind.ts | 4 +- .../jsx-compiler/src/transforms/vOn.test.ts | 16 +- packages/jsx-compiler/src/transforms/vOn.ts | 8 +- packages/jsx-explorer/build.config.ts | 4 +- packages/jsx-explorer/src/index.ts | 8 +- packages/jsx-explorer/src/options.ts | 2 +- packages/react-vapor-hooks/src/_helper.ts | 8 +- packages/react-vapor-hooks/src/index.ts | 2 +- packages/react-vapor-hooks/src/internal.ts | 2 +- .../react-vapor-hooks/src/useState.test.ts | 12 +- packages/react-vapor-hooks/src/useState.ts | 8 +- packages/shared/src/index.ts | 6 +- .../src/compileScript.test.ts | 6 +- .../svelte-sfc-compiler/src/compileScript.ts | 2 +- .../src/compileTemplate.test.ts | 6 +- .../src/compileTemplate.ts | 6 +- packages/svelte-sfc-compiler/src/index.ts | 10 +- .../svelte-sfc-compiler/src/parse.test.ts | 4 +- packages/svelte-sfc-compiler/src/parse.ts | 12 +- .../svelte-sfc-compiler/src/style/cssVars.ts | 2 +- .../svelte-sfc-compiler/src/transform.test.ts | 6 +- packages/svelte-sfc-compiler/src/transform.ts | 20 +- packages/svelte-sfc-compiler/src/types.ts | 22 +- .../src/compile.test.ts | 4 +- .../svelte-template-compiler/src/compile.ts | 10 +- .../svelte-template-compiler/src/index.ts | 12 +- .../src/ir/component.ts | 6 +- .../src/ir/converter.test.ts | 10 +- .../src/ir/converter.ts | 18 +- .../svelte-template-compiler/src/ir/index.ts | 6 +- .../svelte-template-compiler/src/ir/nodes.ts | 11 +- .../svelte-template-compiler/src/ir/svelte.ts | 32 +- .../src/transform.test.ts | 8 +- .../svelte-template-compiler/src/transform.ts | 9 +- .../src/transforms/_utils.ts | 14 +- .../src/transforms/context.ts | 22 +- .../src/transforms/index.ts | 18 +- .../src/transforms/transformChildren.test.ts | 10 +- .../src/transforms/transformChildren.ts | 7 +- .../src/transforms/transformComment.test.ts | 12 +- .../src/transforms/transformComment.ts | 8 +- .../src/transforms/transformElement.test.ts | 14 +- .../src/transforms/transformElement.ts | 34 +- .../src/transforms/transformText.test.ts | 12 +- .../src/transforms/transformText.ts | 24 +- .../src/transforms/types.ts | 8 +- .../src/transforms/utils.ts | 4 +- .../src/transforms/vBind.test.ts | 16 +- .../src/transforms/vBind.ts | 6 +- .../src/transforms/vOn.test.ts | 16 +- .../src/transforms/vOn.ts | 11 +- .../svelte-template-explorer/build.config.ts | 4 +- .../svelte-template-explorer/src/index.ts | 6 +- .../svelte-template-explorer/src/options.ts | 4 +- packages/unplugin-react/scripts/postbuild.ts | 6 +- packages/unplugin-react/src/astro.ts | 4 +- .../unplugin-react/src/core/transform.test.ts | 2 +- packages/unplugin-react/src/core/transform.ts | 10 +- packages/unplugin-react/src/core/types.ts | 4 +- packages/unplugin-react/src/esbuild.ts | 2 +- packages/unplugin-react/src/index.ts | 4 +- packages/unplugin-react/src/rollup.ts | 2 +- packages/unplugin-react/src/rspack.ts | 5 +- packages/unplugin-react/src/vite.ts | 2 +- packages/unplugin-react/src/webpack.ts | 2 +- packages/unplugin-svelte/scripts/postbuild.ts | 6 +- packages/unplugin-svelte/src/astro.ts | 4 +- .../unplugin-svelte/src/core/descriptor.ts | 10 +- packages/unplugin-svelte/src/core/script.ts | 8 +- packages/unplugin-svelte/src/core/style.ts | 2 +- packages/unplugin-svelte/src/core/template.ts | 8 +- .../unplugin-svelte/src/core/transform.ts | 20 +- packages/unplugin-svelte/src/core/types.ts | 5 +- packages/unplugin-svelte/src/core/utils.ts | 8 +- packages/unplugin-svelte/src/esbuild.ts | 4 +- packages/unplugin-svelte/src/index.ts | 16 +- packages/unplugin-svelte/src/nuxt.ts | 6 +- packages/unplugin-svelte/src/rollup.ts | 4 +- packages/unplugin-svelte/src/rspack.ts | 5 +- packages/unplugin-svelte/src/vite.ts | 4 +- packages/unplugin-svelte/src/webpack.ts | 4 +- pnpm-lock.yaml | 295 ++++++++++++++---- 107 files changed, 748 insertions(+), 562 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index dd5b764..22373c7 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,16 +1,17 @@ import { + comments, defineConfig, + imports, javascript, - comments, - typescript, jsonc, - unicorn, + react, regexp, + toml, + typescript, + unicorn, vue, - react, // svelte, - yaml, - toml + yaml } from '@kazupon/eslint-config' export default defineConfig( @@ -40,7 +41,17 @@ export default defineConfig( // TODO: // sometimes, Resolving `parserOptions.project` is not working in `.svelte` files. // extraFileExtensions: ['.vue', '.svelte'] - extraFileExtensions: ['.vue'] + extraFileExtensions: ['.vue'], + rules: { + '@typescript-eslint/consistent-type-imports': ['error', { disallowTypeAnnotations: false }] + } + }), + imports({ + typescript: true, + rules: { + 'import-x/first': 'error', + 'import-x/extensions': ['error', 'always', { ignorePackages: true }] + } }), jsonc({ json: true, diff --git a/package.json b/package.json index 68135af..517afaa 100644 --- a/package.json +++ b/package.json @@ -50,11 +50,13 @@ "watch:unplugin": "pnpm run --filter=./packages/unplugin-svelte watch" }, "devDependencies": { - "@kazupon/eslint-config": "^0.15.0", + "@kazupon/eslint-config": "^0.17.0", "@kazupon/prettier-config": "^0.1.1", "@types/node": "^20.14.10", "bumpp": "^9.5.2", "eslint": "^9.9.0", + "eslint-import-resolver-typescript": "^3.6.3", + "eslint-plugin-import-x": "^4.1.1", "eslint-plugin-jsonc": "^2.16.0", "eslint-plugin-react": "^7.35.0", "eslint-plugin-react-hooks": "^4.6.2", @@ -63,6 +65,7 @@ "eslint-plugin-svelte": "^2.43.0", "eslint-plugin-toml": "^0.11.1", "eslint-plugin-unicorn": "^54.0.0", + "eslint-plugin-unused-imports": "^4.1.3", "eslint-plugin-vue": "^9.27.0", "eslint-plugin-yml": "^1.14.0", "gh-changelogen": "^0.2.8", diff --git a/packages/jsx-compiler/src/compile.test.ts b/packages/jsx-compiler/src/compile.test.ts index 94fa56f..2f607b4 100644 --- a/packages/jsx-compiler/src/compile.test.ts +++ b/packages/jsx-compiler/src/compile.test.ts @@ -1,6 +1,6 @@ -import { describe, test, expect } from 'vitest' import { parse } from '@babel/parser' -import { compile } from './compile' +import { describe, expect, test } from 'vitest' +import { compile } from './compile.ts' const jsxCode = ` (