Skip to content

Commit

Permalink
chore: upgrade eslint releated deps and fix eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Sep 4, 2024
1 parent fd5bbe9 commit 69c56d2
Show file tree
Hide file tree
Showing 22 changed files with 491 additions and 423 deletions.
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
"editor.formatOnPaste": true,
"editor.formatOnType": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
"source.fixAll.eslint": "explicit",
"source.organizeImports": "always"
},
"eslint.experimental.useFlatConfig": true,
"eslint.useFlatConfig": true,
"typescript.tsdk": "node_modules/typescript/lib",
"volar.tsPlugin": true
}
43 changes: 25 additions & 18 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
import globals from 'globals'
import js from '@eslint/js'
import ts from 'typescript-eslint'
import pritter from 'eslint-config-prettier'
import vue from 'eslint-plugin-vue'
import globals from 'globals'
import ts from 'typescript-eslint'

export default [
// ignore globally
{
ignores: [
'**/dist/**',
'**/fixtures/**',
'**/coverage/**',
'**/.vitepress/**',
'**/.vuepress/**',
'**/test/**',
'**/examples/**',
'shim.d.ts',
'.eslintcache',
'.eslintrc.cjs'
]
},

// globals
{
// files: ['**/*.js', '**/*.ts', '**/*.vue', '**/*.json'],
Expand Down Expand Up @@ -87,10 +71,33 @@ export default [
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-empty-object-type': 'off', // FIXME: enable this rule
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/only-throw-error': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'vue/one-component-per-file': 'off',
'vue/multi-word-component-names': 'off',
'vue/experimental-script-setup-vars': 'off',
'vue/no-deprecated-props-default-this': 'off'
}
},

// ignore globally
{
ignores: [
'**/dist/**',
'**/fixtures/**',
'**/coverage/**',
'**/.vitepress/**',
'**/.vuepress/**',
'**/test/**',
'**/examples/**',
'shim.d.ts',
'.eslintcache',
'.eslintrc.cjs',
'packages/*/index.js',
'docsgen.config.js',
'scripts/api/*.js'
]
}
]
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"test:unit": "cross-env TZ=UTC vitest run -c ./vitest.unit.config.ts"
},
"devDependencies": {
"@eslint/js": "^9.0.0",
"@eslint/js": "^9.9.1",
"@intlify/core-base": "workspace:*",
"@intlify/message-compiler": "workspace:*",
"@microsoft/api-extractor": "7.15.2",
Expand All @@ -83,24 +83,24 @@
"@secretlint/secretlint-rule-preset-recommend": "^3.1.0",
"@textlint-rule/textlint-rule-no-unmatched-pair": "^2.0.0",
"@types/brotli": "^1.3.4",
"@types/eslint": "^8.56.7",
"@types/eslint": "^9.6.1",
"@types/js-yaml": "^4.0.5",
"@types/jsdom": "^21.1.1",
"@types/minimist": "^1.2.5",
"@types/node": "^20.11.21",
"@types/node": "^22.5.3",
"@types/rc": "^1.2.4",
"@vitest/coverage-v8": "^2.0.0",
"api-docs-gen": "^0.4.0",
"benchmark": "^2.1.4",
"brotli": "^1.3.2",
"bumpp": "^9.3.0",
"cross-env": "^7.0.3",
"eslint": "^9.1.0",
"eslint": "^9.9.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-vue": "^9.25.0",
"eslint-plugin-vue": "^9.28.0",
"execa": "^5.0.0",
"fixpack": "^4.0.0",
"globals": "^15.0.0",
"globals": "^15.9.0",
"globby": "^14.0.1",
"js-yaml": "^4.1.0",
"jsdom": "^24.0.0",
Expand All @@ -114,7 +114,7 @@
"picocolors": "^1.0.0",
"pkg-pr-new": "^0.0.20",
"playwright-core": "^1.45.3",
"prettier": "^3.2.5",
"prettier": "^3.3.3",
"rc": "^1.2.8",
"rimraf": "^6.0.0",
"rollup": "^3.29.2",
Expand Down Expand Up @@ -144,7 +144,7 @@
"tslib": "^2.6.2",
"tsx": "^4.11.2",
"typescript": "^5.3.3",
"typescript-eslint": "^7.5.0",
"typescript-eslint": "^8.4.0",
"vitepress": "1.3.4",
"vitest": "^2.0.4",
"vue": "3.4.38",
Expand Down
7 changes: 4 additions & 3 deletions packages/core-base/src/compilation.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { warn, format, isObject, isBoolean, isString } from '@intlify/shared'
import {
baseCompile as baseCompileCore,
defaultOnError,
detectHtmlTag
} from '@intlify/message-compiler'
import { format, isBoolean, isObject, isString, warn } from '@intlify/shared'
import { format as formatMessage } from './format'

import type {
CompileOptions,
CompileError,
CompileOptions,
CompilerResult,
ResourceNode
} from '@intlify/message-compiler'
import type { MessageFunction, MessageFunctions } from './runtime'
import type { MessageCompilerContext } from './context'
import type { MessageFunction, MessageFunctions } from './runtime'

const WARN_MESSAGE = `Detected HTML in '{source}' message. Recommend not using HTML messages to avoid XSS.`

Expand Down Expand Up @@ -71,6 +71,7 @@ export function compile<
const warnHtmlMessage = isBoolean(context.warnHtmlMessage)
? context.warnHtmlMessage
: true

__DEV__ && checkHtmlMessage(message, warnHtmlMessage)

// check caches
Expand Down
48 changes: 24 additions & 24 deletions packages/core-base/src/context.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import {
warn,
isString,
assign,
isArray,
isBoolean,
isRegExp,
isFunction,
isPlainObject,
assign,
isObject,
isPlainObject,
isRegExp,
isString,
warn,
warnOnce
} from '@intlify/shared'
import { initI18nDevTools } from './devtools'
import { CoreWarnCodes, getWarnMessage } from './warnings'
import { resolveWithKeyValue } from './resolver'
import { fallbackWithSimple } from './fallbacker'
import { resolveWithKeyValue } from './resolver'
import { CoreWarnCodes, getWarnMessage } from './warnings'

import type { CompileOptions, ResourceNode } from '@intlify/message-compiler'
import type { VueDevToolsEmitter } from '@intlify/devtools-types'
import type { Path, MessageResolver } from './resolver'
import type { CompileOptions, ResourceNode } from '@intlify/message-compiler'
import type { LocaleFallbacker } from './fallbacker'
import type { MessageResolver, Path } from './resolver'
import type {
Locale,
LocaleDetector,
FallbackLocale,
CoreMissingType,
FallbackLocale,
LinkedModifiers,
PluralizationRules,
MessageProcessor,
Locale,
LocaleDetector,
MessageFunction,
MessageFunctionReturn,
MessageType
MessageProcessor,
MessageType,
PluralizationRules
} from './runtime'
import type {
UnionToTuple,
DateTimeFormat,
DateTimeFormats as DateTimeFormatsType,
FallbackLocales,
IsEmptyObject,
IsNever,
LocaleParams,
LocaleRecord,
NumberFormat,
DateTimeFormat,
DateTimeFormats as DateTimeFormatsType,
NumberFormats as NumberFormatsType,
SchemaParams,
LocaleParams,
PickupLocales,
FallbackLocales,
IsEmptyObject,
RemoveIndexSignature
RemoveIndexSignature,
SchemaParams,
UnionToTuple
} from './types'
import type { LocaleFallbacker } from './fallbacker'

export interface MetaInfo {
[field: string]: unknown
Expand Down
24 changes: 12 additions & 12 deletions packages/core-base/src/datetime.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import {
isString,
assign,
isBoolean,
isPlainObject,
isDate,
isNumber,
isEmptyObject,
assign
isNumber,
isPlainObject,
isString
} from '@intlify/shared'
import {
handleMissing,
isTranslateFallbackWarn,
NOT_REOSLVED,
MISSING_RESOLVE_VALUE
MISSING_RESOLVE_VALUE,
NOT_REOSLVED
} from './context'
import { CoreWarnCodes, getWarnMessage } from './warnings'
import { CoreErrorCodes, createCoreError } from './errors'
import { getLocale } from './fallbacker'
import { Availabilities } from './intl'
import { CoreWarnCodes, getWarnMessage } from './warnings'

import type { Locale, FallbackLocale } from './runtime'
import type { CoreContext, CoreInternalContext } from './context'
import type { LocaleOptions } from './fallbacker'
import type { FallbackLocale, Locale } from './runtime'
import type {
DateTimeFormat,
DateTimeFormats as DateTimeFormatsType,
DateTimeFormatOptions,
DateTimeFormats as DateTimeFormatsType,
PickupFormatKeys
} from './types/index'
import type { LocaleOptions } from './fallbacker'
import type { CoreContext, CoreInternalContext } from './context'

/**
* # datetime
Expand Down Expand Up @@ -345,7 +345,7 @@ export function parseDateTimeArgs(
try {
// This will fail if the date is not valid
value.toISOString()
} catch (e) {
} catch {
throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT)
}
} else if (isDate(arg1)) {
Expand Down
5 changes: 3 additions & 2 deletions packages/core-base/src/devtools.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {
IntlifyDevToolsHooks,
IntlifyDevToolsEmitter,
IntlifyDevToolsHookPayloads,
IntlifyDevToolsEmitter
IntlifyDevToolsHooks
} from '@intlify/devtools-types'

let devtools: IntlifyDevToolsEmitter | null = null
Expand All @@ -20,6 +20,7 @@ export function initI18nDevTools(
meta?: Record<string, unknown>
): void {
// TODO: queue if devtools is undefined

devtools &&
devtools.emit('i18n:init', {
timestamp: Date.now(),
Expand Down
13 changes: 7 additions & 6 deletions packages/core-base/src/runtime.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { HelperNameMap } from '@intlify/message-compiler'
import {
assign,
isNumber,
isArray,
isFunction,
toDisplayString,
isNumber,
isObject,
isString,
isArray,
isPlainObject,
join
isString,
join,
toDisplayString
} from '@intlify/shared'
import { HelperNameMap } from '@intlify/message-compiler'
import { Path } from './resolver'
import { IsNever } from './types'

Expand Down Expand Up @@ -369,6 +369,7 @@ export function createMessageContext<T = string, N = {}>(

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const _named = options.named || ({} as any)

isNumber(options.pluralIndex) && normalizeNamed(pluralIndex, _named)
const named = (key: string): unknown => _named[key]

Expand Down
2 changes: 1 addition & 1 deletion packages/devtools-types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface IntlifyRecord {
id: number
i18n: unknown // TODO:
version: string
types: Record<string, string | Symbol> // TODO
types: Record<string, string | symbol> // TODO
}

export type IntlifyDevToolsHooks = 'i18n:init' | 'function:translate'
Expand Down
Loading

0 comments on commit 69c56d2

Please sign in to comment.