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

+1-1
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

+3-3
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

+4-3
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

+3-2
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

+4-4
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

+2-3
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

+8-8
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

+4-4
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

+8-5
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

+3-3
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
},

tests/lib/rules/no-unknown-locale.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const options = {
1717
filename: join(fileLocalesRoot, 'test.json'),
1818
settings: {
1919
'vue-i18n': {
20-
localeDir: fileLocalesRoot + '/*.{json,yaml,yml}'
20+
localeDir: `${fileLocalesRoot}/*.{json,yaml,yml}`
2121
}
2222
}
2323
},
@@ -26,7 +26,7 @@ const options = {
2626
filename: join(fileLocalesRoot, 'en.json'),
2727
settings: {
2828
'vue-i18n': {
29-
localeDir: fileLocalesRoot + '/*.{json,yaml,yml}'
29+
localeDir: `${fileLocalesRoot}/*.{json,yaml,yml}`
3030
}
3131
}
3232
},
@@ -36,7 +36,7 @@ const options = {
3636
settings: {
3737
'vue-i18n': {
3838
localeDir: {
39-
pattern: keyLocalesRoot + '/*.{json,yaml,yml}',
39+
pattern: `${keyLocalesRoot}/*.{json,yaml,yml}`,
4040
localeKey: 'key'
4141
} as SettingsVueI18nLocaleDirObject
4242
}
@@ -49,7 +49,7 @@ const options = {
4949
filename: join(fileLocalesRoot, 'test.yaml'),
5050
settings: {
5151
'vue-i18n': {
52-
localeDir: fileLocalesRoot + '/*.{json,yaml,yml}'
52+
localeDir: `${fileLocalesRoot}/*.{json,yaml,yml}`
5353
}
5454
}
5555
},
@@ -58,7 +58,7 @@ const options = {
5858
filename: join(fileLocalesRoot, 'en.yaml'),
5959
settings: {
6060
'vue-i18n': {
61-
localeDir: fileLocalesRoot + '/*.{json,yaml,yml}'
61+
localeDir: `${fileLocalesRoot}/*.{json,yaml,yml}`
6262
}
6363
}
6464
},
@@ -68,7 +68,7 @@ const options = {
6868
settings: {
6969
'vue-i18n': {
7070
localeDir: {
71-
pattern: keyLocalesRoot + '/*.{json,yaml,yml}',
71+
pattern: `${keyLocalesRoot}/*.{json,yaml,yml}`,
7272
localeKey: 'key'
7373
} as SettingsVueI18nLocaleDirObject
7474
}

tests/lib/rules/prefer-linked-key-with-paren.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const options = {
2121
settings: {
2222
'vue-i18n': {
2323
localeDir: {
24-
pattern: FIXTURES_ROOT + '/*.{json,yaml,yml}'
24+
pattern: `${FIXTURES_ROOT}/*.{json,yaml,yml}`
2525
},
2626
messageSyntaxVersion
2727
}
@@ -35,7 +35,7 @@ const options = {
3535
settings: {
3636
'vue-i18n': {
3737
localeDir: {
38-
pattern: FIXTURES_ROOT + '/*.{json,yaml,yml}'
38+
pattern: `${FIXTURES_ROOT}/*.{json,yaml,yml}`
3939
},
4040
messageSyntaxVersion
4141
}
@@ -385,9 +385,7 @@ tester.run('prefer-linked-key-with-paren', rule as never, {
385385
...options.yaml(null),
386386
output: null,
387387
errors: [
388-
"If you want to use '" +
389-
TEST_RULE_ID_PREFIX +
390-
"prefer-linked-key-with-paren' rule, you need to set 'messageSyntaxVersion' at 'settings'. See the 'eslint-plugin-vue-i18n' documentation"
388+
`If you want to use '${TEST_RULE_ID_PREFIX}prefer-linked-key-with-paren' rule, you need to set 'messageSyntaxVersion' at 'settings'. See the 'eslint-plugin-vue-i18n' documentation`
391389
]
392390
}
393391
]

tests/lib/rules/valid-message-syntax.ts

+12-24
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const options = {
1717
filename: join(localesRoot, 'test.json'),
1818
settings: {
1919
'vue-i18n': {
20-
localeDir: localesRoot + '/*.{json,yaml,yml}'
20+
localeDir: `${localesRoot}/*.{json,yaml,yml}`
2121
}
2222
}
2323
},
@@ -26,7 +26,7 @@ const options = {
2626
filename: join(localesRoot, 'test.json'),
2727
settings: {
2828
'vue-i18n': {
29-
localeDir: localesRoot + '/*.{json,yaml,yml}',
29+
localeDir: `${localesRoot}/*.{json,yaml,yml}`,
3030
messageSyntaxVersion: '^8.0.0'
3131
}
3232
}
@@ -36,7 +36,7 @@ const options = {
3636
filename: join(localesRoot, 'test.json'),
3737
settings: {
3838
'vue-i18n': {
39-
localeDir: localesRoot + '/*.{json,yaml,yml}',
39+
localeDir: `${localesRoot}/*.{json,yaml,yml}`,
4040
messageSyntaxVersion: '^9.0.0'
4141
}
4242
}
@@ -48,7 +48,7 @@ const options = {
4848
filename: join(localesRoot, 'test.yaml'),
4949
settings: {
5050
'vue-i18n': {
51-
localeDir: localesRoot + '/*.{json,yaml,yml}'
51+
localeDir: `${localesRoot}/*.{json,yaml,yml}`
5252
}
5353
}
5454
},
@@ -57,7 +57,7 @@ const options = {
5757
filename: join(localesRoot, 'test.yaml'),
5858
settings: {
5959
'vue-i18n': {
60-
localeDir: localesRoot + '/*.{json,yaml,yml}',
60+
localeDir: `${localesRoot}/*.{json,yaml,yml}`,
6161
messageSyntaxVersion: '^8.0.0'
6262
}
6363
}
@@ -67,7 +67,7 @@ const options = {
6767
filename: join(localesRoot, 'test.yaml'),
6868
settings: {
6969
'vue-i18n': {
70-
localeDir: localesRoot + '/*.{json,yaml,yml}',
70+
localeDir: `${localesRoot}/*.{json,yaml,yml}`,
7171
messageSyntaxVersion: '^9.0.0'
7272
}
7373
}
@@ -79,7 +79,7 @@ const options = {
7979
filename: join(localesRoot, 'test.vue'),
8080
settings: {
8181
'vue-i18n': {
82-
localeDir: localesRoot + '/*.{json,yaml,yml}'
82+
localeDir: `${localesRoot}/*.{json,yaml,yml}`
8383
}
8484
}
8585
},
@@ -88,7 +88,7 @@ const options = {
8888
filename: join(localesRoot, 'test.vue'),
8989
settings: {
9090
'vue-i18n': {
91-
localeDir: localesRoot + '/*.{json,yaml,yml}',
91+
localeDir: `${localesRoot}/*.{json,yaml,yml}`,
9292
messageSyntaxVersion: '^9.0.0'
9393
}
9494
}
@@ -155,10 +155,7 @@ tester.run('valid-message-syntax', rule as never, {
155155
...options.json.default,
156156
errors: [
157157
{
158-
message:
159-
"If you want to use '" +
160-
TEST_RULE_ID_PREFIX +
161-
"valid-message-syntax' rule, you need to set 'messageSyntaxVersion' at 'settings'. See the 'eslint-plugin-vue-i18n' documentation",
158+
message: `If you want to use '${TEST_RULE_ID_PREFIX}valid-message-syntax' rule, you need to set 'messageSyntaxVersion' at 'settings'. See the 'eslint-plugin-vue-i18n' documentation`,
162159
line: 1,
163160
column: 1
164161
},
@@ -233,10 +230,7 @@ tester.run('valid-message-syntax', rule as never, {
233230
...options.yaml.default,
234231
errors: [
235232
{
236-
message:
237-
"If you want to use '" +
238-
TEST_RULE_ID_PREFIX +
239-
"valid-message-syntax' rule, you need to set 'messageSyntaxVersion' at 'settings'. See the 'eslint-plugin-vue-i18n' documentation",
233+
message: `If you want to use '${TEST_RULE_ID_PREFIX}valid-message-syntax' rule, you need to set 'messageSyntaxVersion' at 'settings'. See the 'eslint-plugin-vue-i18n' documentation`,
240234
line: 1,
241235
column: 1
242236
},
@@ -254,10 +248,7 @@ tester.run('valid-message-syntax', rule as never, {
254248
...options.yaml.default,
255249
errors: [
256250
{
257-
message:
258-
"If you want to use '" +
259-
TEST_RULE_ID_PREFIX +
260-
"valid-message-syntax' rule, you need to set 'messageSyntaxVersion' at 'settings'. See the 'eslint-plugin-vue-i18n' documentation",
251+
message: `If you want to use '${TEST_RULE_ID_PREFIX}valid-message-syntax' rule, you need to set 'messageSyntaxVersion' at 'settings'. See the 'eslint-plugin-vue-i18n' documentation`,
261252
line: 1,
262253
column: 1
263254
},
@@ -379,10 +370,7 @@ tester.run('valid-message-syntax', rule as never, {
379370
...options.vue.default,
380371
errors: [
381372
{
382-
message:
383-
"If you want to use '" +
384-
TEST_RULE_ID_PREFIX +
385-
"valid-message-syntax' rule, you need to set 'messageSyntaxVersion' at 'settings'. See the 'eslint-plugin-vue-i18n' documentation",
373+
message: `If you want to use '${TEST_RULE_ID_PREFIX}valid-message-syntax' rule, you need to set 'messageSyntaxVersion' at 'settings'. See the 'eslint-plugin-vue-i18n' documentation`,
386374
line: 1,
387375
column: 1
388376
},

0 commit comments

Comments
 (0)