From 98471eee65db28a496f053c250df67b5cf718902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Fern=C3=A1ndez?= Date: Mon, 4 Nov 2024 19:14:39 +0000 Subject: [PATCH] chore(configs): fix wrong type mapping in TypeScript --- frontend/eslint.config.ts | 2 +- packages/configs/eslint.config.ts | 2 +- packages/configs/{eslint => lint}/index.ts | 0 .../configs/{eslint => lint}/rules/base.ts | 20 ++++++------ .../configs/{eslint => lint}/rules/env.ts | 4 +-- .../configs/{eslint => lint}/rules/i18n.ts | 0 .../configs/{eslint => lint}/rules/json.ts | 2 +- .../{eslint => lint}/rules/typescript-vue.ts | 32 +++++++++---------- .../configs/{eslint => lint}/rules/unocss.ts | 0 packages/configs/{eslint => lint}/shared.ts | 0 packages/configs/package.json | 2 +- packages/vite-plugins/eslint.config.ts | 2 +- 12 files changed, 33 insertions(+), 33 deletions(-) rename packages/configs/{eslint => lint}/index.ts (100%) rename packages/configs/{eslint => lint}/rules/base.ts (87%) rename packages/configs/{eslint => lint}/rules/env.ts (87%) rename packages/configs/{eslint => lint}/rules/i18n.ts (100%) rename packages/configs/{eslint => lint}/rules/json.ts (89%) rename packages/configs/{eslint => lint}/rules/typescript-vue.ts (79%) rename packages/configs/{eslint => lint}/rules/unocss.ts (100%) rename packages/configs/{eslint => lint}/shared.ts (100%) diff --git a/frontend/eslint.config.ts b/frontend/eslint.config.ts index d9012587..2089baab 100644 --- a/frontend/eslint.config.ts +++ b/frontend/eslint.config.ts @@ -1,5 +1,5 @@ import type { Linter } from 'eslint'; -import { getBaseConfig, getTSVueConfig, getNodeFiles, unocss, getWorkerFiles } from '@jellyfin-vue/configs/eslint'; +import { getBaseConfig, getTSVueConfig, getNodeFiles, unocss, getWorkerFiles } from '@jellyfin-vue/configs/lint'; // TODO: Add missing rules for i18n and json export default [ diff --git a/packages/configs/eslint.config.ts b/packages/configs/eslint.config.ts index 74204c94..17e8e99c 100644 --- a/packages/configs/eslint.config.ts +++ b/packages/configs/eslint.config.ts @@ -1,5 +1,5 @@ import type { Linter } from 'eslint'; -import { getBaseConfig, getTSVueConfig, getNodeFiles, tsFiles } from './eslint/'; +import { getBaseConfig, getTSVueConfig, getNodeFiles, tsFiles } from './lint/'; export default [ ...getBaseConfig('@jellyfin-vue/configs'), diff --git a/packages/configs/eslint/index.ts b/packages/configs/lint/index.ts similarity index 100% rename from packages/configs/eslint/index.ts rename to packages/configs/lint/index.ts diff --git a/packages/configs/eslint/rules/base.ts b/packages/configs/lint/rules/base.ts similarity index 87% rename from packages/configs/eslint/rules/base.ts rename to packages/configs/lint/rules/base.ts index 77a7e71c..f6113f8a 100644 --- a/packages/configs/eslint/rules/base.ts +++ b/packages/configs/lint/rules/base.ts @@ -40,12 +40,12 @@ export function getBaseConfig(packageName: string, forceCache = !CI_environment, const cacheLocation = join(findUpSync('node_modules', { type: 'directory' }) ?? '', '.cache/eslint', packageName.replace('/', '_')); newArgs.push('--cache', '--cache-location', cacheLocation); - console.log('[@jellyfin-vue/configs/eslint] Force enabling caching for this run'); + console.log('[@jellyfin-vue/configs/lint] Force enabling caching for this run'); } if (warningAsErrors && !newArgs.some(arg => arg.includes('--max-warnings'))) { newArgs.push('--max-warnings=0'); - console.log('[@jellyfin-vue/configs/eslint] Force enabling warnings for this run'); + console.log('[@jellyfin-vue/configs/lint] Force enabling warnings for this run'); } const argsHaveChanged = new Set(newArgs).difference(new Set(process.argv.slice(1))).size > 0; @@ -64,15 +64,15 @@ export function getBaseConfig(packageName: string, forceCache = !CI_environment, return [ { ...js.configs.recommended, - name: '(@jellyfin-vue/configs/eslint/base - eslint) Extended config from plugin' + name: '(@jellyfin-vue/configs/lint/base - eslint) Extended config from plugin' }, { ...unicorn.configs['flat/recommended'], - name: '(@jellyfin-vue/configs/eslint/base - unicorn) Extended config from plugin' + name: '(@jellyfin-vue/configs/lint/base - unicorn) Extended config from plugin' }, { ...dependConfigs['flat/recommended'], - name: '(@jellyfin-vue/configs/eslint/base - depend) Extended config from plugin' + name: '(@jellyfin-vue/configs/lint/base - depend) Extended config from plugin' }, { ...stylistic.configs.customize({ @@ -83,10 +83,10 @@ export function getBaseConfig(packageName: string, forceCache = !CI_environment, arrowParens: false, blockSpacing: true }), - name: '(@jellyfin-vue/configs/eslint/base - @stylistic) Extended config from plugin' + name: '(@jellyfin-vue/configs/lint/base - @stylistic) Extended config from plugin' }, { - name: '(@jellyfin-vue/configs/eslint/base) Common settings', + name: '(@jellyfin-vue/configs/lint/base) Common settings', rules: { 'no-empty': ['error', { allowEmptyCatch: true }], 'no-extend-native': 'error', @@ -150,13 +150,13 @@ export function getBaseConfig(packageName: string, forceCache = !CI_environment, }, { ...stylistic.configs['disable-legacy'], - name: '(@jellyfin-vue/configs/eslint/base) Disable stylistic legacy rules' + name: '(@jellyfin-vue/configs/lint/base) Disable stylistic legacy rules' }, /** * Extra files to include and ignores that should override all the others */ { - name: '(@jellyfin-vue/configs/eslint/base) Ignored files', + name: '(@jellyfin-vue/configs/lint/base) Ignored files', ignores: [ '**/.git', ...gitignore().ignores @@ -164,7 +164,7 @@ export function getBaseConfig(packageName: string, forceCache = !CI_environment, }, /** File progress plugin */ { - name: '(@jellyfin-vue/configs/eslint/base) Linting progress report', + name: '(@jellyfin-vue/configs/lint/base) Linting progress report', settings: { progress: { successMessage: 'Linting done!' diff --git a/packages/configs/eslint/rules/env.ts b/packages/configs/lint/rules/env.ts similarity index 87% rename from packages/configs/eslint/rules/env.ts rename to packages/configs/lint/rules/env.ts index 74febfea..e433908e 100644 --- a/packages/configs/eslint/rules/env.ts +++ b/packages/configs/lint/rules/env.ts @@ -7,7 +7,7 @@ import globals from 'globals'; */ export function getNodeFiles(files = ['*.config.*', 'scripts/**/*.ts']): Linter.Config[] { return [{ - name: '(@jellyfin-vue/configs/eslint/env) Node.js and development-related files', + name: '(@jellyfin-vue/configs/lint/env) Node.js and development-related files', files, languageOptions: { globals: { @@ -35,7 +35,7 @@ export function getNodeFiles(files = ['*.config.*', 'scripts/**/*.ts']): Linter. */ export function getWorkerFiles(files = ['**/*.worker.ts']): Linter.Config[] { return [{ - name: '(@jellyfin-vue/configs/eslint/env) WebWorkers', + name: '(@jellyfin-vue/configs/lint/env) WebWorkers', files, languageOptions: { globals: { diff --git a/packages/configs/eslint/rules/i18n.ts b/packages/configs/lint/rules/i18n.ts similarity index 100% rename from packages/configs/eslint/rules/i18n.ts rename to packages/configs/lint/rules/i18n.ts diff --git a/packages/configs/eslint/rules/json.ts b/packages/configs/lint/rules/json.ts similarity index 89% rename from packages/configs/eslint/rules/json.ts rename to packages/configs/lint/rules/json.ts index 63c5b902..492b42bd 100644 --- a/packages/configs/eslint/rules/json.ts +++ b/packages/configs/lint/rules/json.ts @@ -8,7 +8,7 @@ export const json = [ /* First index is just the plugin definition */ ...jsoncRecommended.at(0), ...jsoncRecommended.at(1), - name: '(@jellyfin-vue/configs/eslint/json) - Custom config', + name: '(@jellyfin-vue/configs/lint/json) - Custom config', rules: { ...jsoncRecommended.at(1).rules, ...jsoncRecommended.at(2).rules, diff --git a/packages/configs/eslint/rules/typescript-vue.ts b/packages/configs/lint/rules/typescript-vue.ts similarity index 79% rename from packages/configs/eslint/rules/typescript-vue.ts rename to packages/configs/lint/rules/typescript-vue.ts index 6d2ddf34..994084b3 100644 --- a/packages/configs/eslint/rules/typescript-vue.ts +++ b/packages/configs/lint/rules/typescript-vue.ts @@ -23,33 +23,33 @@ const flatArrayOfObjects = (obj: unknown[]) => Object.assign({}, ...obj); const common = [ { ...flatArrayOfObjects(tseslint.configs.strictTypeChecked), - name: '(@jellyfin-vue/configs/eslint/typescript-vue - typescript-eslint) Extended config from plugin (strict type checking)' + name: '(@jellyfin-vue/configs/lint/typescript-vue - typescript-eslint) Extended config from plugin (strict type checking)' }, { ...flatArrayOfObjects(tseslint.configs.stylisticTypeChecked), - name: '(@jellyfin-vue/configs/eslint/typescript-vue - typescript-eslint) Extended config from plugin (stylistic type checking)' + name: '(@jellyfin-vue/configs/lint/typescript-vue - typescript-eslint) Extended config from plugin (stylistic type checking)' }, { ...tseslint.configs.eslintRecommended, - name: '(@jellyfin-vue/configs/eslint/typescript-vue - typescript-eslint) Extended config from plugin (ESLint rules with type checking)' + name: '(@jellyfin-vue/configs/lint/typescript-vue - typescript-eslint) Extended config from plugin (ESLint rules with type checking)' }, { ...regexp.configs['flat/recommended'], - name: '(@jellyfin-vue/configs/eslint/typescript-vue - regexp) Extended config from plugin' + name: '(@jellyfin-vue/configs/lint/typescript-vue - regexp) Extended config from plugin' }, { ...promise.configs['flat/recommended'], - name: '(@jellyfin-vue/configs/eslint/typescript-vue - promise) Extended config from plugin' + name: '(@jellyfin-vue/configs/lint/typescript-vue - promise) Extended config from plugin' }, { - name: '(@jellyfin-vue/configs/eslint/typescript-vue - promise) Custom config', + name: '(@jellyfin-vue/configs/lint/typescript-vue - promise) Custom config', rules: { 'promise/prefer-await-to-callbacks': 'error', 'promise/prefer-await-to-then': 'error' } }, { - name: '(@jellyfin-vue/configs/eslint/typescript-vue - import) Custom config', + name: '(@jellyfin-vue/configs/lint/typescript-vue - import) Custom config', plugins: { 'import-x': eslintImportX }, @@ -65,7 +65,7 @@ const common = [ } }, { - name: '(@jellyfin-vue/configs/eslint/typescript-vue - JSDoc) Custom config', + name: '(@jellyfin-vue/configs/lint/typescript-vue - JSDoc) Custom config', plugins: { jsdoc }, @@ -78,7 +78,7 @@ const common = [ } }, { - name: '(@jellyfin-vue/configs/eslint/typescript-vue - TypeScript & Vue) Custom config', + name: '(@jellyfin-vue/configs/lint/typescript-vue - TypeScript & Vue) Custom config', rules: { '@typescript-eslint/no-redundant-type-constituents': 'off', '@typescript-eslint/restrict-template-expressions': 'off', @@ -110,7 +110,7 @@ const common = [ }, { ...sonarjs.configs.recommended, - name: '(@jellyfin-vue/configs/eslint/typescript-vue - sonarcloud) Extended config from plugin' + name: '(@jellyfin-vue/configs/lint/typescript-vue - sonarcloud) Extended config from plugin' } ] satisfies Linter.Config[]; @@ -126,18 +126,18 @@ const vue_config = [ * TODO: Remove when it's removed from the recommended rules */ delete config.rules?.['vue/component-tags-order']; - config.name = `(@jellyfin-vue/configs/eslint/typescript-vue - ${config.name}) - Extended config from plugin`; + config.name = `(@jellyfin-vue/configs/lint/typescript-vue - ${config.name}) - Extended config from plugin`; return config; }), { ...flatArrayOfObjects(vueScopedCSS.configs['flat/recommended']), - name: '(@jellyfin-vue/configs/eslint/typescript-vue - Vue Scoped CSS) Extended config from plugin', + name: '(@jellyfin-vue/configs/lint/typescript-vue - Vue Scoped CSS) Extended config from plugin', files: vueFiles }, { ...css.configs['flat/recommended'], - name: '(@jellyfin-vue/configs/eslint/typescript-vue - Vue CSS) Extended config from plugin', + name: '(@jellyfin-vue/configs/lint/typescript-vue - Vue CSS) Extended config from plugin', files: vueFiles }, { @@ -202,7 +202,7 @@ export function getTSVueConfig(enableVue = true, tsconfigRootDir = import.meta.d // Extracted from https://github.com/vuejs/eslint-config-typescript const base_vue_parser = { - name: '(@jellyfin-vue/configs/eslint/typescript-vue - Vue) Extra parser configuration for typed linting', + name: '(@jellyfin-vue/configs/lint/typescript-vue - Vue) Extra parser configuration for typed linting', files: vueFiles, languageOptions: { ...langOptions, @@ -216,8 +216,8 @@ export function getTSVueConfig(enableVue = true, tsconfigRootDir = import.meta.d const base_ts_parser = { name: enableVue - ? '(@jellyfin-vue/configs/eslint/typescript-vue - TypeScript & Vue) Parser extra config' - : '(@jellyfin-vue/configs/eslint/typescript-vue - TypeScript) Parser extra config', + ? '(@jellyfin-vue/configs/lint/typescript-vue - TypeScript & Vue) Parser extra config' + : '(@jellyfin-vue/configs/lint/typescript-vue - TypeScript) Parser extra config', files: enableVue ? vueAndTsFiles : tsFiles, languageOptions: { ...langOptions, diff --git a/packages/configs/eslint/rules/unocss.ts b/packages/configs/lint/rules/unocss.ts similarity index 100% rename from packages/configs/eslint/rules/unocss.ts rename to packages/configs/lint/rules/unocss.ts diff --git a/packages/configs/eslint/shared.ts b/packages/configs/lint/shared.ts similarity index 100% rename from packages/configs/eslint/shared.ts rename to packages/configs/lint/shared.ts diff --git a/packages/configs/package.json b/packages/configs/package.json index 0e554ceb..3d340a4d 100644 --- a/packages/configs/package.json +++ b/packages/configs/package.json @@ -4,7 +4,7 @@ "type": "module", "exports": { "./typescript/base.json": "./typescript/base.json", - "./eslint": "./eslint/index.ts", + "./lint": "./lint/index.ts", "./unocss": "./unocss.ts" }, "scripts": { diff --git a/packages/vite-plugins/eslint.config.ts b/packages/vite-plugins/eslint.config.ts index 46b5079a..8954595e 100644 --- a/packages/vite-plugins/eslint.config.ts +++ b/packages/vite-plugins/eslint.config.ts @@ -1,5 +1,5 @@ import type { Linter } from 'eslint'; -import { getBaseConfig, getTSVueConfig, getNodeFiles, tsFiles } from '@jellyfin-vue/configs/eslint'; +import { getBaseConfig, getTSVueConfig, getNodeFiles, tsFiles } from '@jellyfin-vue/configs/lint'; export default [ ...getBaseConfig('@jellyfin-vue/vite-plugins'),