Skip to content

Commit 690cdff

Browse files
committed
format
1 parent 0c1f86d commit 690cdff

15 files changed

+64
-74
lines changed

docs/.vitepress/components/resource-group.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default {
1414
return {
1515
$resourceGroup: {
1616
async set(fileName, code) {
17-
Vue.set(data.fileContents, '/path/' + fileName, code)
17+
Vue.set(data.fileContents, `/path/${fileName}`, code)
1818
1919
const timeSeq = ++waitSeq
2020
await Vue.nextTick()

lib/rules/no-duplicate-keys-in-locale.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ interface PathStack {
3535
function getMessageFilepath(fullPath: string, context: RuleContext) {
3636
const cwd = getCwd(context)
3737
if (fullPath.startsWith(cwd)) {
38-
return fullPath.replace(cwd + '/', './')
38+
return fullPath.replace(`${cwd}/`, './')
3939
}
4040
return fullPath
4141
}
@@ -131,7 +131,7 @@ function create(context: RuleContext): RuleListener {
131131
}
132132
if (typeof value.value !== 'object') {
133133
reportFiles.push(
134-
'"' + getMessageFilepath(value.source.fullpath, context) + '"'
134+
`"${getMessageFilepath(value.source.fullpath, context)}"`
135135
)
136136
} else {
137137
nextOtherDictionaries.push({
@@ -147,7 +147,7 @@ function create(context: RuleContext): RuleListener {
147147
message: `duplicate key '${keyPathStr}' in '${pathStack.locale}'. ${
148148
reportFiles.length === 0
149149
? last
150-
: reportFiles.join(', ') + ', and ' + last
150+
: `${reportFiles.join(', ')}, and ${last}`
151151
} has the same key`,
152152
loc: reportNode.loc
153153
})

lib/rules/no-raw-text.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,14 +609,15 @@ function* generateFixAddI18nBlock(
609609
for (const objectNode of objects) {
610610
const first = objectNode.properties[0]
611611

612-
let indent =
612+
let indent = `${
613613
/^\s*/.exec(
614614
sourceCode.lines[offsets.getLoc(objectNode.range[0]).line - 1]
615-
)![0] + ' '
615+
)![0]
616+
} `
616617
let next = ''
617618
if (first) {
618619
if (objectNode.loc.start.line === first.loc.start.line) {
619-
next = ',\n' + indent
620+
next = `,\n${indent}`
620621
} else {
621622
indent = /^\s*/.exec(
622623
sourceCode.lines[offsets.getLoc(first.range[0]).line - 1]

lib/rules/prefer-sfc-lang-attr.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ function create(context: RuleContext): RuleListener {
3636
const beforeToken = tokenStore.getTokenBefore(closeToken)
3737
return fixer.insertTextBeforeRange(
3838
closeToken.range,
39-
(beforeToken.range[1] < closeToken.range[0] ? '' : ' ') +
40-
'lang="json" '
39+
`${
40+
beforeToken.range[1] < closeToken.range[0] ? '' : ' '
41+
}lang="json" `
4142
)
4243
}
4344
})

lib/utils/compat.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as compat from 'eslint-compat-utils'
2-
import { RuleContext, SourceCode } from '../types'
2+
import type { RuleContext, SourceCode } from '../types'
33

4-
export function getFilename(context: RuleContext) {
5-
return compat.getFilename(context as any)
4+
export function getFilename(context: RuleContext): string {
5+
return compat.getFilename(context as never)
66
}
77
export function getSourceCode(context: RuleContext): SourceCode {
8-
return compat.getSourceCode(context as any) as any
8+
return compat.getSourceCode(context as never) as never
99
}

lib/utils/get-cwd.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { RuleContext } from '../types'
2+
import { getCwd as getCwdCompat } from 'eslint-compat-utils'
23

34
export function getCwd(context: RuleContext): string {
4-
return (
5-
context.settings?.['vue-i18n']?.cwd ?? context.getCwd?.() ?? process.cwd()
6-
)
5+
return context.settings?.['vue-i18n']?.cwd ?? getCwdCompat(context as never)
76
}

tests/lib/eslint-compat.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { getLegacyESLint, getESLint } from 'eslint-compat-utils/eslint';
2-
import { getLinter } from 'eslint-compat-utils/linter';
3-
import { getRuleTester, getRuleIdPrefix } from 'eslint-compat-utils/rule-tester';
1+
import { getLegacyESLint, getESLint } from 'eslint-compat-utils/eslint'
2+
import { getLinter } from 'eslint-compat-utils/linter'
3+
import { getRuleTester, getRuleIdPrefix } from 'eslint-compat-utils/rule-tester'
44

5-
export const LegacyESLint = getLegacyESLint();
6-
export const ESLint = getESLint();
7-
export const RuleTester = getRuleTester();
8-
export const TEST_RULE_ID_PREFIX = getRuleIdPrefix();
9-
export const Linter = getLinter();
5+
export const LegacyESLint = getLegacyESLint()
6+
export const ESLint = getESLint()
7+
export const RuleTester = getRuleTester()
8+
export const TEST_RULE_ID_PREFIX = getRuleIdPrefix()
9+
export const Linter = getLinter()

tests/lib/rules/key-format-style.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const options = {
2121
filename: join(fileLocalesRoot, 'test.json'),
2222
settings: {
2323
'vue-i18n': {
24-
localeDir: fileLocalesRoot + '/*.{json,yaml,yml}'
24+
localeDir: `${fileLocalesRoot}/*.{json,yaml,yml}`
2525
}
2626
}
2727
},
@@ -31,7 +31,7 @@ const options = {
3131
settings: {
3232
'vue-i18n': {
3333
localeDir: {
34-
pattern: keyLocalesRoot + '/*.{json,yaml,yml}',
34+
pattern: `${keyLocalesRoot}/*.{json,yaml,yml}`,
3535
localeKey: 'key'
3636
} as SettingsVueI18nLocaleDirObject
3737
}
@@ -44,7 +44,7 @@ const options = {
4444
filename: join(fileLocalesRoot, 'test.yaml'),
4545
settings: {
4646
'vue-i18n': {
47-
localeDir: fileLocalesRoot + '/*.{json,yaml,yml}'
47+
localeDir: `${fileLocalesRoot}/*.{json,yaml,yml}`
4848
}
4949
}
5050
},
@@ -54,7 +54,7 @@ const options = {
5454
settings: {
5555
'vue-i18n': {
5656
localeDir: {
57-
pattern: keyLocalesRoot + '/*.{json,yaml,yml}',
57+
pattern: `${keyLocalesRoot}/*.{json,yaml,yml}`,
5858
localeKey: 'key'
5959
} as SettingsVueI18nLocaleDirObject
6060
}

tests/lib/rules/no-missing-keys-in-other-locales.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,19 @@ const YAML_FILENAME_LOCALE_KEY_TYPE_KEY = join(
3434
const SETTINGS = {
3535
FILE: {
3636
'vue-i18n': {
37-
localeDir:
38-
join(FIXTURES_ROOT, 'vue-cli-format/locales') + '/*.{json,yaml,yml}'
37+
localeDir: `${join(
38+
FIXTURES_ROOT,
39+
'vue-cli-format/locales'
40+
)}/*.{json,yaml,yml}`
3941
}
4042
},
4143
KEY: {
4244
'vue-i18n': {
4345
localeDir: {
44-
pattern:
45-
join(FIXTURES_ROOT, 'constructor-option-format/locales') +
46-
'/*.{json,yaml,yml}',
46+
pattern: `${join(
47+
FIXTURES_ROOT,
48+
'constructor-option-format/locales'
49+
)}/*.{json,yaml,yml}`,
4750
localeKey: 'key'
4851
}
4952
}

tests/lib/rules/no-missing-keys.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
*/
44
import { join } from 'node:path'
55
import { RuleTester } from '../eslint-compat'
6-
import { RuleTester as RawRuleTester } from 'eslint'
6+
import type { RuleTester as RawRuleTester } from 'eslint'
77
import rule from '../../../lib/rules/no-missing-keys'
88
import * as vueParser from 'vue-eslint-parser'
9-
// @ts-expect-error
9+
// @ts-expect-error -- missing type
1010
import * as espree from 'espree'
1111

1212
const localeDirs = [
@@ -305,7 +305,7 @@ tester.run('no-missing-keys', rule as never, {
305305
]
306306
},
307307
{
308-
// @ts-expect-error
308+
// @ts-expect-error -- Type error for eslint v9
309309
languageOptions: {
310310
parser: espree
311311
},

0 commit comments

Comments
 (0)