diff --git a/.eslintrc.js b/.eslintrc.js index 24029fa..85f8beb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -69,6 +69,22 @@ module.exports = { 'import/extensions': 'off', 'import/no-unresolved': 'off', 'import/no-extraneous-dependencies': 'off', + 'import/order': ['error', { + warnOnUnassignedImports: true, + alphabetize: { + order: 'asc', + caseInsensitive: false, + }, + pathGroups: [ + { + 'pattern': '@/**', + 'group': 'parent', + }, + ], + groups: [ + 'builtin', 'external', 'parent', 'sibling', 'index', 'object', 'type', + ], + }], 'comma-dangle': 'off', '@typescript-eslint/comma-dangle': ['error', 'always-multiline'], diff --git a/example/src/app.ts b/example/src/app.ts index 0715f8e..fecad83 100644 --- a/example/src/app.ts +++ b/example/src/app.ts @@ -1,11 +1,11 @@ +import { useSSRContext } from '@vue/runtime-core' +import { Quasar } from 'quasar/src/index.all' import { createSSRApp } from 'vue' import App from './components/App.vue' import { createAppRouter } from './router' -import type { createRouter } from 'vue-router' import type { SSRContext } from '@vue/server-renderer' -import { useSSRContext } from '@vue/runtime-core' import type express from 'express' -import { Quasar } from 'quasar/src/index.all' +import type { createRouter } from 'vue-router' interface CreatedApp { app: ReturnType diff --git a/example/src/entryServer.ts b/example/src/entryServer.ts index eb6d667..f2126ed 100644 --- a/example/src/entryServer.ts +++ b/example/src/entryServer.ts @@ -1,10 +1,10 @@ -import express from 'express' -import http from 'http' import assert from 'assert' -import { VueSsrAssetRenderer } from 'vue-ssr-assets-plugin' +import http from 'http' +import path from 'path' import { renderToString } from '@vue/server-renderer' +import express from 'express' +import { VueSsrAssetRenderer } from 'vue-ssr-assets-plugin' import { AppContext, createApp } from './app' -import path from 'path' // ----------------------------------------------------------------------------- // Express diff --git a/example/src/router.ts b/example/src/router.ts index d25cb1c..add22fc 100644 --- a/example/src/router.ts +++ b/example/src/router.ts @@ -1,5 +1,5 @@ -import type { SSRContext } from '@vue/server-renderer' import { createMemoryHistory, createRouter, createWebHistory, type Router } from 'vue-router' +import type { SSRContext } from '@vue/server-renderer' // ---------------------------------------------------------------------------- // Router diff --git a/example/webpack.config.ts b/example/webpack.config.ts index a9312af..b4827c1 100644 --- a/example/webpack.config.ts +++ b/example/webpack.config.ts @@ -1,12 +1,12 @@ import path from 'path' -import { Configuration, DefinePlugin } from 'webpack' -import { VueLoaderPlugin } from 'vue-loader' -import merge from 'webpack-merge' -import nodeExternals from 'webpack-node-externals' import CopyWebpackPlugin from 'copy-webpack-plugin' import MiniCssExtractPlugin from 'mini-css-extract-plugin' +import { VueLoaderPlugin } from 'vue-loader' import { VueSsrAssetsClientPlugin, VueSsrAssetsServerPlugin } from 'vue-ssr-assets-plugin' +import { Configuration, DefinePlugin } from 'webpack' import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer' +import merge from 'webpack-merge' +import nodeExternals from 'webpack-node-externals' import { QuasarUnusedPlugin } from '../src' // ---------------------------------------------------------------------------- diff --git a/src/utils/findCallExpressions.ts b/src/utils/findCallExpressions.ts index d137097..7b57e08 100644 --- a/src/utils/findCallExpressions.ts +++ b/src/utils/findCallExpressions.ts @@ -1,5 +1,5 @@ -import type { CallExpression, Node } from 'estree' import { visitChildren } from './visitChildren' +import type { CallExpression, Node } from 'estree' export function findCallExpressions(root: Node, calleeName: string): Array { const isTargetCallExpression = (node: Node): node is CallExpression => { diff --git a/src/utils/findImportLocalId.ts b/src/utils/findImportLocalId.ts index 90b1494..da07cb1 100644 --- a/src/utils/findImportLocalId.ts +++ b/src/utils/findImportLocalId.ts @@ -1,5 +1,5 @@ -import type { ImportDefaultSpecifier, ImportSpecifier, Node } from 'estree' import { visitChildren } from './visitChildren' +import type { ImportDefaultSpecifier, ImportSpecifier, Node } from 'estree' export function findImportLocalId(root: Node, importSource: string, importName: string): string | undefined { const search = (node: Node): ImportSpecifier | ImportDefaultSpecifier | undefined => { diff --git a/src/utils/stringifyEstree.ts b/src/utils/stringifyEstree.ts index b736877..deee9c1 100644 --- a/src/utils/stringifyEstree.ts +++ b/src/utils/stringifyEstree.ts @@ -1,5 +1,5 @@ -import type { Node } from 'estree' import { isEstreeNode } from './isEstreeNode' +import type { Node } from 'estree' export function stringifyEstree(root: Node): string { let str = '' diff --git a/src/utils/visitChildren.ts b/src/utils/visitChildren.ts index f733800..deee290 100644 --- a/src/utils/visitChildren.ts +++ b/src/utils/visitChildren.ts @@ -1,5 +1,5 @@ -import type { Node } from 'estree' import { isEstreeNode } from './isEstreeNode' +import type { Node } from 'estree' export function visitChildren(node: Node, visitNode: (node: Node) => T | undefined): T | undefined { for (const value of Object.values(node)) { diff --git a/src/webpack/QuasarUnusedLoader.ts b/src/webpack/QuasarUnusedLoader.ts index fd2b226..2b96d51 100644 --- a/src/webpack/QuasarUnusedLoader.ts +++ b/src/webpack/QuasarUnusedLoader.ts @@ -1,6 +1,6 @@ import { PLUGIN_NAME, QUASAR_INDEX_FILE } from '../Constants' -import type { LoaderContext } from 'webpack' import type { QuasarUnusedLoaderOptions } from './QuasarUnusedLoaderOptions' +import type { LoaderContext } from 'webpack' // eslint-disable-next-line @typescript-eslint/naming-convention export function QuasarUnusedLoader(this: LoaderContext, source: string): string { diff --git a/src/webpack/QuasarUnusedPlugin.ts b/src/webpack/QuasarUnusedPlugin.ts index 50734b2..53bd54b 100644 --- a/src/webpack/QuasarUnusedPlugin.ts +++ b/src/webpack/QuasarUnusedPlugin.ts @@ -1,15 +1,15 @@ +import assert from 'assert' +import { existsSync } from 'fs' +import path from 'path' +import quasarAutoImportJson from 'quasar/dist/transforms/auto-import.json' +import quasarJson from 'quasar/package.json' import { WebpackPluginInstance, Compiler, javascript, NormalModule, Compilation } from 'webpack' import { PLUGIN_NAME, QUASAR_INDEX_FILE } from '../Constants' -import quasarAutoImportJson from 'quasar/dist/transforms/auto-import.json' +import { findCallExpressions } from '../utils/findCallExpressions' +import { findImportLocalId } from '../utils/findImportLocalId' +import { QuasarUnusedPluginOptions, validateQuasarUnusedPluginOptions } from './QuasarUnusedPluginOptions' import { ReplaceValueDependency } from './ReplaceValueDependency' -import quasarJson from 'quasar/package.json' -import path from 'path' -import { existsSync } from 'fs' import type { QuasarUnusedLoaderOptions } from './QuasarUnusedLoaderOptions' -import { QuasarUnusedPluginOptions, validateQuasarUnusedPluginOptions } from './QuasarUnusedPluginOptions' -import { findImportLocalId } from '../utils/findImportLocalId' -import { findCallExpressions } from '../utils/findCallExpressions' -import assert from 'assert' interface QuasarAutoImport { importName: Record diff --git a/src/webpack/ReplaceValueDependency.ts b/src/webpack/ReplaceValueDependency.ts index bcb0b50..f5c6fc2 100644 --- a/src/webpack/ReplaceValueDependency.ts +++ b/src/webpack/ReplaceValueDependency.ts @@ -1,5 +1,5 @@ -import { PLUGIN_NAME } from '../Constants' import { Dependency, javascript, Generator, sources } from 'webpack' +import { PLUGIN_NAME } from '../Constants' type DependencyTemplate = ReturnType[1]['dependencyTemplates']['get']> type Expression = Parameters[0]