Skip to content

Commit

Permalink
chore: use eslint and eslint-plugin-simple-import-sort for import…
Browse files Browse the repository at this point in the history
… sorting(waiting until `dprint` support grouped import sorting
  • Loading branch information
stijnvanhulle committed Oct 21, 2023
1 parent 0913b53 commit 687a015
Show file tree
Hide file tree
Showing 45 changed files with 248 additions and 216 deletions.
4 changes: 3 additions & 1 deletion .dprint.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
"binaryExpression.linePerExpression": true,
"jsx.quoteStyle": "preferDouble",
"preferSingleLine": false,
"preferHanging": true
"preferHanging": true,
// https://github.com/lydell/eslint-plugin-simple-import-sort/tree/main?tab=readme-ov-file#how-do-i-use-this-with-dprint
"module.sortImportDeclarations": "maintain"
},
"json": {
"trailingCommas": "never"
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"packages/swagger-msw": "1.14.0",
"packages/react": "1.14.0",
".": "1.14.0"
}
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,12 @@
"upgrade": "npx taze -r -w --exclude pnpm"
},
"devDependencies": {
"@ianvs/prettier-plugin-sort-imports": "^4.1.1",
"@kubb/eslint-config": "workspace:*",
"@kubb/ts-config": "workspace:*",
"@types/node": "^20.8.7",
"@vitest/coverage-v8": "^0.34.6",
"@vitest/ui": "^0.34.6",
"bun-types": "^1.0.6",
"bun-types": "^1.0.7",
"dprint": "^0.41.0",
"prettier": "^3.0.3",
"prettier-eslint": "^15.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { getSummary } from './utils/getSummary.ts'
import { OraWritable } from './utils/OraWritable.ts'
import { spinner } from './utils/spinner.ts'

import type { Writable } from 'node:stream'
import type { CLIOptions, KubbConfig, Logger } from '@kubb/core'
import type { ExecaReturnValue } from 'execa'
import type { Writable } from 'node:stream'

type GenerateProps = {
input?: string
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { cac } from 'cac'
import pc from 'picocolors'

import { version } from '../package.json'
import { getConfig, getCosmiConfig, renderErrors, spinner, startWatcher } from './utils/index.ts'
import generate from './generate.ts'
import init from './init.ts'
import { getConfig, getCosmiConfig, renderErrors, spinner, startWatcher } from './utils/index.ts'

import type { CLIOptions } from '@kubb/core'

Expand Down
5 changes: 3 additions & 2 deletions packages/config/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
},
"dependencies": {
"@eslint/js": "^8.51.0",
"@eslint/js": "^8.52.0",
"@types/eslint": "~8.44.6",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "~6.7.5",
Expand All @@ -49,6 +49,7 @@
"eslint-plugin-eslint-plugin": "^5.1.1",
"eslint-plugin-import": "~2.28.1",
"eslint-plugin-react": "~7.33.2",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-unused-imports": "~3.0.0",
"eslint-plugin-vitest": "~0.3.3",
"eslint-plugin-vitest-globals": "~1.4.0",
Expand All @@ -57,7 +58,7 @@
"devDependencies": {
"@kubb/ts-config": "workspace:*",
"@kubb/tsup-config": "workspace:*",
"eslint": "^8.51.0",
"eslint": "^8.52.0",
"tsup": "^7.2.0",
"typescript": "~5.2.2"
},
Expand Down
5 changes: 3 additions & 2 deletions packages/config/eslint-config/src/flat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ import prettier from 'eslint-config-prettier'
/**
* Recommended plugins ESM
*/

// @ts-ignore
import eslintPluginRecommended from 'eslint-plugin-eslint-plugin/configs/recommended'
/**
* Plugins
*/

// @ts-ignore
import importPlugin from 'eslint-plugin-import'
// @ts-ignore
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort'
// @ts-ignore
import turboPlugin from 'eslint-plugin-turbo'
// @ts-ignore
import unusedImportsPlugin from 'eslint-plugin-unused-imports'
Expand Down Expand Up @@ -73,6 +73,7 @@ export const config: Linter.FlatConfig = {
'unused-imports': unusedImportsPlugin,
import: importPlugin,
turbo: turboPlugin,
'simple-import-sort': simpleImportSortPlugin,
},
languageOptions: {
ecmaVersion: 'latest',
Expand Down
2 changes: 1 addition & 1 deletion packages/config/eslint-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const config: Linter.Config = {
'plugin:@typescript-eslint/stylistic-type-checked',
'plugin:react/recommended',
],
plugins: ['@typescript-eslint', 'vitest', 'vitest-globals', 'unused-imports', 'import', 'turbo'],
plugins: ['@typescript-eslint', 'vitest', 'vitest-globals', 'unused-imports', 'import', 'simple-import-sort', 'turbo'],
rules,
overrides: [
{
Expand Down
38 changes: 38 additions & 0 deletions packages/config/eslint-config/src/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,44 @@ export const rules: Linter.FlatConfig['rules'] = {
'import/no-extraneous-dependencies': 'off',
'import/no-unresolved': 'off',
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
// 'import/order': [
// 'error',
// {
// 'newlines-between': 'always',
// pathGroups: [
// {
// pattern: '@kubb/**',
// group: 'internal',
// position: 'before',
// },
// ],
// distinctGroup: false,
// alphabetize: {
// orderImportKind: 'asc',
// caseInsensitive: true,
// },
// groups: ['builtin', 'external', 'internal', ['sibling', 'parent'], 'index', 'object', 'type'],
// },
// ],
// 'sort-imports': ['error', { ignoreDeclarationSort: true }],
'simple-import-sort/imports': [
'error',
{
groups: [
// Node.js builtins prefixed with `node:`.
['^node:'],
// Dependency Packages
['^@kubb'],
['^@?\\w', '^\\u0000'],
// Parent imports. Put `..` last.
// Other relative imports. Put same-folder imports and `.` last.
['^\\.\\.(?!/?$)', '^\\.\\./?$', '^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
// types
['^node:.*\\u0000$', '^@kubb.*\\u0000$', '^@?\\w.*\\u0000$', '^[^.].*\\u0000$', '^\\..*\\u0000$'],
],
},
],
'simple-import-sort/exports': ['error'],
'turbo/no-undeclared-env-vars': 'off',
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': ['warn', { vars: 'all', varsIgnorePattern: '^_', args: 'after-used', argsIgnorePattern: '^_' }],
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"@types/react": "^18.2.31",
"@types/seedrandom": "^3.0.7",
"@types/semver": "^7.5.4",
"eslint": "^8.51.0",
"eslint": "^8.52.0",
"ora": "^7.0.1",
"tsup": "^7.2.0",
"typescript": "^5.2.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import pc from 'picocolors'

import { createFileSource } from './managers/fileManager/index.ts'
import { PluginManager } from './managers/pluginManager/index.ts'
import { LogLevel } from './types.ts'
import { clean, createLogger, randomPicoColour, read, URLPath } from './utils/index.ts'
import { isPromise } from './utils/isPromise.ts'
import { LogLevel } from './types.ts'

import type { KubbFile } from './managers/fileManager/index.ts'
import type { BuildOutput, KubbPlugin, PluginContext, TransformResult } from './types.ts'
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { build } from './build.ts'

export * from './build.ts'
export * from './config.ts'
export { createPlugin, pluginName, pluginName as name } from './plugin.ts'
export * from './types.ts'

export * from './generators/index.ts'
export * from './managers/index.ts'
export { createPlugin, pluginName as name, pluginName } from './plugin.ts'
export * from './types.ts'
export * from './utils/index.ts'

export default build
2 changes: 1 addition & 1 deletion packages/parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@kubb/eslint-config": "workspace:*",
"@kubb/ts-config": "workspace:*",
"@kubb/tsup-config": "workspace:*",
"eslint": "^8.51.0",
"eslint": "^8.52.0",
"tsup": "^7.2.0"
},
"packageManager": "[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"@kubb/tsup-config": "workspace:*",
"@types/react": "^18.2.31",
"@types/react-reconciler": "^0.28.6",
"eslint": "^8.51.0",
"eslint": "^8.52.0",
"react": "^18.2.0",
"react-reconciler": "^0.29.0",
"tsup": "^7.2.0"
Expand Down
9 changes: 3 additions & 6 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
export * from './types.ts'

export type { RootType } from './client/index.ts'
export { createRoot } from './client/index.ts'
export * from './components/index.ts'
export * from './hooks/index.ts'

export * from './shared/index.ts'

export { createRoot } from './client/index.ts'
export type { RootType } from './client/index.ts'
export * from './types.ts'
2 changes: 1 addition & 1 deletion packages/swagger-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"@kubb/tsup-config": "workspace:*",
"@types/react": "^18.2.31",
"axios": "^1.5.1",
"eslint": "^8.51.0",
"eslint": "^8.52.0",
"tsup": "^7.2.0",
"typescript": "^5.2.2"
},
Expand Down
6 changes: 1 addition & 5 deletions packages/swagger-client/src/builders/ClientBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,7 @@ export class ClientBuilder extends OasBuilder<Options> {
const file = useResolve({ pluginName, type: 'file' })
const fileType = useResolveType({ type: 'file' })

const resolvedClientPath = clientImportPath
? clientImportPath
: clientPath
? getRelativePath(file.path, clientPath)
: '@kubb/swagger-client/client'
const resolvedClientPath = clientImportPath ? clientImportPath : clientPath ? getRelativePath(file.path, clientPath) : '@kubb/swagger-client/client'

return (
<File baseName={file.baseName} path={file.path}>
Expand Down
5 changes: 2 additions & 3 deletions packages/swagger-client/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { definePlugin } from './plugin.ts'

export type { RequestConfig } from '../client.ts'
export * from './plugin.ts'
export * from './types.ts'

export * from './builders/index.ts'
export * from './components/index.ts'
export * from './generators/index.ts'
export * from './plugin.ts'
export * from './types.ts'

export default definePlugin
2 changes: 1 addition & 1 deletion packages/swagger-client/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PluginFactoryOptions } from '@kubb/core'
import type { OverrideBy, ResolvePathOptions, SkipBy, AppMeta as SwaggerAppMeta } from '@kubb/swagger'
import type { AppMeta as SwaggerAppMeta, OverrideBy, ResolvePathOptions, SkipBy } from '@kubb/swagger'
import type { CreateAxiosDefaults } from 'axios'

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/swagger-faker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"@kubb/eslint-config": "workspace:*",
"@kubb/ts-config": "workspace:*",
"@kubb/tsup-config": "workspace:*",
"eslint": "^8.51.0",
"eslint": "^8.52.0",
"tsup": "^7.2.0",
"typescript": "^5.2.2"
},
Expand Down
8 changes: 3 additions & 5 deletions packages/swagger-faker/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { definePlugin } from './plugin.ts'

export * from './plugin.ts'
export * from './types.ts'

export * from './builders/index.ts'
export * from './generators/index.ts'
export * from './parsers/index.ts'

export * from './hooks/index.ts'
export * from './parsers/index.ts'
export * from './plugin.ts'
export * from './types.ts'
export * from './utils/index.ts'

export default definePlugin
2 changes: 1 addition & 1 deletion packages/swagger-msw/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@kubb/eslint-config": "workspace:*",
"@kubb/ts-config": "workspace:*",
"@kubb/tsup-config": "workspace:*",
"eslint": "^8.51.0",
"eslint": "^8.52.0",
"tsup": "^7.2.0",
"typescript": "^5.2.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/swagger-msw/src/generators/OperationGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getRelativePath } from '@kubb/core'
import { OperationGenerator as Generator, resolve } from '@kubb/swagger'
import { resolve as resolveSwaggerFaker, pluginName as swaggerFakerPluginName } from '@kubb/swagger-faker'
import { pluginName as swaggerFakerPluginName, resolve as resolveSwaggerFaker } from '@kubb/swagger-faker'

import { MSWBuilder } from '../builders/index.ts'
import { pluginName } from '../plugin.ts'
Expand Down
5 changes: 2 additions & 3 deletions packages/swagger-msw/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { definePlugin } from './plugin.ts'

export * from './plugin.ts'
export * from './types.ts'

export * from './builders/index.ts'
export * from './generators/index.ts'
export * from './plugin.ts'
export * from './types.ts'

export default definePlugin
2 changes: 1 addition & 1 deletion packages/swagger-msw/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PluginFactoryOptions } from '@kubb/core'
import type { OverrideBy, ResolvePathOptions, SkipBy, AppMeta as SwaggerAppMeta } from '@kubb/swagger'
import type { AppMeta as SwaggerAppMeta, OverrideBy, ResolvePathOptions, SkipBy } from '@kubb/swagger'

export type Options = {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/swagger-swr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"@kubb/eslint-config": "workspace:*",
"@kubb/ts-config": "workspace:*",
"@kubb/tsup-config": "workspace:*",
"eslint": "^8.51.0",
"eslint": "^8.52.0",
"tsup": "^7.2.0",
"typescript": "^5.2.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/swagger-swr/src/generators/OperationGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getRelativePath } from '@kubb/core'
import { OperationGenerator as Generator, resolve } from '@kubb/swagger'
import { resolve as resolveSwaggerTypescript, pluginName as swaggerTypescriptPluginName } from '@kubb/swagger-ts'
import { pluginName as swaggerTypescriptPluginName, resolve as resolveSwaggerTypescript } from '@kubb/swagger-ts'

import { QueryBuilder } from '../builders/QueryBuilder.tsx'
import { pluginName } from '../plugin.ts'
Expand Down
5 changes: 2 additions & 3 deletions packages/swagger-swr/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { definePlugin } from './plugin.ts'

export * from './plugin.ts'
export * from './types.ts'

export * from './builders/index.ts'
export * from './generators/index.ts'
export * from './plugin.ts'
export * from './types.ts'

export default definePlugin
2 changes: 1 addition & 1 deletion packages/swagger-swr/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PluginFactoryOptions } from '@kubb/core'
import type { OverrideBy, ResolvePathOptions, SkipBy, AppMeta as SwaggerAppMeta } from '@kubb/swagger'
import type { AppMeta as SwaggerAppMeta, OverrideBy, ResolvePathOptions, SkipBy } from '@kubb/swagger'

export type Options = {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/swagger-tanstack-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"@kubb/ts-config": "workspace:*",
"@kubb/tsup-config": "workspace:*",
"@types/react": "^18.2.31",
"eslint": "^8.51.0",
"eslint": "^8.52.0",
"tsup": "^7.2.0",
"typescript": "^5.2.2"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getRelativePath, PackageManager } from '@kubb/core'
import { OperationGenerator as Generator, resolve } from '@kubb/swagger'
import { resolve as resolveSwaggerTypescript, pluginName as swaggerTypescriptPluginName } from '@kubb/swagger-ts'
import { pluginName as swaggerTypescriptPluginName, resolve as resolveSwaggerTypescript } from '@kubb/swagger-ts'

import { QueryBuilder } from '../builders/QueryBuilder.tsx'
import { pluginName } from '../plugin.ts'
Expand Down
5 changes: 2 additions & 3 deletions packages/swagger-tanstack-query/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { definePlugin } from './plugin.ts'

export * from './plugin.ts'
export * from './types.ts'

export * from './builders/index.ts'
export * from './components/index.ts'
export * from './generators/index.ts'
export * from './plugin.ts'
export * from './types.ts'

export default definePlugin
Loading

0 comments on commit 687a015

Please sign in to comment.