Skip to content

Commit

Permalink
chore: eslint upgrade and lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Apr 20, 2024
1 parent 6910440 commit 0fde190
Show file tree
Hide file tree
Showing 26 changed files with 8,398 additions and 6,731 deletions.
1 change: 0 additions & 1 deletion benchmark/utils.mjs
@@ -1,6 +1,5 @@
import fs from 'fs/promises'

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export async function readJson(path) {
const data = await fs.readFile(path, 'utf8')
return JSON.parse(data)
Expand Down
3 changes: 1 addition & 2 deletions e2e/helper.ts
Expand Up @@ -51,7 +51,6 @@ export function getDom(html: string) {
}

export function getDataFromDom(dom: Document, selector: string) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return JSON.parse(
dom.querySelector(selector)!.textContent!.replace('"', '"')
)
Expand All @@ -66,7 +65,7 @@ export function assertLocaleHeadWithDom(dom: Document, headSelector: string) {
if (key === 'id') {
continue
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion

const v = tag!.getAttribute(key)
if (v !== value) {
throw new Error(`${key} ${v} !== ${value}`)
Expand Down
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -95,9 +95,9 @@
"bumpp": "^9.3.0",
"cross-env": "^7.0.3",
"esbuild-register": "^3.5.0",
"eslint": "^8.57.0",
"eslint": "^9.1.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-vue": "^9.24.0",
"eslint-plugin-vue": "^9.25.0",
"execa": "^5.0.0",
"fixpack": "^4.0.0",
"globals": "^15.0.0",
Expand Down Expand Up @@ -173,7 +173,7 @@
"secretlint"
]
},
"packageManager": "pnpm@8.9.2",
"packageManager": "pnpm@9.0.4",
"pnpm": {
"overrides": {
"vue": "3.4.20",
Expand Down
6 changes: 3 additions & 3 deletions packages/core-base/src/context.ts
Expand Up @@ -116,7 +116,7 @@ export type LocaleMessages<
*
* @VueI18nGeneral
*/
export interface DefineCoreLocaleMessage extends LocaleMessage<string> {} // eslint-disable-line @typescript-eslint/no-empty-interface
export interface DefineCoreLocaleMessage extends LocaleMessage<string> {}

export type DefaultCoreLocaleMessageSchema<
Schema = RemoveIndexSignature<{
Expand Down Expand Up @@ -252,7 +252,7 @@ export interface CoreOptions<
export interface CoreInternalOptions {
__datetimeFormatters?: Map<string, Intl.DateTimeFormat>
__numberFormatters?: Map<string, Intl.NumberFormat>
__v_emitter?: VueDevToolsEmitter // eslint-disable-line camelcase
__v_emitter?: VueDevToolsEmitter
__meta?: MetaInfo
}

Expand Down Expand Up @@ -327,7 +327,7 @@ export interface CoreInternalContext {
__datetimeFormatters: Map<string, Intl.DateTimeFormat>
__numberFormatters: Map<string, Intl.NumberFormat>
__localeChainCache?: Map<Locale, Locale[]>
__v_emitter?: VueDevToolsEmitter // eslint-disable-line camelcase
__v_emitter?: VueDevToolsEmitter
__meta: MetaInfo // for Intlify DevTools
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core-base/src/fallbacker.ts
Expand Up @@ -87,7 +87,7 @@ export type LocaleFallbacker = <Message = string>(
export function fallbackWithSimple<Message = string>(
ctx: CoreContext<Message>,
fallback: FallbackLocale,
start: Locale // eslint-disable-line @typescript-eslint/no-unused-vars
start: Locale
): Locale[] {
// prettier-ignore
return [...new Set(
Expand Down
2 changes: 1 addition & 1 deletion packages/format-explorer/src/shims-vue.d.ts
@@ -1,6 +1,6 @@
declare module '*.vue' {
import { DefineComponent } from 'vue'
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const component: DefineComponent<{}, {}, any>
// @ts-ignore
export default component
Expand Down
2 changes: 1 addition & 1 deletion packages/message-compiler/src/generator.ts
Expand Up @@ -284,7 +284,7 @@ function generateNode(generator: CodeGenerator, node: Node): void {
// generate code from AST
export const generate = (
ast: ResourceNode,
options: CodeGenOptions = {} // eslint-disable-line
options: CodeGenOptions = {}
): CodeGenResult => {
const mode = isString(options.mode) ? options.mode : 'normal'
const filename = isString(options.filename)
Expand Down
2 changes: 1 addition & 1 deletion packages/message-compiler/src/scanner.ts
Expand Up @@ -79,7 +79,7 @@ export function createScanner(str: string): Scanner {

function skipToPeek(): void {
const target = _index + _peekOffset
// eslint-disable-next-line no-unmodified-loop-condition

while (target !== _index) {
next()
}
Expand Down
2 changes: 1 addition & 1 deletion packages/message-compiler/src/tokenizer.ts
Expand Up @@ -481,7 +481,7 @@ export function createTokenizer(

function readText(scnr: Scanner): string {
let buf = ''
// eslint-disable-next-line no-constant-condition

while (true) {
const ch = scnr.currentChar()
if (
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/messages.ts
@@ -1,7 +1,7 @@
import { isArray, isObject } from './utils'

const isNotObjectOrIsArray = (val: unknown) => !isObject(val) || isArray(val)
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function deepCopy(src: any, des: any): void {
// src and des should both be objects, and none of them can be a array
if (isNotObjectOrIsArray(src) || isNotObjectOrIsArray(des)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/size-check-petite-vue-i18n/src/shims-vue.d.ts
@@ -1,6 +1,6 @@
declare module '*.vue' {
import { DefineComponent } from 'vue'
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const component: DefineComponent<{}, {}, any>
// @ts-ignore
export default component
Expand Down
2 changes: 1 addition & 1 deletion packages/size-check-vue-i18n/src/shims-vue.d.ts
@@ -1,6 +1,6 @@
declare module '*.vue' {
import { DefineComponent } from 'vue'
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const component: DefineComponent<{}, {}, any>
// @ts-ignore
export default component
Expand Down
1 change: 0 additions & 1 deletion packages/vue-i18n-core/src/components/DatetimeFormat.ts
Expand Up @@ -6,7 +6,6 @@ import { DatetimePartsSymbol } from '../symbols'
import { renderFormatter } from './formatRenderer'
import { baseFormatProps } from './base'

/* eslint-enable @typescript-eslint/no-unused-vars */
import type { VNodeProps } from 'vue'
import type { DateTimeOptions } from '@intlify/core-base'
import type { Composer, ComposerInternal } from '../composer'
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-i18n-core/src/components/Translation.ts
Expand Up @@ -39,7 +39,7 @@ export const TranslationImpl = /*#__PURE__*/ defineComponent({
},
plural: {
type: [Number, String],
// eslint-disable-next-line @typescript-eslint/no-explicit-any

validator: (val: any): boolean => isNumber(val) || !isNaN(val)
}
},
Expand Down
22 changes: 11 additions & 11 deletions packages/vue-i18n-core/src/composer.ts
Expand Up @@ -150,7 +150,7 @@ export type VueMessageType = string | ResourceNode | VNode
*
* @VueI18nGeneral
*/
export interface DefineLocaleMessage extends LocaleMessage<VueMessageType> {} // eslint-disable-line @typescript-eslint/no-empty-interface
export interface DefineLocaleMessage extends LocaleMessage<VueMessageType> {}

/**
* The type definition of datetime format
Expand All @@ -177,7 +177,7 @@ export interface DefineLocaleMessage extends LocaleMessage<VueMessageType> {} //
*
* @VueI18nGeneral
*/
export interface DefineDateTimeFormat extends DateTimeFormat {} // eslint-disable-line @typescript-eslint/no-empty-interface
export interface DefineDateTimeFormat extends DateTimeFormat {}

/**
* The type definition of number format
Expand Down Expand Up @@ -205,7 +205,7 @@ export interface DefineDateTimeFormat extends DateTimeFormat {} // eslint-disabl
*
* @VueI18nGeneral
*/
export interface DefineNumberFormat extends NumberFormat {} // eslint-disable-line @typescript-eslint/no-empty-interface
export interface DefineNumberFormat extends NumberFormat {}

export type DefaultLocaleMessageSchema<
Schema = RemoveIndexSignature<{
Expand Down Expand Up @@ -1196,7 +1196,7 @@ export interface ComposerNumberFormatting<
*
* @VueI18nComposition
*/
export interface ComposerCustom {} // eslint-disable-line @typescript-eslint/no-empty-interface
export interface ComposerCustom {}

/**
* Composer interfaces
Expand Down Expand Up @@ -1801,9 +1801,9 @@ function defineCoreMissingHandler(missing: MissingHandler): CoreMissingHandler {
/* #__NO_SIDE_EFFECTS__ */
const getMetaInfo = (): MetaInfo | null => {
const instance = getCurrentInstance()
let meta: any = null // eslint-disable-line @typescript-eslint/no-explicit-any
let meta: any = null
return instance && (meta = getComponentOptions(instance)[DEVTOOLS_META])
? { [DEVTOOLS_META]: meta } // eslint-disable-line @typescript-eslint/no-explicit-any
? { [DEVTOOLS_META]: meta }
: null
}

Expand Down Expand Up @@ -1867,7 +1867,7 @@ export function createComposer<
*
* @internal
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types

export function createComposer(options: any = {}, VueI18nLegacy?: any): any {
type Message = VueMessageType
const { __root, __injectWithOption } = options as ComposerInternalOptions<
Expand Down Expand Up @@ -2172,7 +2172,7 @@ export function createComposer(options: any = {}, VueI18nLegacy?: any): any {

function isResolvedTranslateMessage(
type: ComposerWarnType,
arg: any // eslint-disable-line @typescript-eslint/no-explicit-any
arg: any
): boolean {
return type !== 'translate' || !arg.resolvedMessage
}
Expand Down Expand Up @@ -2337,7 +2337,7 @@ export function createComposer(options: any = {}, VueI18nLegacy?: any): any {
},
() => parseTranslateArgs(...args),
'translate',
// eslint-disable-next-line @typescript-eslint/no-explicit-any

root => (root as any)[TranslateVNodeSymbol](...args),
key => [createTextNode(key as string)],
val => isArray(val)
Expand All @@ -2350,7 +2350,7 @@ export function createComposer(options: any = {}, VueI18nLegacy?: any): any {
context => Reflect.apply(number, null, [context, ...args]),
() => parseNumberArgs(...args),
'number format',
// eslint-disable-next-line @typescript-eslint/no-explicit-any

root => (root as any)[NumberPartsSymbol](...args),
NOOP_RETURN_ARRAY,
val => isString(val) || isArray(val)
Expand All @@ -2365,7 +2365,7 @@ export function createComposer(options: any = {}, VueI18nLegacy?: any): any {
context => Reflect.apply(datetime, null, [context, ...args]),
() => parseDateTimeArgs(...args),
'datetime format',
// eslint-disable-next-line @typescript-eslint/no-explicit-any

root => (root as any)[DatetimePartsSymbol](...args),
NOOP_RETURN_ARRAY,
val => isString(val) || isArray(val)
Expand Down
4 changes: 2 additions & 2 deletions packages/vue-i18n-core/src/i18n.ts
Expand Up @@ -518,7 +518,7 @@ export function createI18n<
? I18n<Messages, DateTimeFormats, NumberFormats, OptionLocale, false>
: I18n<Messages, DateTimeFormats, NumberFormats, OptionLocale, Legacy>

// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function createI18n(options: any = {}, VueI18nLegacy?: any): any {
type _I18n = I18n & I18nInternal

Expand Down Expand Up @@ -828,7 +828,7 @@ export function useI18n<
NonNullable<Options['numberFormats']>,
Options['locale'] extends unknown ? string : Options['locale']
>
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types

export function useI18n<
Options extends UseI18nOptions = UseI18nOptions,
Messages extends Record<string, unknown> = NonNullable<Options['messages']>,
Expand Down
3 changes: 1 addition & 2 deletions packages/vue-i18n-core/src/legacy.ts
Expand Up @@ -77,7 +77,6 @@ export type DateTimeFormatResult = string
/** @VueI18nLegacy */
export type NumberFormatResult = string
export interface Formatter {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
interpolate(message: string, values: any, path: string): Array<any> | null
}
export type VueI18nExtender = (vueI18n: VueI18n) => Disposer | undefined
Expand Down Expand Up @@ -1465,7 +1464,7 @@ export function createVueI18n<
*
* @internal
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types

export function createVueI18n(options: any = {}, VueI18nLegacy?: any): any {
type Message = VueMessageType

Expand Down
2 changes: 1 addition & 1 deletion packages/vue-i18n-core/src/mixins/bridge.ts
Expand Up @@ -10,7 +10,7 @@ import type { I18n } from '../i18n'
*/
export function defineMixin(
i18n: I18n,
VueI18n: any // eslint-disable-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
VueI18n: any // eslint-disable-line @typescript-eslint/no-explicit-any
): ComponentOptions {
return {
beforeCreate(): void {
Expand Down
4 changes: 1 addition & 3 deletions packages/vue-i18n-core/src/utils.ts
Expand Up @@ -38,7 +38,6 @@ declare module 'vue' {
}
}

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function isLegacyVueI18n(VueI18n: any): boolean {
if (VueI18n == null || VueI18n.version == null) {
return false
Expand Down Expand Up @@ -148,15 +147,14 @@ export function getLocaleMessages<Messages = {}>(
return ret as { [K in keyof Messages]: Messages[K] }
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function getComponentOptions(instance: ComponentInternalInstance): any {
return !__BRIDGE__ ? instance.type : instance.proxy!.$options
}

export function adjustI18nResources(
gl: Composer,
options: ComposerOptions,
componentOptions: any // eslint-disable-line @typescript-eslint/no-explicit-any
componentOptions: any
): void {
let messages = isObject(options.messages) ? options.messages : {}
if ('__i18nGlobal' in componentOptions) {
Expand Down

0 comments on commit 0fde190

Please sign in to comment.